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


Python ContactFactory.create方法代码示例

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


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

示例1: test_filtered_report

# 需要导入模块: from mypartners.tests.factories import ContactFactory [as 别名]
# 或者: from mypartners.tests.factories.ContactFactory import create [as 别名]
    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,代码行数:31,代码来源:test_models.py

示例2: test_dynamic_report_with_filter

# 需要导入模块: from mypartners.tests.factories import ContactFactory [as 别名]
# 或者: from mypartners.tests.factories.ContactFactory import create [as 别名]
    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,代码行数:35,代码来源:test_views.py

示例3: test_dynamic_contacts_trial_report

# 需要导入模块: from mypartners.tests.factories import ContactFactory [as 别名]
# 或者: from mypartners.tests.factories.ContactFactory import create [as 别名]
    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,代码行数:30,代码来源:test_views.py

示例4: test_dynamic_contacts_report

# 需要导入模块: from mypartners.tests.factories import ContactFactory [as 别名]
# 或者: from mypartners.tests.factories.ContactFactory import create [as 别名]
    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,代码行数:37,代码来源:test_views.py

示例5: setUp

# 需要导入模块: from mypartners.tests.factories import ContactFactory [as 别名]
# 或者: from mypartners.tests.factories.ContactFactory import create [as 别名]
 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,代码行数:15,代码来源:test_views.py

示例6: test_report

# 需要导入模块: from mypartners.tests.factories import ContactFactory [as 别名]
# 或者: from mypartners.tests.factories.ContactFactory import create [as 别名]
    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,代码行数:18,代码来源:test_models.py

示例7: test_report

# 需要导入模块: from mypartners.tests.factories import ContactFactory [as 别名]
# 或者: from mypartners.tests.factories.ContactFactory import create [as 别名]
    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,代码行数:20,代码来源:test_models.py

示例8: test_dynamic_contacts_report

# 需要导入模块: from mypartners.tests.factories import ContactFactory [as 别名]
# 或者: from mypartners.tests.factories.ContactFactory import create [as 别名]
    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,代码行数:44,代码来源:test_views.py

示例9: test_dynamic_report

# 需要导入模块: from mypartners.tests.factories import ContactFactory [as 别名]
# 或者: from mypartners.tests.factories.ContactFactory import create [as 别名]
    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,代码行数:22,代码来源:test_views.py

示例10: test_dynamic_report_with_filter

# 需要导入模块: from mypartners.tests.factories import ContactFactory [as 别名]
# 或者: from mypartners.tests.factories.ContactFactory import create [as 别名]
    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,代码行数:42,代码来源:test_views.py

示例11: test_dynamic_partners_report_comm_per_month

# 需要导入模块: from mypartners.tests.factories import ContactFactory [as 别名]
# 或者: from mypartners.tests.factories.ContactFactory import create [as 别名]
    def test_dynamic_partners_report_comm_per_month(self):
        """Run the comm_rec per month per partner report."""
        self.client.login_user(self.user)

        partner = PartnerFactory(owner=self.company)
        partner.tags.add(TagFactory.create(name="this"))
        contact = ContactFactory.create(name='somename', partner=partner)

        for i in range(0, 20):
            # unicode here to push through report generation/download
            ContactRecordFactory(
                partner=partner,
                contact=contact,
                date_time=datetime(2015, 2, 4),
                subject=u"subject-%s \u2019" % i)

        report_presentation = self.find_report_presentation(
            'partners',
            'json_pass',
            data_type="count_comm_rec_per_month")

        resp = self.client.post(
            reverse('run_dynamic_report'),
            data={
                'rp_id': report_presentation.pk,
                'name': 'The Report',
                'filter': json.dumps({
                    'tags': [['this']],
                }),
            })
        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(12, len(response_data['records']))
        january = response_data['records'][0]
        self.assertEqual('1', january['month'])
        self.assertEqual('0', january['comm_rec_count'])
        february = response_data['records'][1]
        self.assertEqual('2', february['month'])
        self.assertEqual('20', february['comm_rec_count'])
开发者ID:kepinq,项目名称:MyJobs,代码行数:54,代码来源:test_views.py

示例12: setUp

# 需要导入模块: from mypartners.tests.factories import ContactFactory [as 别名]
# 或者: from mypartners.tests.factories.ContactFactory import create [as 别名]
    def setUp(self):
        super(TestReportsApi, self).setUp()
        contact = ContactFactory.create(
            name="a",
            email="[email protected]",
            partner=self.partner,
            locations=[
                LocationFactory.create(city="Chicago", state="IL"),
                LocationFactory.create(city="Champaign", state="IL"),
            ],
        )

        contact.tags.add(TagFactory.create(name="Disability"))
        contact.tags.add(TagFactory.create(name="Veteran"))
        contact.tags.add(TagFactory.create(name="Senior"))
开发者ID:DirectEmployers,项目名称:MyJobs,代码行数:17,代码来源:test_views.py

示例13: test_dynamic_comm_records_report

# 需要导入模块: from mypartners.tests.factories import ContactFactory [as 别名]
# 或者: from mypartners.tests.factories.ContactFactory import create [as 别名]
    def test_dynamic_comm_records_report(self):
        """Create some test data, run, list, and download a commrec report."""
        self.client.login_user(self.user)

        partner = PartnerFactory(owner=self.company)
        contact = ContactFactory.create(name='somename', partner=partner)

        for i in range(0, 20):
            # unicode here to push through report generation/download
            ContactRecordFactory(
                partner=partner,
                contact=contact,
                subject=u"subject-%s \u2019" % i)

        report_presentation = self.find_report_presentation(
            'comm_records',
            '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(20, len(response_data['records']))

        last_subject = response_data['records'][-1]['subject']
        expected_subject = u'subject-19 \u2019'
        self.assertEqual(expected_subject, last_subject)
开发者ID:kepinq,项目名称:MyJobs,代码行数:46,代码来源:test_views.py

示例14: test_dynamic_partners_report_comm_per_month

# 需要导入模块: from mypartners.tests.factories import ContactFactory [as 别名]
# 或者: from mypartners.tests.factories.ContactFactory import create [as 别名]
    def test_dynamic_partners_report_comm_per_month(self):
        """Run the comm_rec per month per partner report."""
        self.client.login_user(self.user)

        partner = PartnerFactory(owner=self.company)
        partner.tags.add(TagFactory.create(name="this"))
        contact = ContactFactory.create(name="somename", partner=partner)

        for i in range(0, 20):
            # unicode here to push through report generation/download
            ContactRecordFactory(
                partner=partner, contact=contact, date_time=datetime(2015, 2, 4), subject=u"subject-%s \u2019" % i
            )

        report_data = self.find_report_data("partners", data_type="count_comm_rec_per_month")

        resp = self.client.post(
            reverse("run_dynamic_report"),
            data={"report_data_id": report_data.pk, "name": "The Report", "filter": json.dumps({"tags": [["this"]]})},
        )
        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": "partners"}]}, 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(12, len(response_data["records"]))
        january = response_data["records"][0]
        self.assertEqual("1", january["Month"])
        self.assertEqual("0", january["Communication Record Count"])
        february = response_data["records"][1]
        self.assertEqual("2", february["Month"])
        self.assertEqual("20", february["Communication Record Count"])
开发者ID:DirectEmployers,项目名称:MyJobs,代码行数:44,代码来源:test_views.py

示例15: test_dynamic_comm_records_report

# 需要导入模块: from mypartners.tests.factories import ContactFactory [as 别名]
# 或者: from mypartners.tests.factories.ContactFactory import create [as 别名]
    def test_dynamic_comm_records_report(self):
        """Create some test data, run, list, and download a commrec report."""
        self.client.login_user(self.user)

        partner = PartnerFactory(owner=self.company)
        contact = ContactFactory.create(name="somename", partner=partner)

        for i in range(0, 20):
            # unicode here to push through report generation/download
            ContactRecordFactory(partner=partner, contact=contact, subject=u"subject-%s \u2019" % i)

        report_data = self.find_report_data("comm_records")

        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": "communication-records"}]},
            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(20, len(response_data["records"]))

        last_subject = response_data["records"][-1]["Subject"]
        expected_subject = u"subject-19 \u2019"
        self.assertEqual(expected_subject, last_subject)
开发者ID:DirectEmployers,项目名称:MyJobs,代码行数:39,代码来源:test_views.py


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