本文整理匯總了Python中holmes.models.Domain.get_domains_details方法的典型用法代碼示例。如果您正苦於以下問題:Python Domain.get_domains_details方法的具體用法?Python Domain.get_domains_details怎麽用?Python Domain.get_domains_details使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類holmes.models.Domain
的用法示例。
在下文中一共展示了Domain.get_domains_details方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_can_get_domains_details
# 需要導入模塊: from holmes.models import Domain [as 別名]
# 或者: from holmes.models.Domain import get_domains_details [as 別名]
def test_can_get_domains_details(self):
self.db.query(Domain).delete()
details = Domain.get_domains_details(self.db)
expect(details).to_length(0)
domain = DomainFactory.create(name='domain-1.com', url='http://domain-1.com/')
domain2 = DomainFactory.create(name='domain-2.com', url='http://domain-2.com/')
DomainFactory.create()
page = PageFactory.create(domain=domain)
page2 = PageFactory.create(domain=domain)
page3 = PageFactory.create(domain=domain2)
ReviewFactory.create(domain=domain, page=page, is_active=True, number_of_violations=20)
ReviewFactory.create(domain=domain, page=page2, is_active=True, number_of_violations=10)
ReviewFactory.create(domain=domain2, page=page3, is_active=True, number_of_violations=30)
RequestFactory.create(status_code=200, domain_name=domain.name, response_time=0.25)
RequestFactory.create(status_code=304, domain_name=domain.name, response_time=0.35)
RequestFactory.create(status_code=400, domain_name=domain.name, response_time=0.25)
RequestFactory.create(status_code=403, domain_name=domain.name, response_time=0.35)
RequestFactory.create(status_code=404, domain_name=domain.name, response_time=0.25)
details = Domain.get_domains_details(self.db)
expect(details).to_length(3)
expect(details[0]).to_length(10)
expect(details[0]['url']).to_equal('http://domain-1.com/')
expect(details[0]['name']).to_equal('domain-1.com')
expect(details[0]['violationCount']).to_equal(30)
expect(details[0]['pageCount']).to_equal(2)
expect(details[0]['reviewCount']).to_equal(2)
expect(details[0]['reviewPercentage']).to_equal(100.0)
expect(details[0]['errorPercentage']).to_equal(60.0)
expect(details[0]['is_active']).to_be_true()
expect(details[0]['averageResponseTime']).to_equal(0.3)