本文整理汇总了Python中mypartners.tests.factories.ContactRecordFactory类的典型用法代码示例。如果您正苦于以下问题:Python ContactRecordFactory类的具体用法?Python ContactRecordFactory怎么用?Python ContactRecordFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ContactRecordFactory类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: setUp
def setUp(self):
super(TestRegenerate, self).setUp()
self.client = TestClient(path=reverse('reports', kwargs={
'app': 'mypartners', 'model': 'contactrecord'}))
self.client.login_user(self.user)
ContactRecordFactory.create_batch(10, partner__owner=self.company)
开发者ID:kepinae,项目名称:MyJobs,代码行数:7,代码来源:test_views.py
示例2: setUp
def setUp(self):
super(ContactRecordFormTests, self).setUp()
self.contact_record = ContactRecordFactory(
contact=self.contact, partner=self.partner)
# The contact record form has a lot of required fields.
self.data = {
'contact_type': self.contact_record.contact_type,
'contact': self.contact_record.contact.pk,
'contact_email': self.contact_record.contact_email,
'length_0': "00",
'length_1': "30",
'date_time_0': "Aug",
'date_time_1': "24",
'date_time_2': "2015",
'date_time_3': "03",
'date_time_4': "10",
'date_time_5': "PM",
'notes': self.contact_record.notes,
'partner': self.contact_record.partner.pk,
'company': self.contact_record.partner.owner
}
self.form = ContactRecordForm(
instance=self.contact_record, partner=self.partner, data=self.data)
# add a few contact records so that we have some to select from
ContactRecordFactory.create_batch(3, partner=self.partner,
contact=self.contact,
contact_type='phone')
self.client.path = reverse(
"partner_edit_record") + "?partner=%s" % self.partner.pk
开发者ID:kepinae,项目名称:MyJobs,代码行数:33,代码来源:test_forms.py
示例3: test_filtering_on_foreign_key
def test_filtering_on_foreign_key(self):
"""Test the ability to filter on a model's foreign key fields."""
PartnerFactory.create_batch(5, name='Test Partner', owner=self.company)
ContactRecordFactory.create_batch(
5, partner=self.partner, contact__name='Jane Doe')
self.client.path += '/partner'
filters = json.dumps({
'name': {
'icontains': 'Test Partner',
},
'contactrecord': {
'contact': {
'name': {
'icontains': 'Jane Doe'
}
}
}
})
response = self.client.post(data={'filters': filters})
output = json.loads(response.content)
self.assertEqual(response.status_code, 200)
# We look for distinct records
self.assertEqual(len(output), 1)
开发者ID:kepinae,项目名称:MyJobs,代码行数:28,代码来源:test_views.py
示例4: setUp
def setUp(self):
super(TestHelpers, self).setUp()
tags = [TagFactory(name=name, company=self.company) for name in ["test", "stuff", "working"]]
# Returns a list rather than a QuerySet, which is what the helper
# functions use, so saving this to a variable isn't really helpful
ContactRecordFactory.create_batch(10, partner=self.partner, contact__name="Joe Shmoe", tags=tags)
self.records = ContactRecord.objects.all()
开发者ID:abdulfiroz007,项目名称:MyJobs,代码行数:9,代码来源:test_helpers.py
示例5: test_json_output
def test_json_output(self):
"""Test that filtering contact records through ajax works properly."""
# records to be filtered out
ContactRecordFactory.create_batch(10, contact__name="John Doe")
self.client.path += "/contactrecord"
response = self.client.get(data={"contact__name": "Joe Shmoe"})
output = json.loads(response.content)
self.assertEqual(response.status_code, 200)
self.assertEqual(len(output), 10)
开发者ID:vfulco,项目名称:MyJobs,代码行数:12,代码来源:test_views.py
示例6: test_only_user_results_returned
def test_only_user_results_returned(self):
"""Results should only contain records user has access to."""
# records not owned by user
partner = PartnerFactory(name="Wrong Partner")
ContactRecordFactory.create_batch(10, partner=partner)
self.client.path += '/contactrecord'
response = self.client.post()
output = json.loads(response.content)
self.assertEqual(response.status_code, 200)
self.assertEqual(len(output), 10)
开发者ID:kepinae,项目名称:MyJobs,代码行数:13,代码来源:test_views.py
示例7: test_filtering_on_foreign_key
def test_filtering_on_foreign_key(self):
"""Test the ability to filter on a model's foreign key fields."""
PartnerFactory.create_batch(5, name="Test Partner", owner=self.company)
ContactRecordFactory.create_batch(5, partner=self.partner, contact__name="Jane Doe")
self.client.path += "/partner"
filters = json.dumps(
{"name": {"icontains": "Test Partner"}, "contactrecord": {"contact": {"name": {"icontains": "Jane Doe"}}}}
)
response = self.client.post(data={"filters": filters})
output = json.loads(response.content)
self.assertEqual(response.status_code, 200)
# We look for distinct records
self.assertEqual(len(output), 1)
开发者ID:DirectEmployers,项目名称:MyJobs,代码行数:17,代码来源:test_views.py
示例8: test_json_output
def test_json_output(self):
"""Test that filtering contact records through ajax works properly."""
# records to be filtered out
ContactRecordFactory.create_batch(10, contact__name='John Doe')
self.client.path += '/contactrecord'
filters = json.dumps({
'contact': {
'name': {
'icontains': 'Joe Shmoe'
}
}
})
response = self.client.post(data={'filters': filters})
output = json.loads(response.content)
self.assertEqual(response.status_code, 200)
self.assertEqual(len(output), 10)
开发者ID:kepinae,项目名称:MyJobs,代码行数:19,代码来源: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: setUp
def setUp(self):
super(TestReportView, self).setUp()
self.client = TestClient(path=reverse("reports", kwargs={"app": "mypartners", "model": "contactrecord"}))
self.client.login_user(self.user)
ContactRecordFactory.create_batch(5, partner__owner=self.company)
ContactRecordFactory.create_batch(5, contact_type="job", job_applications=1, partner__owner=self.company)
ContactRecordFactory.create_batch(5, contact_type="job", job_hires=1, partner__owner=self.company)
开发者ID:vfulco,项目名称:MyJobs,代码行数:8,代码来源:test_views.py
示例11: setUp
def setUp(self):
super(TestCommRecordsDataSource, self).setUp()
# A company to work with
self.company = CompanyFactory(name='right')
self.company.save()
# A separate company that should not show up in results.
self.other_company = CompanyFactory(name='wrong')
self.other_company.save()
self.partner_a = PartnerFactory(
owner=self.company,
uri='http://www.example.com/',
data_source="zap",
name="aaa")
self.partner_b = PartnerFactory(
owner=self.company,
uri='http://www.asdf.com/',
data_source="bcd",
name="bbb")
# An unapproved parther. Associated data should be filtered out.
self.partner_unapp = PartnerFactory(
owner=self.company,
name="unapproved",
approval_status__code=Status.UNPROCESSED)
# An archived parther. Associated data should be filtered out.
self.partner_archived = PartnerFactory(owner=self.company)
self.east_tag = TagFactory.create(name='east', hex_color="aaaaaa")
self.west_tag = TagFactory.create(name='west', hex_color="bbbbbb")
self.bad_tag = TagFactory.create(name='bad', hex_color="cccccc")
self.john_user = UserFactory(email="[email protected]")
self.john = ContactFactory(
partner=self.partner_a,
name='john adams',
user=self.john_user,
email="[email protected]",
last_action_time='2015-10-03')
self.john.locations.add(
LocationFactory.create(
city="Indianapolis",
state="IN"))
self.john.locations.add(
LocationFactory.create(
city="Chicago",
state="IL"))
self.sue_user = UserFactory(email="[email protected]")
self.sue = ContactFactory(
partner=self.partner_b,
name='Sue Baxter',
user=self.sue_user,
email="[email protected]",
last_action_time='2015-09-30 13:23')
self.sue.locations.add(
LocationFactory.create(
address_line_one="123",
city="Los Angeles",
state="CA"))
self.sue.locations.add(
LocationFactory.create(
address_line_one="234",
city="Los Angeles",
state="CA"))
self.partner_a.primary_contact = self.john
self.partner_b.primary_contact = self.sue
self.partner_a.save()
self.partner_b.save()
self.record_1 = ContactRecordFactory(
subject='record 1',
date_time='2015-09-30 13:23',
contact=self.john,
contact_type="Email",
partner=self.partner_a,
location='Indianapolis, IN',
tags=[self.east_tag])
self.record_2 = ContactRecordFactory(
subject='record 2',
date_time='2015-01-01',
contact=self.john,
contact_type="Meeting Or Event",
partner=self.partner_a,
location='Indianapolis, IN',
tags=[self.east_tag])
self.record_3 = ContactRecordFactory(
subject='record 3',
date_time='2015-10-03',
contact=self.sue,
contact_type="Phone",
partner=self.partner_b,
location='Los Angeles, CA',
tags=[self.west_tag])
# Archive archived data here. Doing this earlier in the set up results
# in odd exceptions.
#.........这里部分代码省略.........
开发者ID:kepinq,项目名称:MyJobs,代码行数:101,代码来源:test_comm_records_datasource.py
示例12: TestCommRecordsDataSource
class TestCommRecordsDataSource(MyJobsBase):
def setUp(self):
super(TestCommRecordsDataSource, self).setUp()
# A company to work with
self.company = CompanyFactory(name='right')
self.company.save()
# A separate company that should not show up in results.
self.other_company = CompanyFactory(name='wrong')
self.other_company.save()
self.partner_a = PartnerFactory(
owner=self.company,
uri='http://www.example.com/',
data_source="zap",
name="aaa")
self.partner_b = PartnerFactory(
owner=self.company,
uri='http://www.asdf.com/',
data_source="bcd",
name="bbb")
# An unapproved parther. Associated data should be filtered out.
self.partner_unapp = PartnerFactory(
owner=self.company,
name="unapproved",
approval_status__code=Status.UNPROCESSED)
# An archived parther. Associated data should be filtered out.
self.partner_archived = PartnerFactory(owner=self.company)
self.east_tag = TagFactory.create(name='east', hex_color="aaaaaa")
self.west_tag = TagFactory.create(name='west', hex_color="bbbbbb")
self.bad_tag = TagFactory.create(name='bad', hex_color="cccccc")
self.john_user = UserFactory(email="[email protected]")
self.john = ContactFactory(
partner=self.partner_a,
name='john adams',
user=self.john_user,
email="[email protected]",
last_action_time='2015-10-03')
self.john.locations.add(
LocationFactory.create(
city="Indianapolis",
state="IN"))
self.john.locations.add(
LocationFactory.create(
city="Chicago",
state="IL"))
self.sue_user = UserFactory(email="[email protected]")
self.sue = ContactFactory(
partner=self.partner_b,
name='Sue Baxter',
user=self.sue_user,
email="[email protected]",
last_action_time='2015-09-30 13:23')
self.sue.locations.add(
LocationFactory.create(
address_line_one="123",
city="Los Angeles",
state="CA"))
self.sue.locations.add(
LocationFactory.create(
address_line_one="234",
city="Los Angeles",
state="CA"))
self.partner_a.primary_contact = self.john
self.partner_b.primary_contact = self.sue
self.partner_a.save()
self.partner_b.save()
self.record_1 = ContactRecordFactory(
subject='record 1',
date_time='2015-09-30 13:23',
contact=self.john,
contact_type="Email",
partner=self.partner_a,
location='Indianapolis, IN',
tags=[self.east_tag])
self.record_2 = ContactRecordFactory(
subject='record 2',
date_time='2015-01-01',
contact=self.john,
contact_type="Meeting Or Event",
partner=self.partner_a,
location='Indianapolis, IN',
tags=[self.east_tag])
self.record_3 = ContactRecordFactory(
subject='record 3',
date_time='2015-10-03',
contact=self.sue,
contact_type="Phone",
partner=self.partner_b,
location='Los Angeles, CA',
tags=[self.west_tag])
# Archive archived data here. Doing this earlier in the set up results
#.........这里部分代码省略.........
开发者ID:kepinq,项目名称:MyJobs,代码行数:101,代码来源:test_comm_records_datasource.py
示例13: TestCommRecordsDataSource
class TestCommRecordsDataSource(MyJobsBase):
def setUp(self):
super(TestCommRecordsDataSource, self).setUp()
# A company to work with
self.company = CompanyFactory(name='right')
self.company.save()
# A separate company that should not show up in results.
self.other_company = CompanyFactory(name='wrong')
self.other_company.save()
self.partner_a = PartnerFactory(
owner=self.company,
uri='http://www.example.com/',
data_source="zap",
name="aaa")
self.partner_b = PartnerFactory(
owner=self.company,
uri='http://www.asdf.com/',
data_source="bcd",
name="bbb")
# An unapproved parther. Associated data should be filtered out.
self.partner_unapp = PartnerFactory(
owner=self.company,
name="unapproved",
approval_status__code=Status.UNPROCESSED)
# An archived parther. Associated data should be filtered out.
self.partner_archived = PartnerFactory(owner=self.company)
self.east_tag = TagFactory.create(
company=self.company, name='east', hex_color="aaaaaa")
self.west_tag = TagFactory.create(
company=self.company, name='west', hex_color="bbbbbb")
self.north_tag = TagFactory.create(
company=self.company, name='north', hex_color="cccccc")
self.south_tag = TagFactory.create(
company=self.company, name='south', hex_color="dddddd")
self.left_tag = TagFactory.create(
company=self.company, name='left', hex_color="eeeeee")
self.right_tag = TagFactory.create(
company=self.company, name='right', hex_color="ffffff")
self.bad_tag = TagFactory.create(
company=self.company, name='bad', hex_color="cccccc")
self.partner_a.tags.add(self.left_tag)
self.partner_b.tags.add(self.right_tag)
self.john_user = UserFactory(email="[email protected]")
self.john = ContactFactory(
partner=self.partner_a,
name='john adams',
user=self.john_user,
email="[email protected]",
last_action_time='2015-10-03')
self.john.locations.add(
LocationFactory.create(
city="Indianapolis",
state="IN"))
self.john.locations.add(
LocationFactory.create(
city="Chicago",
state="IL"))
self.john.tags.add(self.north_tag)
self.sue_user = UserFactory(email="[email protected]")
self.sue = ContactFactory(
partner=self.partner_b,
name='Sue Baxter',
user=self.sue_user,
email="[email protected]",
last_action_time='2015-09-30 13:23')
self.sue.locations.add(
LocationFactory.create(
address_line_one="123",
city="Los Angeles",
state="CA"))
self.sue.locations.add(
LocationFactory.create(
address_line_one="234",
city="Los Angeles",
state="CA"))
self.sue.tags.add(self.south_tag)
self.partner_a.primary_contact = self.john
self.partner_b.primary_contact = self.sue
self.partner_a.save()
self.partner_b.save()
self.record_1 = ContactRecordFactory(
subject='record 1',
date_time='2015-09-30 13:23',
contact=self.john,
contact_type="Email",
partner=self.partner_a,
location='Indianapolis, IN',
tags=[self.east_tag])
self.record_2 = ContactRecordFactory(
subject='record 2',
#.........这里部分代码省略.........
开发者ID:DirectEmployers,项目名称:MyJobs,代码行数:101,代码来源:test_comm_records_datasource.py
注:本文中的mypartners.tests.factories.ContactRecordFactory类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论