• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python fixtures.DomainFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tests.fixtures.DomainFactory的典型用法代码示例。如果您正苦于以下问题:Python DomainFactory类的具体用法?Python DomainFactory怎么用?Python DomainFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了DomainFactory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: 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


示例2: test_can_get_homepage

    def test_can_get_homepage(self):
        domain = DomainFactory(is_active=True)
        page = PageFactory(url=domain.url, domain=domain, last_review_uuid='123')

        homepage = domain.get_homepage(self.db)

        expect(homepage.uuid).to_equal(page.uuid)
        expect(homepage.last_review_uuid).to_equal('123')
开发者ID:diegosaouda,项目名称:holmes-api,代码行数:8,代码来源:test_domain.py


示例3: test_key_category_not_found

    def test_key_category_not_found(self):
        DomainFactory.create(name='domain-0.com')

        try:
            yield self.authenticated_fetch('/domains/domain-0.com/violations/0')
        except HTTPError:
            err = sys.exc_info()[1]
            expect(err).not_to_be_null()
            expect(err.code).to_equal(404)
            expect(err.response.reason).to_be_like('Key category 0 not found')
        else:
            assert False, 'Should not have got this far'
开发者ID:diegosaouda,项目名称:holmes-api,代码行数:12,代码来源:test_domains.py


示例4: test_get_domain_names

    def test_get_domain_names(self):
        self.db.query(Domain).delete()

        DomainFactory.create(name="g1.globo.com")
        DomainFactory.create(name="globoesporte.globo.com")

        domain_names = Domain.get_domain_names(self.db)

        expect(domain_names).to_be_like([
            'g1.globo.com',
            'globoesporte.globo.com'
        ])
开发者ID:pombredanne,项目名称:holmes-api,代码行数:12,代码来源:test_domain.py


示例5: test_can_insert_default_violations_values_for_all_domains

    def test_can_insert_default_violations_values_for_all_domains(self):
        DomainsViolationsPrefsFactory.create(
            domain=Domain(name='globo.com'),
            key=Key(name='some.random.fact'),
            value='whatever'
        )

        for x in range(3):
            DomainFactory.create(name='g%d.com' % x)

        domains_violations_prefs = \
            DomainsViolationsPrefs.get_domains_violations_prefs(self.db)

        expect(domains_violations_prefs).to_length(1)

        default_violations_values = {
            'page.title.size': 100,
            'total.requests.img': 5,
        }

        page_title_size = KeyFactory.create(name='page.title.size')
        total_requests_img = KeyFactory.create(name='total.requests.img')

        violation_definitions = {
            'page.title.size': {'key': page_title_size, 'default_value': 100},
            'total.requests.img': {'key': total_requests_img, 'default_value': 5}
        }

        DomainsViolationsPrefs.insert_default_violations_values_for_all_domains(
            self.db,
            default_violations_values,
            violation_definitions,
            self.cache
        )

        domains_violations_prefs = \
            DomainsViolationsPrefs.get_domains_violations_prefs(self.db)

        expect(domains_violations_prefs).to_length(4)

        expect(domains_violations_prefs).to_be_like({
            'globo.com': {
                'some.random.fact': 'whatever',
                'total.requests.img': 5,
                'page.title.size': 100
            },
            'g0.com': {'page.title.size': 100, 'total.requests.img': 5},
            'g1.com': {'page.title.size': 100, 'total.requests.img': 5},
            'g2.com': {'page.title.size': 100, 'total.requests.img': 5},
        })
开发者ID:diegosaouda,项目名称:holmes-api,代码行数:50,代码来源:test_domains_violations_prefs.py


示例6: test_domain_not_found_in_materials

    def test_domain_not_found_in_materials(self):
        DomainFactory.create(name='domain-0.com')

        self.server.application.girl.get = Mock(return_value=[])

        try:
            yield self.authenticated_fetch('/domains/domain-0.com')
        except HTTPError:
            err = sys.exc_info()[1]
            expect(err).not_to_be_null()
            expect(err.code).to_equal(404)
            expect(err.response.reason).to_be_like('Domain domain-0.com not found')

        else:
            assert False, 'Should not have got this far'
开发者ID:diegosaouda,项目名称:holmes-api,代码行数:15,代码来源:test_domains.py


示例7: test_can_insert_default_violations_values_for_domain

    def test_can_insert_default_violations_values_for_domain(self):
        domain = DomainFactory.create()

        page_title_size = KeyFactory.create(name='page.title.size')
        total_requests_img = KeyFactory.create(name='total.requests.img')

        violation_definitions = {
            'page.title.size': {'key': page_title_size, 'default_value': 100},
            'total.requests.img': {'key': total_requests_img, 'default_value': 5}
        }

        keys = violation_definitions.keys()

        data = DomainsViolationsPrefs.get_domains_violations_prefs_by_domain(self.db, domain.name)
        expect(data).to_length(0)

        DomainsViolationsPrefs.insert_default_violations_values_for_domain(
            self.db,
            domain,
            keys,
            violation_definitions,
            self.cache
        )

        data = DomainsViolationsPrefs.get_domains_violations_prefs_by_domain(self.db, domain.name)

        expect(data).not_to_be_null()
        expect(data).to_length(2)
        expect(data).to_be_like([
            {'value': 100, 'key': 'page.title.size'},
            {'value': 5, 'key': 'total.requests.img'}
        ])
开发者ID:diegosaouda,项目名称:holmes-api,代码行数:32,代码来源:test_domains_violations_prefs.py


示例8: 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


示例9: 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


示例10: 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


示例11: 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


示例12: test_can_get_domain_violations_prefs

    def test_can_get_domain_violations_prefs(self):
        domain = DomainFactory.create(name='globo.com')

        self.sync_cache.redis.delete( 'violations-prefs-%s' % domain.name)

        for i in range(3):
            DomainsViolationsPrefsFactory.create(
                domain=domain,
                key=KeyFactory.create(name='some.random.%d' % i),
                value='v%d' % i
            )

        prefs = self.sync_cache.get_domain_violations_prefs('globo.com')
        expect(prefs).to_equal([
            {'value': u'v0', 'key': u'some.random.0'},
            {'value': u'v1', 'key': u'some.random.1'},
            {'value': u'v2', 'key': u'some.random.2'}
        ])

        # should get from cache
        self.sync_cache.db = None

        prefs = self.sync_cache.get_domain_violations_prefs('globo.com')
        expect(prefs).to_equal([
            {'value': u'v0', 'key': u'some.random.0'},
            {'value': u'v1', 'key': u'some.random.1'},
            {'value': u'v2', 'key': u'some.random.2'}
        ])
开发者ID:marcelometal,项目名称:holmes-api,代码行数:28,代码来源:test_cache.py


示例13: test_can_update_by_domain

    def test_can_update_by_domain(self):
        domain = DomainFactory.create(name='globo.com')

        DomainsViolationsPrefsFactory.create(
            domain=domain,
            key=Key(name='some.random'),
            value='whatever'
        )

        loaded = DomainsViolationsPrefs.get_domains_violations_prefs_by_domain(self.db, domain.name)

        expect(loaded).not_to_be_null()
        expect(loaded).to_length(1)
        expect(loaded).to_be_like([{'key': 'some.random', 'value': 'whatever'}])

        data = [
            {'key': 'some.random', 'value': '10'},
            {'invalid_key': 'some.random.1', 'invalid_value': '101'}
        ]

        DomainsViolationsPrefs.update_by_domain(self.db, self.cache, domain, data)

        loaded = DomainsViolationsPrefs.get_domains_violations_prefs_by_domain(self.db, domain.name)

        expect(loaded).not_to_be_null()
        expect(loaded).to_length(1)
        expect(loaded).to_be_like([{'key': 'some.random', 'value': '10'}])
开发者ID:diegosaouda,项目名称:holmes-api,代码行数:27,代码来源:test_domains_violations_prefs.py


示例14: test_can_save_prefs_as_superuser

    def test_can_save_prefs_as_superuser(self):
        self.db.query(User).delete()
        user = UserFactory(email='[email protected]', is_superuser=True)
        domain = DomainFactory.create(name='globo.com')
        key = KeyFactory.create(name='some.random')
        DomainsViolationsPrefsFactory.create(domain=domain, key=key, value=100)

        loaded_prefs = DomainsViolationsPrefs.get_domains_violations_prefs_by_domain(self.db, domain.name)
        expect(loaded_prefs).to_length(1)
        expect(loaded_prefs[0]).to_be_like({
            'value': 100,
            'key': 'some.random'
        })

        yield self.authenticated_fetch(
            '/domains/%s/violations-prefs/' % domain.name,
            user_email=user.email,
            method='POST',
            body=dumps([
                {'key': 'some.random', 'value': 10},
            ])
        )

        loaded_prefs = DomainsViolationsPrefs.get_domains_violations_prefs_by_domain(self.db, domain.name)
        expect(loaded_prefs).to_length(1)
        expect(loaded_prefs[0]).to_be_like({
            'value': 10,
            'key': 'some.random'
        })
开发者ID:diegosaouda,项目名称:holmes-api,代码行数:29,代码来源:test_domains_violations_prefs.py


示例15: 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


示例16: test_can_get_violation_count_and_points

    def test_can_get_violation_count_and_points(self):
        domain = DomainFactory.create()
        domain2 = DomainFactory.create()
        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)

        violation_count = domain.get_violation_data(self.db)

        expect(violation_count).to_equal(30)
开发者ID:pombredanne,项目名称:holmes-api,代码行数:16,代码来源:test_domain.py


示例17: 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


示例18: 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


示例19: test_can_convert_to_dict

    def test_can_convert_to_dict(self):
        domain = DomainFactory.create()

        domain_dict = domain.to_dict()

        expect(domain_dict['url']).to_equal(domain.url)
        expect(domain_dict['name']).to_equal(domain.name)
开发者ID:pombredanne,项目名称:holmes-api,代码行数:7,代码来源:test_domain.py


示例20: test_can_get_page_count

    def test_can_get_page_count(self):
        domain = DomainFactory.create()
        domain2 = DomainFactory.create()
        DomainFactory.create()

        PageFactory.create(domain=domain)
        PageFactory.create(domain=domain)
        PageFactory.create(domain=domain2)
        PageFactory.create(domain=domain2)
        PageFactory.create(domain=domain2)

        pages_for_domain = domain.get_page_count(self.db)
        pages_for_domain_2 = domain2.get_page_count(self.db)

        expect(pages_for_domain).to_equal(2)
        expect(pages_for_domain_2).to_equal(3)
开发者ID:pombredanne,项目名称:holmes-api,代码行数:16,代码来源:test_domain.py



注:本文中的tests.fixtures.DomainFactory类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python fixtures.KeyFactory类代码示例发布时间:2022-05-27
下一篇:
Python fixtures.loop函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap