本文整理汇总了Python中tests.fixtures.PageFactory类的典型用法代码示例。如果您正苦于以下问题:Python PageFactory类的具体用法?Python PageFactory怎么用?Python PageFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PageFactory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_increment_active_review_count
def test_increment_active_review_count(self):
key = 'g.com-active-review-count'
self.sync_cache.redis.delete(key)
gcom = DomainFactory.create(url='http://g.com', name='g.com')
page = PageFactory.create(domain=gcom)
ReviewFactory.create(
is_active=True,
is_complete=True,
domain=gcom,
page=page,
number_of_violations=1
)
page = PageFactory.create(domain=gcom)
ReviewFactory.create(
is_active=False,
is_complete=True,
domain=gcom,
page=page,
number_of_violations=3
)
self.sync_cache.increment_active_review_count(gcom.name)
active_review_count = self.sync_cache.redis.get(key)
expect(active_review_count).to_equal('1')
self.sync_cache.increment_active_review_count(gcom.name)
active_review_count = self.sync_cache.redis.get(key)
expect(active_review_count).to_equal('2')
开发者ID:pombredanne,项目名称:holmes-api,代码行数:30,代码来源:test_cache.py
示例2: test_can_get_domain_reviews
def test_can_get_domain_reviews(self):
dt = datetime(2010, 11, 12, 13, 14, 15)
dt_timestamp = calendar.timegm(dt.utctimetuple())
dt2 = datetime(2011, 12, 13, 14, 15, 16)
dt2_timestamp = calendar.timegm(dt2.utctimetuple())
domain = DomainFactory.create(url="http://www.domain-details.com", name="domain-details.com")
page = PageFactory.create(domain=domain, last_review_date=dt)
page2 = PageFactory.create(domain=domain, last_review_date=dt2)
ReviewFactory.create(page=page, is_active=True, is_complete=True, completed_date=dt, number_of_violations=20)
ReviewFactory.create(page=page, is_active=False, is_complete=True, completed_date=dt2, number_of_violations=30)
ReviewFactory.create(page=page2, is_active=True, is_complete=True, completed_date=dt2, number_of_violations=30)
ReviewFactory.create(page=page2, is_active=False, is_complete=True, completed_date=dt, number_of_violations=20)
response = yield self.http_client.fetch(
self.get_url('/domains/%s/reviews/' % domain.name)
)
expect(response.code).to_equal(200)
domain_details = loads(response.body)
expect(domain_details['pages']).to_length(2)
expect(domain_details['pages'][1]['url']).to_equal(page2.url)
expect(domain_details['pages'][1]['uuid']).to_equal(str(page2.uuid))
expect(domain_details['pages'][1]['completedAt']).to_equal(dt2_timestamp)
expect(domain_details['pages'][0]['url']).to_equal(page.url)
expect(domain_details['pages'][0]['uuid']).to_equal(str(page.uuid))
expect(domain_details['pages'][0]['completedAt']).to_equal(dt_timestamp)
开发者ID:ricardodani,项目名称:holmes-api,代码行数:34,代码来源:test_domains.py
示例3: test_update_pages_score
def test_update_pages_score(self):
config = Config()
config.MAX_PAGE_SCORE = 15000000
self.db.query(Page).delete()
self.sync_cache.redis.delete('pages-score')
page1 = PageFactory.create(score=3)
page2 = PageFactory.create(score=0)
for i in range(3):
self.sync_cache.increment_page_score(page1.id)
self.sync_cache.increment_page_score(page2.id)
expect(page1.score).to_equal(3)
expect(page2.score).to_equal(0)
Page.update_pages_score(self.db, self.sync_cache, config)
self.db.flush()
self.db.refresh(page1)
self.db.refresh(page2)
expect(page1.score).to_equal(6)
expect(page2.score).to_equal(1)
开发者ID:marcelometal,项目名称:holmes-api,代码行数:26,代码来源:test_page.py
示例4: test_can_get_domain_details
def test_can_get_domain_details(self):
self.clean_cache('domain-details.com')
domain = DomainFactory.create(url="http://www.domain-details.com", name="domain-details.com")
page = PageFactory.create(domain=domain)
page2 = PageFactory.create(domain=domain)
ReviewFactory.create(page=page, is_active=True, is_complete=True, number_of_violations=20)
ReviewFactory.create(page=page2, is_active=True, is_complete=True, number_of_violations=30)
response = yield self.http_client.fetch(
self.get_url('/domains/%s/' % domain.name)
)
expect(response.code).to_equal(200)
domain_details = loads(response.body)
expect(domain_details['name']).to_equal('domain-details.com')
expect(domain_details['pageCount']).to_equal(2)
expect(domain_details['reviewCount']).to_equal(2)
expect(domain_details['violationCount']).to_equal(50)
expect(domain_details['reviewPercentage']).to_equal(100.00)
expect(domain_details['statusCodeInfo']).to_equal([])
expect(domain_details['errorPercentage']).to_equal(0)
expect(domain_details['averageResponseTime']).to_equal(0)
expect(domain_details['is_active']).to_be_true()
开发者ID:ricardodani,项目名称:holmes-api,代码行数:28,代码来源:test_domains.py
示例5: test_can_get_domain_details
def test_can_get_domain_details(self):
domain = DomainFactory.create(url="http://www.domain-details.com", name="domain-details.com")
page = PageFactory.create(domain=domain, url=domain.url)
page2 = PageFactory.create(domain=domain)
ReviewFactory.create(page=page, is_active=True, is_complete=True, number_of_violations=20)
ReviewFactory.create(page=page2, is_active=True, is_complete=True, number_of_violations=30)
response = yield self.authenticated_fetch('/domains/%s/' % domain.name)
expect(response.code).to_equal(200)
domain_details = loads(response.body)
expect(domain_details['name']).to_equal('domain-details.com')
expect(domain_details['pageCount']).to_equal(2)
expect(domain_details['reviewCount']).to_equal(2)
expect(domain_details['violationCount']).to_equal(50)
expect(domain_details['reviewPercentage']).to_equal(100.00)
expect(domain_details['errorPercentage']).to_equal(0)
expect(domain_details['averageResponseTime']).to_equal(0)
expect(domain_details['is_active']).to_be_true()
expect(domain_details['homepageId']).to_equal(str(page.uuid))
expect(domain_details['homepageReviewId']).to_equal(str(page.last_review_uuid))
开发者ID:diegosaouda,项目名称:holmes-api,代码行数:25,代码来源:test_domains.py
示例6: test_get_count
def test_get_count(self):
key = 'g.com-my-key'
self.sync_cache.redis.delete(key)
gcom = DomainFactory.create(url="http://g.com", name="g.com")
PageFactory.create(domain=gcom)
count = self.sync_cache.get_count(
key,
gcom.name,
int(self.config.PAGE_COUNT_EXPIRATION_IN_SECONDS),
lambda domain: domain.get_page_count(self.db)
)
expect(count).to_equal(1)
# should get from cache
self.sync_cache.db = None
count = self.sync_cache.get_count(
key,
gcom.name,
int(self.config.PAGE_COUNT_EXPIRATION_IN_SECONDS),
lambda domain: domain.get_page_count(self.db)
)
expect(count).to_equal(1)
开发者ID:pombredanne,项目名称:holmes-api,代码行数:25,代码来源:test_cache.py
示例7: test_can_decrement_next_jobs_count
def test_can_decrement_next_jobs_count(self):
self.db.query(Page).delete()
self.db.query(Domain).delete()
key = 'next-jobs'
self.sync_cache.redis.delete(key)
globocom = DomainFactory.create(
url="http://globo.com",
name="globo.com",
is_active=True
)
for i in range(2):
PageFactory.create(domain=globocom)
self.sync_cache.increment_next_jobs_count(-2)
page_count = self.sync_cache.redis.get(key)
expect(page_count).to_equal('0')
# should get from cache
self.sync_cache.db = None
self.sync_cache.increment_next_jobs_count(10)
page_count = self.sync_cache.redis.get(key)
expect(page_count).to_equal('10')
开发者ID:pombredanne,项目名称:holmes-api,代码行数:25,代码来源:test_cache.py
示例8: test_can_get_domain_grouped_violations
def test_can_get_domain_grouped_violations(self):
domain1 = DomainFactory.create()
domain2 = DomainFactory.create()
page1 = PageFactory.create(domain=domain1)
page2 = PageFactory.create(domain=domain1)
page3 = PageFactory.create(domain=domain2)
ReviewFactory.create(domain=domain1, page=page1, is_active=True, number_of_violations=5)
ReviewFactory.create(domain=domain1, page=page2, is_active=True, number_of_violations=7)
ReviewFactory.create(domain=domain2, page=page3, is_active=True, number_of_violations=9)
self.server.application.violation_definitions = {
'key.%s' % i: {
'title': 'title.%s' % i,
'category': 'category.%s' % (i % 3),
'key': Key.get_or_create(self.db, 'key.%d' % i, 'category.%d' % (i % 3))
} for i in xrange(9)
}
response = yield self.http_client.fetch(
self.get_url('/domains/%s/violations' % domain1.name)
)
expect(response.code).to_equal(200)
domain_violations = loads(response.body)
expect(domain_violations).to_length(5)
expect(domain_violations.keys()).to_be_like(['domainName', 'violations', 'total', 'domainURL', 'domainId'])
expect(domain_violations['total']).to_equal(12)
expect(domain_violations['violations']).to_length(3)
counts = map(lambda v: v['count'], domain_violations['violations'])
expect(counts).to_be_like([5, 4, 3])
开发者ID:ricardodani,项目名称:holmes-api,代码行数:35,代码来源:test_domains.py
示例9: test_can_get_page_by_url_hash
def test_can_get_page_by_url_hash(self):
page = PageFactory.create()
PageFactory.create()
loaded_page = Page.by_url_hash(page.url_hash, self.db)
expect(loaded_page.id).to_equal(page.id)
invalid_page = Page.by_uuid('123', self.db)
expect(invalid_page).to_be_null()
开发者ID:ricardodani,项目名称:holmes-api,代码行数:9,代码来源:test_page.py
示例10: test_can_get_page_by_uuid
def test_can_get_page_by_uuid(self):
page = PageFactory.create()
PageFactory.create()
loaded_page = Page.by_uuid(page.uuid, self.db)
expect(loaded_page.id).to_equal(page.id)
invalid_page = Page.by_uuid(uuid4(), self.db)
expect(invalid_page).to_be_null()
开发者ID:ricardodani,项目名称:holmes-api,代码行数:9,代码来源:test_page.py
示例11: test_get_next_job_does_not_get_from_inactive_domains
def test_get_next_job_does_not_get_from_inactive_domains(self):
domain = DomainFactory.create(is_active=False)
PageFactory.create(domain=domain)
next_job = Page.get_next_job(
self.db,
expiration=100,
cache=self.sync_cache,
lock_expiration=1
)
expect(next_job).to_be_null()
开发者ID:pombredanne,项目名称:holmes-api,代码行数:12,代码来源:test_page.py
示例12: test_get_next_job_list
def test_get_next_job_list(self):
page = PageFactory.create()
PageFactory.create()
next_job_list = Page.get_next_job_list(self.db, expiration=100)
expect(next_job_list).to_length(2)
pages = [{'url': x.url, 'uuid': str(x.uuid)} for x in next_job_list]
expect(pages).to_include({
'url': page.url,
'uuid': str(page.uuid)
})
开发者ID:ricardodani,项目名称:holmes-api,代码行数:13,代码来源:test_page.py
示例13: test_can_increment_page_count
def test_can_increment_page_count(self):
self.db.query(Domain).delete()
globocom = DomainFactory.create(url="http://globo.com", name="globo.com")
for i in range(2):
PageFactory.create(domain=globocom)
page_count = yield self.cache.get_page_count('globo.com')
expect(page_count).to_equal(2)
page_count = yield self.cache.increment_page_count('globo.com', 10)
expect(page_count).to_equal(12)
开发者ID:pombredanne,项目名称:holmes-api,代码行数:13,代码来源:test_cache.py
示例14: test_increment_page_count
def test_increment_page_count(self):
key = 'g.com-page-count'
self.sync_cache.redis.delete(key)
gcom = DomainFactory.create(url="http://g.com", name="g.com")
PageFactory.create(domain=gcom)
self.sync_cache.increment_page_count(gcom.name)
page_count = self.sync_cache.redis.get(key)
expect(page_count).to_equal('1')
self.sync_cache.increment_page_count(gcom.name)
page_count = self.sync_cache.redis.get(key)
expect(page_count).to_equal('2')
开发者ID:pombredanne,项目名称:holmes-api,代码行数:14,代码来源:test_cache.py
示例15: test_can_get_next_jobs_count
def test_can_get_next_jobs_count(self):
config = Config()
config.REVIEW_EXPIRATION_IN_SECONDS = 100
for x in range(3):
PageFactory.create()
next_job_list = Page.get_next_jobs_count(self.db, config)
expect(next_job_list).to_equal(3)
for x in range(2):
PageFactory.create()
next_job_list = Page.get_next_jobs_count(self.db, config)
expect(next_job_list).to_equal(5)
开发者ID:ricardodani,项目名称:holmes-api,代码行数:15,代码来源:test_page.py
示例16: test_handle_sitemap_url_loaded
def test_handle_sitemap_url_loaded(self):
page = PageFactory.create(url="http://g1.globo.com/")
reviewer = Reviewer(
api_url='http://localhost:2368',
page_uuid=page.uuid,
page_url=page.url,
page_score=0.0,
config=Config(),
validators=[]
)
reviewer.enqueue = Mock()
content = self.get_file('url_sitemap.xml')
response = Mock(status_code=200, text=content)
facter = SitemapFacter(reviewer)
facter.async_get = Mock()
facter.get_facts()
facter.handle_sitemap_loaded("http://g1.globo.com/sitemap.xml", response)
expect(facter.review.data['sitemap.files.size']["http://g1.globo.com/sitemap.xml"]).to_equal(0.296875)
expect(facter.review.data['sitemap.urls']["http://g1.globo.com/sitemap.xml"]).to_equal(set(['http://domain.com/1.html', 'http://domain.com/2.html']))
expect(facter.review.facts['total.size.sitemap']['value']).to_equal(0.296875)
expect(facter.review.facts['total.size.sitemap.gzipped']['value']).to_equal(0.1494140625)
expect(facter.review.data['total.size.sitemap']).to_equal(0.296875)
expect(facter.review.data['total.size.sitemap.gzipped']).to_equal(0.1494140625)
expect(facter.review.data['sitemap.files.urls']["http://g1.globo.com/sitemap.xml"]).to_equal(2)
expect(facter.review.facts['total.sitemap.urls']['value']).to_equal(2)
开发者ID:pombredanne,项目名称:holmes-api,代码行数:31,代码来源:test_sitemap.py
示例17: test_can_get_violations_per_day
def test_can_get_violations_per_day(self):
dt = datetime(2013, 10, 10, 10, 10, 10)
dt2 = datetime(2013, 10, 11, 10, 10, 10)
dt3 = datetime(2013, 10, 12, 10, 10, 10)
page = PageFactory.create()
ReviewFactory.create(page=page, is_active=False, is_complete=True, completed_date=dt, number_of_violations=20)
ReviewFactory.create(page=page, is_active=False, is_complete=True, completed_date=dt2, number_of_violations=10)
ReviewFactory.create(page=page, is_active=True, is_complete=True, completed_date=dt3, number_of_violations=30)
response = yield self.authenticated_fetch('/domains/%s/violations-per-day/' % page.domain.name)
expect(response.code).to_equal(200)
domain_details = loads(response.body)
expect(domain_details['violations']).to_be_like([
{
u'completedAt': u'2013-10-10',
u'violation_points': 190,
u'violation_count': 20
},
{
u'completedAt': u'2013-10-11',
u'violation_points': 45,
u'violation_count': 10
},
{
u'completedAt': u'2013-10-12',
u'violation_points': 435,
u'violation_count': 30
}
])
开发者ID:diegosaouda,项目名称:holmes-api,代码行数:34,代码来源:test_domains.py
示例18: test_can_get_fact_definitions
def test_can_get_fact_definitions(self):
page = PageFactory.create()
reviewer = Reviewer(
api_url='http://localhost:2368',
page_uuid=page.uuid,
page_url=page.url,
page_score=0.0,
config=Config(),
facters=[]
)
content = self.get_file('globo.html')
result = {
'url': page.url,
'status': 200,
'content': content,
'html': lxml.html.fromstring(content)
}
reviewer.responses[page.url] = result
reviewer._wait_for_async_requests = Mock()
reviewer.save_review = Mock()
response = Mock(status_code=200, text=content, headers={})
reviewer.content_loaded(page.url, response)
facter = TitleFacter(reviewer)
definitions = facter.get_fact_definitions()
expect(definitions).to_length(1)
expect('page.title' in definitions).to_be_true()
开发者ID:pombredanne,项目名称:holmes-api,代码行数:32,代码来源:test_title.py
示例19: test_can_get_default_violations_values
def test_can_get_default_violations_values(self):
config = Config()
config.REQUIRED_META_TAGS = ['description']
page = PageFactory.create()
reviewer = Reviewer(
api_url='http://localhost:2368',
page_uuid=page.uuid,
page_url=page.url,
page_score=0.0,
config=config,
validators=[]
)
validator = RequiredMetaTagsValidator(reviewer)
violations_values = validator.get_default_violations_values(config)
expect(violations_values).to_include('absent.meta.tags')
expect(violations_values['absent.meta.tags']).to_length(2)
expect(violations_values['absent.meta.tags']).to_be_like({
'value': config.REQUIRED_META_TAGS,
'description': config.get_description('REQUIRED_META_TAGS')
})
开发者ID:diegosaouda,项目名称:holmes-api,代码行数:27,代码来源:test_required_meta_tags.py
示例20: test_no_title_tag
def test_no_title_tag(self):
page = PageFactory.create()
reviewer = Reviewer(
api_url='http://localhost:2368',
page_uuid=page.uuid,
page_url=page.url,
page_score=0.0,
config=Config(),
facters=[]
)
content = '<html></html>'
result = {
'url': page.url,
'status': 200,
'content': content,
'html': lxml.html.fromstring(content)
}
reviewer.responses[page.url] = result
reviewer._wait_for_async_requests = Mock()
reviewer.save_review = Mock()
reviewer.content_loaded(page.url, Mock(status_code=200, text=content, headers={}))
facter = TitleFacter(reviewer)
facter.add_fact = Mock()
facter.get_facts()
expect(facter.add_fact.called).to_be_false()
expect(facter.review.data).to_be_like({})
开发者ID:pombredanne,项目名称:holmes-api,代码行数:32,代码来源:test_title.py
注:本文中的tests.fixtures.PageFactory类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论