当前位置: 首页>>代码示例>>Python>>正文


Python factories.ContactFactory类代码示例

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


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

示例1: test_dynamic_contacts_report

    def test_dynamic_contacts_report(self):
        """Create some test data, run, list, and download a contacts report."""
        self.client.login_user(self.user)

        partner = PartnerFactory(owner=self.company)
        for i in range(0, 10):
            # unicode here to push through report generation/download
            ContactFactory.create(name=u"name-%s \u2019" % i, partner=partner)

        report_data = self.find_report_data("contacts")

        resp = self.client.post(
            reverse("run_dynamic_report"), data={"report_data_id": report_data.pk, "name": "The Report"}
        )
        self.assertEqual(200, resp.status_code)
        report_id = json.loads(resp.content)["id"]

        resp = self.client.get(reverse("list_dynamic_reports"))
        self.assertEqual(200, resp.status_code)
        self.assertEqual(
            {"reports": [{"id": report_id, "name": "The Report", "report_type": "contacts"}]}, json.loads(resp.content)
        )

        report_presentation = self.find_report_presentation(report_data, "json_pass")

        data = {"id": report_id, "report_presentation_id": report_presentation.pk}
        resp = self.client.get(reverse("download_dynamic_report"), data)
        self.assertEquals(200, resp.status_code)

        response_data = json.loads(resp.content)
        self.assertEquals(10, len(response_data["records"]))

        first_found_name = response_data["records"][0]["Name"]
        expected_name = u"name-0 \u2019"
        self.assertEqual(expected_name, first_found_name)
开发者ID:DirectEmployers,项目名称:MyJobs,代码行数:35,代码来源:test_views.py

示例2: test_dynamic_contacts_trial_report

    def test_dynamic_contacts_trial_report(self):
        """Run a trial report."""
        self.maxDiff = 10000
        self.client.login_user(self.user)

        partner = PartnerFactory(owner=self.company)
        for i in range(0, 10):
            location = LocationFactory.create(city="city-%s" % i, state="ZZ")
            # unicode here to push through report generation/download
            ContactFactory.create(name=u"name-%s \u2019" % i, partner=partner, locations=[location])

        report_data = self.find_report_data("contacts")

        resp = self.client.post(
            reverse("run_trial_dynamic_report"),
            data={
                "report_data_id": report_data.pk,
                "name": "The Report",
                "filter": json.dumps({"locations": {"city": "city-2"}}),
                "values": json.dumps(["phone", "tags", "email", "name"]),
            },
        )
        self.assertEqual(200, resp.status_code)
        report_content = json.loads(resp.content)
        self.assertEqual(
            [{u"email": u"[email protected]", u"name": u"name-2 \u2019", u"phone": u"84104391", u"tags": []}],
            report_content,
        )
开发者ID:DirectEmployers,项目名称:MyJobs,代码行数:28,代码来源:test_views.py

示例3: test_dynamic_report_with_filter

    def test_dynamic_report_with_filter(self):
        """Create some test data, run filtered, and download a report."""
        self.client.login_user(self.user)

        partner = PartnerFactory(owner=self.company)
        for i in range(0, 10):
            location = LocationFactory.create(city="city-%s" % i)
            ContactFactory.create(name="name-%s" % i, partner=partner, locations=[location])

        report_data = self.find_report_data("contacts")

        resp = self.client.post(
            reverse("run_dynamic_report"),
            data={
                "report_data_id": report_data.pk,
                "name": "The Report",
                "filter": json.dumps({"locations": {"city": "city-2"}}),
            },
        )
        self.assertEqual(200, resp.status_code)
        report_id = json.loads(resp.content)["id"]

        report_presentation = self.find_report_presentation(report_data, "json_pass")

        data = {"id": report_id, "report_presentation_id": report_presentation.pk}
        resp = self.client.get(reverse("download_dynamic_report"), data)
        self.assertEquals(200, resp.status_code)
        response_data = json.loads(resp.content)
        self.assertEquals(1, len(response_data["records"]))

        found_name = response_data["records"][0]["Name"]
        expected_name = u"name-2"
        self.assertEqual(expected_name, found_name)
开发者ID:DirectEmployers,项目名称:MyJobs,代码行数:33,代码来源:test_views.py

示例4: test_filtered_report

    def test_filtered_report(self):
        """Run a dynamic report with a filter."""
        partner = PartnerFactory(owner=self.company)
        for i in range(0, 10):
            location = LocationFactory.create(
                city="city-%s" % i)
            ContactFactory.create(
                name="name-%s" % i,
                partner=partner,
                locations=[location])

        report_data = (
            self.dynamic_models['report_type/data_type']
            ['contacts/unaggregated'])
        report = DynamicReport.objects.create(
            report_data=report_data,
            filters=json.dumps({
                'locations': {
                    'city': 'city-2',
                },
            }),
            owner=self.company)
        report.regenerate()
        expected_column_names = {
            'name', 'tags', 'notes', 'locations', 'phone', 'partner',
            'email', 'date'}
        self.assertEqual(1, len(report.python))
        self.assertEqual('name-2', report.python[0]['name'])
        self.assertEqual(expected_column_names, set(report.python[0]))
开发者ID:DirectEmployers,项目名称:MyJobs,代码行数:29,代码来源:test_models.py

示例5: test_filter_by_state

    def test_filter_by_state(self):
        """Tests that filtering by state works."""

        indiana = LocationFactory(state="IN")
        ContactFactory.create_batch(10, name="Jen Doe", partner=self.partner, locations=[indiana])

        self.client.path += "/contact"
        response = self.client.get(data={"state": "IN"})
        output = json.loads(response.content)

        self.assertEqual(len(output), 10)
开发者ID:vfulco,项目名称:MyJobs,代码行数:11,代码来源:test_views.py

示例6: test_filter_by_city

    def test_filter_by_city(self):
        """Tests that filtering by city works."""

        indianapolis = LocationFactory(city="Indianapolis")
        ContactFactory.create_batch(10, name="Jen Doe", partner=self.partner, locations=[indianapolis])

        self.client.path += "/contact"
        response = self.client.get(data={"city": "indianapolis"})
        output = json.loads(response.content)

        self.assertEqual(len(output), 10)
开发者ID:vfulco,项目名称:MyJobs,代码行数:11,代码来源:test_views.py

示例7: setUp

 def setUp(self):
     super(TestReportsApi, self).setUp()
     ContactFactory.create(
         name="a", email="[email protected]",
         partner=self.partner,
         locations=[
             LocationFactory.create(
                 city="Chicago",
                 state="IL"),
             LocationFactory.create(
                 city="Champaign",
                 state="IL"),
             ])
开发者ID:kepinq,项目名称:MyJobs,代码行数:13,代码来源:test_views.py

示例8: test_filtering_on_contact

    def test_filtering_on_contact(self):
        """Test the ability to filter by contact."""

        ContactFactory.create_batch(10, name="Jen Doe", partner=self.partner)

        # contacts with the wrong name
        ContactFactory.create_batch(10, name="Jen Smith", partner=self.partner)

        self.client.path += "/contact"
        response = self.client.get(data={"name": "Jen Doe"})
        output = json.loads(response.content)

        self.assertEqual(response.status_code, 200)
        self.assertEqual(len(output), 10)
开发者ID:vfulco,项目名称:MyJobs,代码行数:14,代码来源:test_views.py

示例9: test_contact_record_counts_vs_list

    def test_contact_record_counts_vs_list(self):
        """
        ContactRecord counts for Communication Records and Referals
        should match summed counts from contacts.
        """
        contacts = ContactFactory.create_batch(4)
        contacts[0].name = 'Other name'
        contacts[1].email = '[email protected]'
        contacts[2].partner = PartnerFactory(name='Other Partner')
        for contact in contacts:
            ContactRecordFactory.create(contact_type="job",
                                        contact=contact,
                                        partner=contact.partner)
            ContactRecordFactory.create(contact_type = 'email',
                                        contact=contact,
                                        partner=contact.partner)

        contacts[0].email = '[email protected]'
        ContactRecordFactory.create(contact_type = 'email',
                                    contact=contacts[0],
                                    partner=contact.partner)


        queryset = ContactRecord.objects.all()
        self.assertEqual(queryset.count(), 9)

        contacts = list(queryset.contacts)
        sum_referrals = sum([contact['referrals'] for contact in contacts])
        sum_records = sum([contact['records'] for contact in contacts])
        self.assertEqual(sum_referrals, queryset.referrals)
        self.assertEqual(sum_records, queryset.communication_activity.count())
开发者ID:DirectEmployers,项目名称:MyJobs,代码行数:31,代码来源:test_models.py

示例10: test_report

    def test_report(self):
        """Run a dynamic report through its paces."""
        partner = PartnerFactory(owner=self.company)
        for i in range(0, 10):
            ContactFactory.create(name="name-%s" % i, partner=partner)

        report_pres = ReportPresentation.objects.get(id=3)
        report = DynamicReport.objects.create(
            report_presentation=report_pres,
            owner=self.company)
        report.regenerate()
        expected_column_names = set([
            'name', 'tags', 'notes', 'locations', 'phone', 'partner',
            'email'])
        self.assertEqual(10, len(report.python))
        self.assertEqual(expected_column_names, set(report.python[0]))
开发者ID:wejhink,项目名称:MyJobs,代码行数:16,代码来源:test_models.py

示例11: test_report

    def test_report(self):
        """Run a dynamic report through its paces."""
        partner = PartnerFactory(owner=self.company)
        for i in range(0, 10):
            ContactFactory.create(name="name-%s" % i, partner=partner)

        report_data = (
            self.dynamic_models['report_type/data_type']
            ['contacts/unaggregated'])
        report = DynamicReport.objects.create(
            report_data=report_data,
            owner=self.company)
        report.regenerate()
        expected_column_names = {
            'name', 'tags', 'notes', 'locations', 'phone', 'partner',
            'email', 'date'}
        self.assertEqual(10, len(report.python))
        self.assertEqual(expected_column_names, set(report.python[0]))
开发者ID:DirectEmployers,项目名称:MyJobs,代码行数:18,代码来源:test_models.py

示例12: test_dynamic_contacts_report

    def test_dynamic_contacts_report(self):
        """Create some test data, run, list, and download a contacts report."""
        self.client.login_user(self.user)

        partner = PartnerFactory(owner=self.company)
        for i in range(0, 10):
            # unicode here to push through report generation/download
            ContactFactory.create(
                name=u"name-%s \u2019" % i,
                partner=partner)

        report_presentation = self.find_report_presentation(
            'contacts',
            'json_pass')

        resp = self.client.post(
            reverse('run_dynamic_report'),
            data={
                'rp_id': report_presentation.pk,
                'name': 'The Report',
            })
        self.assertEqual(200, resp.status_code)
        report_id = json.loads(resp.content)['id']

        resp = self.client.get(reverse('list_dynamic_reports'))
        self.assertEqual(200, resp.status_code)
        self.assertEqual(
            {'reports': [
                {'id': report_id, 'name': 'The Report'},
            ]},
            json.loads(resp.content))

        resp = self.client.get(reverse('download_dynamic_report'),
                               {'id': report_id})
        self.assertEquals(200, resp.status_code)

        response_data = json.loads(resp.content)
        self.assertEquals(10, len(response_data['records']))

        first_found_name = response_data['records'][0]['name']
        expected_name = u'name-0 \u2019'
        self.assertEqual(expected_name, first_found_name)
开发者ID:kepinq,项目名称:MyJobs,代码行数:42,代码来源:test_views.py

示例13: test_dynamic_report

    def test_dynamic_report(self):
        """Create some test data, run, and download a report."""
        self.client.login_user(self.user)

        partner = PartnerFactory(owner=self.company)
        for i in range(0, 10):
            ContactFactory.create(name=u"name-%s \u2019" % i, partner=partner)

        resp = self.client.post(reverse('run_dynamic_report'), {'rp_id': 3})
        self.assertEqual(200, resp.status_code)
        report_id = json.loads(resp.content)['id']

        resp = self.client.get(reverse('download_dynamic_report'),
                               {'id': report_id})
        self.assertEquals(200, resp.status_code)
        lines = resp.content.splitlines()
        first_found_name = lines[1].split(',')[0]
        expected_name = u'name-0 \u2019'.encode('utf-8')
        self.assertEqual(expected_name, first_found_name)
        self.assertEquals(11, len(lines))
开发者ID:wejhink,项目名称:MyJobs,代码行数:20,代码来源:test_views.py

示例14: test_list_query_params

    def test_list_query_params(self):
        """Test that query parameters that are lists are parsed correctly."""

        contacts = ContactFactory.create_batch(10, partner__owner=self.company)
        pks = [contact.pk for contact in contacts[:5]]

        self.client.path += "/partner"
        response = self.client.get(data={"contact": pks})
        output = json.loads(response.content)

        self.assertEqual(response.status_code, 200)
        self.assertEqual(len(output), 5)
开发者ID:vfulco,项目名称:MyJobs,代码行数:12,代码来源:test_views.py

示例15: test_dynamic_report_with_filter

    def test_dynamic_report_with_filter(self):
        """Create some test data, run filtered, and download a report."""
        self.client.login_user(self.user)

        partner = PartnerFactory(owner=self.company)
        for i in range(0, 10):
            location = LocationFactory.create(
                city="city-%s" % i)
            ContactFactory.create(
                name="name-%s" % i,
                partner=partner,
                locations=[location])

        report_presentation = self.find_report_presentation(
            'contacts',
            'json_pass')

        resp = self.client.post(
            reverse('run_dynamic_report'),
            data={
                'rp_id': report_presentation.pk,
                'name': 'The Report',
                'filter': json.dumps({
                    'locations': {
                        'city': 'city-2',
                    },
                }),
            })
        self.assertEqual(200, resp.status_code)
        report_id = json.loads(resp.content)['id']

        resp = self.client.get(reverse('download_dynamic_report'),
                               {'id': report_id})
        self.assertEquals(200, resp.status_code)
        response_data = json.loads(resp.content)
        self.assertEquals(1, len(response_data['records']))

        found_name = response_data['records'][0]['name']
        expected_name = u'name-2'
        self.assertEqual(expected_name, found_name)
开发者ID:kepinq,项目名称:MyJobs,代码行数:40,代码来源:test_views.py


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