本文整理汇总了Python中tests.fixtures.ReviewFactory类的典型用法代码示例。如果您正苦于以下问题:Python ReviewFactory类的具体用法?Python ReviewFactory怎么用?Python ReviewFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ReviewFactory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: 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
示例2: 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
示例3: 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
示例4: test_can_get_page_reviews
def test_can_get_page_reviews(self):
dt1 = datetime(2010, 11, 12, 13, 14, 15)
dt1_timestamp = calendar.timegm(dt1.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)
review1 = ReviewFactory.create(page=page, is_active=False, is_complete=True, completed_date=dt1, number_of_violations=20)
review2 = ReviewFactory.create(page=page, is_active=False, is_complete=True, completed_date=dt2, number_of_violations=30)
response = yield self.http_client.fetch(
self.get_url('/page/%s/reviews/' % page.uuid)
)
expect(response.code).to_equal(200)
page_details = loads(response.body)
expect(page_details[0]['violationCount']).to_equal(30)
expect(page_details[0]['uuid']).to_equal(str(review2.uuid))
expect(page_details[0]['completedAt']).to_equal(dt2_timestamp)
expect(page_details[1]['violationCount']).to_equal(20)
expect(page_details[1]['uuid']).to_equal(str(review1.uuid))
expect(page_details[1]['completedAt']).to_equal(dt1_timestamp)
开发者ID:pombredanne,项目名称:holmes-api,代码行数:28,代码来源:test_page.py
示例5: test_can_get_last_reviews_count_in_last_hour
def test_can_get_last_reviews_count_in_last_hour(self):
dt = datetime.utcnow()
ReviewFactory.create(
is_active=True,
completed_date=dt - timedelta(minutes=1)
)
first_date = dt - timedelta(minutes=59)
ReviewFactory.create(
is_active=True,
completed_date=first_date
)
ReviewFactory.create(
is_active=True,
completed_date=dt - timedelta(minutes=5)
)
ReviewFactory.create(
is_active=True,
completed_date=dt - timedelta(minutes=61)
)
self.db.flush()
url = self.get_url('/reviews-in-last-hour')
response = yield self.http_client.fetch(url, method='GET')
expect(response.code).to_equal(200)
result = loads(response.body)
expect(result['count']).to_equal(3)
expect(round(result['ellapsed'], 0)).to_be_like(59.0 * 60)
开发者ID:ricardodani,项目名称:holmes-api,代码行数:34,代码来源:test_review.py
示例6: test_can_get_last_reviews_count_in_last_hour
def test_can_get_last_reviews_count_in_last_hour(self, datetime_mock):
dt = datetime(2014, 2, 14, 15, 0, 30)
datetime_mock.utcnow.return_value = dt
ReviewFactory.create(
is_active=True,
completed_date=dt - timedelta(minutes=1)
)
first_date = dt - timedelta(minutes=59)
ReviewFactory.create(
is_active=True,
completed_date=first_date
)
ReviewFactory.create(
is_active=True,
completed_date=dt - timedelta(minutes=5)
)
ReviewFactory.create(
is_active=True,
completed_date=dt - timedelta(minutes=61)
)
self.db.flush()
self.authenticated_fetch('/reviews-in-last-hour', callback=self.stop)
response = self.wait()
expect(response.code).to_equal(200)
result = loads(response.body)
expect(result['count']).to_equal(3)
expect(round(result['ellapsed'], 0)).to_be_like(59 * 60)
开发者ID:diegosaouda,项目名称:holmes-api,代码行数:35,代码来源:test_review.py
示例7: 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
示例8: test_can_search
def test_can_search(self):
dt = datetime.now()
page = PageFactory.create(url="http://www.mypage.something.com")
review1 = ReviewFactory.create(
page=page, is_active=True, is_complete=True,
completed_date=dt, number_of_violations=20
)
self.db.flush()
page.last_review = review1
page.last_review_date = dt
self.db.flush()
response = yield self.http_client.fetch(
self.get_url('/search?term=http://www.mypage.something.com'),
method='GET',
)
expect(response.code).to_equal(200)
obj = loads(response.body)
expect(obj).to_be_like({
u'url': u'http://www.mypage.something.com',
u'reviewId': str(review1.uuid),
u'uuid': str(page.uuid)
})
开发者ID:pombredanne,项目名称:holmes-api,代码行数:29,代码来源:test_search.py
示例9: test_worker_is_working
def test_worker_is_working(self):
review = ReviewFactory.create()
worker = WorkerFactory.create()
worker2 = WorkerFactory.create(current_url=review.domain.url)
expect(worker.working).to_be_false()
expect(worker2.working).to_be_true()
开发者ID:pombredanne,项目名称:holmes-api,代码行数:7,代码来源:test_worker.py
示例10: test_can_get_violation_count_for_domain
def test_can_get_violation_count_for_domain(self):
self.db.query(Domain).delete()
globocom = DomainFactory.create(url="http://globo.com", name="globo.com")
page = PageFactory.create(domain=globocom)
ReviewFactory.create(is_active=True, is_complete=True, domain=globocom, page=page, number_of_violations=10)
violation_count = yield self.cache.get_violation_count('globo.com')
expect(violation_count).to_equal(10)
# should get from cache
self.cache.db = None
violation_count = yield self.cache.get_violation_count('globo.com')
expect(violation_count).to_equal(10)
开发者ID:pombredanne,项目名称:holmes-api,代码行数:16,代码来源:test_cache.py
示例11: test_to_dict
def test_to_dict(self):
page_id = uuid4()
review_id = uuid4()
page = PageFactory.build(uuid=page_id)
review = ReviewFactory.build(page=page, uuid=review_id)
key1 = KeyFactory.create(name='some.random.key1')
review.add_violation(key1, 'b', 100, review.domain)
key2 = KeyFactory.create(name='some.random.key2')
review.add_fact(key2, 'b')
fact_definitions = {'some.random.key2': {}}
violation_definitions = {'some.random.key1': {}}
expect(review.to_dict(fact_definitions, violation_definitions)).to_be_like({
'domain': review.domain.name,
'uuid': str(review_id),
'completedAt': None,
'facts': [
{'value': 'b', 'key': 'some.random.key2', 'unit': 'value', 'title': 'unknown', 'category': 'unknown'}
],
'violations': [
{'points': 100, 'key': 'some.random.key1', 'description': 'b', 'title': 'undefined', 'category': 'undefined'}
],
'page': {
'url': page.url,
'lastModified': None,
'expires': None,
'uuid': str(page_id),
'score': 0.0
},
'createdAt': review.created_date,
'isComplete': False
})
开发者ID:pombredanne,项目名称:holmes-api,代码行数:33,代码来源:test_review.py
示例12: test_can_get_review_by_uuid
def test_can_get_review_by_uuid(self):
review = ReviewFactory.create()
loaded = Review.by_uuid(review.uuid, self.db)
expect(loaded.id).to_equal(review.id)
invalid = Review.by_uuid(uuid4(), self.db)
expect(invalid).to_be_null()
开发者ID:pombredanne,项目名称:holmes-api,代码行数:8,代码来源:test_review.py
示例13: test_worker_to_dict
def test_worker_to_dict(self):
review = ReviewFactory.create()
worker = WorkerFactory.create(current_url=review.domain.url)
worker_dict = worker.to_dict()
expect(worker_dict['uuid']).to_equal(str(worker.uuid))
expect(worker_dict['last_ping']).to_equal(str(worker.last_ping))
expect(worker_dict['working']).to_be_true()
开发者ID:pombredanne,项目名称:holmes-api,代码行数:9,代码来源:test_worker.py
示例14: test_can_append_facts
def test_can_append_facts(self):
review = ReviewFactory.build()
expect(review.facts).to_length(0)
key = KeyFactory.create(name='a')
review.add_fact(key, 'b')
expect(review.facts).to_length(1)
expect(review.facts[0].key.name).to_equal('a')
expect(review.facts[0].value).to_equal('b')
开发者ID:pombredanne,项目名称:holmes-api,代码行数:10,代码来源:test_review.py
示例15: test_can_get_domain_reviews_using_elastic_search_provider
def test_can_get_domain_reviews_using_elastic_search_provider(self):
self.use_elastic_search_provider()
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)
review = ReviewFactory.create(page=page, is_active=False, is_complete=True, completed_date=dt, number_of_violations=13)
self.server.application.search_provider.index_review(review)
review = ReviewFactory.create(page=page, is_active=True, is_complete=True, completed_date=dt, number_of_violations=12)
self.server.application.search_provider.index_review(review)
review = ReviewFactory.create(page=page2, is_active=False, is_complete=True, completed_date=dt2, number_of_violations=11)
self.server.application.search_provider.index_review(review)
review = ReviewFactory.create(page=page2, is_active=True, is_complete=True, completed_date=dt2, number_of_violations=10)
self.server.application.search_provider.index_review(review)
self.server.application.search_provider.refresh()
response = yield self.authenticated_fetch('/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'][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)
expect(domain_details['pages'][0]['violationCount']).to_equal(12)
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'][1]['violationCount']).to_equal(10)
开发者ID:diegosaouda,项目名称:holmes-api,代码行数:42,代码来源:test_domains.py
示例16: test_increment_violations_count
def test_increment_violations_count(self):
key = 'g.com-violation-count'
self.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=10
)
violation_count = yield self.cache.get_violation_count(gcom.name)
expect(violation_count).to_equal(10)
yield self.cache.increment_violations_count(gcom.name)
violation_count = yield self.cache.get_violation_count(gcom.name)
expect(violation_count).to_equal(11)
开发者ID:pombredanne,项目名称:holmes-api,代码行数:20,代码来源:test_cache.py
示例17: test_invalid_review_uuid_returns_redirect
def test_invalid_review_uuid_returns_redirect(self):
page = PageFactory.create()
review = ReviewFactory.create(page=page)
response = yield self.authenticated_fetch(
'/page/%s/review/%s' % (page.uuid, self.ZERO_UUID)
)
expect(response.code).to_equal(200)
expect(str(review.uuid)).to_equal(loads(response.body).get('uuid'))
开发者ID:diegosaouda,项目名称:holmes-api,代码行数:11,代码来源:test_review.py
示例18: test_can_append_violations
def test_can_append_violations(self):
review = ReviewFactory.build()
expect(review.violations).to_length(0)
key = KeyFactory.create(name='a')
review.add_violation(key, 'b', 100, review.domain)
expect(review.violations).to_length(1)
expect(review.violations[0].key.name).to_equal('a')
expect(review.violations[0].value).to_equal('b')
expect(review.violations[0].points).to_equal(100)
开发者ID:pombredanne,项目名称:holmes-api,代码行数:11,代码来源:test_review.py
示例19: test_can_get_reviews_for_domain
def test_can_get_reviews_for_domain(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)
domain = DomainFactory.create()
page = PageFactory.create(domain=domain, last_review_date=dt3)
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)
review = ReviewFactory.create(
page=page, is_active=True, is_complete=True,
completed_date=dt3, number_of_violations=30)
reviews = domain.get_active_reviews(self.db)
expect(reviews).to_length(1)
expect(reviews[0].last_review_uuid).to_equal(str(review.uuid))
开发者ID:pombredanne,项目名称:holmes-api,代码行数:20,代码来源:test_domain.py
示例20: test_can_create_facts_float
def test_can_create_facts_float(self):
review = ReviewFactory.create()
key = KeyFactory.create(name="some.random.fact")
review.add_fact(key, value=1203.01)
loaded_review = self.db.query(Review).get(review.id)
expect(loaded_review.facts).to_length(1)
expect(loaded_review.facts[0].key.name).to_equal("some.random.fact")
expect(loaded_review.facts[0].value).to_equal(1203.01)
开发者ID:pombredanne,项目名称:holmes-api,代码行数:11,代码来源:test_review.py
注:本文中的tests.fixtures.ReviewFactory类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论