本文整理汇总了Python中tests.fixtures.ReviewFactory.create方法的典型用法代码示例。如果您正苦于以下问题:Python ReviewFactory.create方法的具体用法?Python ReviewFactory.create怎么用?Python ReviewFactory.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tests.fixtures.ReviewFactory
的用法示例。
在下文中一共展示了ReviewFactory.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_increment_active_review_count
# 需要导入模块: from tests.fixtures import ReviewFactory [as 别名]
# 或者: from tests.fixtures.ReviewFactory import create [as 别名]
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')
示例2: test_can_get_domain_details
# 需要导入模块: from tests.fixtures import ReviewFactory [as 别名]
# 或者: from tests.fixtures.ReviewFactory import create [as 别名]
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))
示例3: test_can_get_domain_details
# 需要导入模块: from tests.fixtures import ReviewFactory [as 别名]
# 或者: from tests.fixtures.ReviewFactory import create [as 别名]
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()
示例4: test_can_get_page_reviews
# 需要导入模块: from tests.fixtures import ReviewFactory [as 别名]
# 或者: from tests.fixtures.ReviewFactory import create [as 别名]
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)
示例5: test_can_get_last_reviews_count_in_last_hour
# 需要导入模块: from tests.fixtures import ReviewFactory [as 别名]
# 或者: from tests.fixtures.ReviewFactory import create [as 别名]
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)
示例6: test_can_get_last_reviews_count_in_last_hour
# 需要导入模块: from tests.fixtures import ReviewFactory [as 别名]
# 或者: from tests.fixtures.ReviewFactory import create [as 别名]
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)
示例7: test_can_get_domain_reviews
# 需要导入模块: from tests.fixtures import ReviewFactory [as 别名]
# 或者: from tests.fixtures.ReviewFactory import create [as 别名]
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)
示例8: test_worker_is_working
# 需要导入模块: from tests.fixtures import ReviewFactory [as 别名]
# 或者: from tests.fixtures.ReviewFactory import create [as 别名]
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()
示例9: test_can_search
# 需要导入模块: from tests.fixtures import ReviewFactory [as 别名]
# 或者: from tests.fixtures.ReviewFactory import create [as 别名]
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)
})
示例10: test_can_get_violation_count_for_domain
# 需要导入模块: from tests.fixtures import ReviewFactory [as 别名]
# 或者: from tests.fixtures.ReviewFactory import create [as 别名]
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)
示例11: test_can_get_review_by_uuid
# 需要导入模块: from tests.fixtures import ReviewFactory [as 别名]
# 或者: from tests.fixtures.ReviewFactory import create [as 别名]
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()
示例12: test_worker_to_dict
# 需要导入模块: from tests.fixtures import ReviewFactory [as 别名]
# 或者: from tests.fixtures.ReviewFactory import create [as 别名]
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()
示例13: test_can_get_domain_reviews_using_elastic_search_provider
# 需要导入模块: from tests.fixtures import ReviewFactory [as 别名]
# 或者: from tests.fixtures.ReviewFactory import create [as 别名]
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)
示例14: test_invalid_review_uuid_returns_redirect
# 需要导入模块: from tests.fixtures import ReviewFactory [as 别名]
# 或者: from tests.fixtures.ReviewFactory import create [as 别名]
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'))
示例15: test_increment_violations_count
# 需要导入模块: from tests.fixtures import ReviewFactory [as 别名]
# 或者: from tests.fixtures.ReviewFactory import create [as 别名]
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)