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


Python models.Contact类代码示例

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


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

示例1: setUpClass

 def setUpClass(cls):
     """Add contact if less than 2 exist"""
     super(BasicSOQLRoTest, cls).setUpClass()
     some_contacts = Contact.objects.all()[:2]
     if len(some_contacts) < 2:
         for i in range(2 - len(some_contacts)):
             contact = Contact(first_name='sf_test demo', last_name='Test %d' %i)
             contact.save()
     if User.objects.count() == 0:
         user = User(Username=current_user)
         user.save()
开发者ID:chromakey,项目名称:django-salesforce,代码行数:11,代码来源:test_integration.py

示例2: test_foreign_key

 def test_foreign_key(self):
     """Verify that the owner of an Contact is the currently logged admin.
     """
     current_sf_user = User.objects.get(Username=current_user)
     test_contact = Contact(first_name='sf_test', last_name='my')
     test_contact.save()
     try:
         contact = Contact.objects.filter(owner=current_sf_user)[0]
         user = contact.owner
         # This user can be e.g. '[email protected]'.
         self.assertEqual(user.Username, current_user)
     finally:
         test_contact.delete()
开发者ID:KristianOellegaard,项目名称:django-salesforce,代码行数:13,代码来源:test_integration.py

示例3: test_insert_date

 def test_insert_date(self):
     """Test inserting a date.
     """
     now = timezone.now().replace(microsecond=0)
     contact = Contact(
             first_name='Joe',
             last_name='Freelancer',
             email_bounced_date=now)
     contact.save()
     try:
         self.assertEqual(refresh(contact).email_bounced_date, now)
     finally:
         contact.delete()
开发者ID:KristianOellegaard,项目名称:django-salesforce,代码行数:13,代码来源:test_integration.py

示例4: test_foreign_key_column

 def test_foreign_key_column(self):
     """Verify filtering by a column of related parent object.
     """
     test_account = Account(Name='sf_test account')
     test_account.save()
     test_contact = Contact(first_name='sf_test', last_name='my', account=test_account)
     test_contact.save()
     try:
         contacts = Contact.objects.filter(account__Name='sf_test account')
         self.assertEqual(len(contacts), 1)
     finally:
         test_contact.delete()
         test_account.delete()
开发者ID:KristianOellegaard,项目名称:django-salesforce,代码行数:13,代码来源:test_integration.py

示例5: test_insert_date

	def test_insert_date(self):
		"""
		Test inserting a date.
		"""
		now = round_datetime_utc(datetime.datetime.utcnow())
		contact = Contact(
				FirstName = 'Joe',
				LastName = 'Freelancer',
				EmailBouncedDate=now.replace(tzinfo=pytz.utc))
		contact.save()
		try:
			self.assertEqual(refresh(contact).EmailBouncedDate, now)
		finally:
			contact.delete()
开发者ID:jacobwegner,项目名称:django-salesforce,代码行数:14,代码来源:test_integration.py

示例6: test_not_null_related

	def test_not_null_related(self):
		"""
		Verify conditions `isnull` for foreign keys: filter(Account=None)
		filter(Account__isnull=True) and nested in Q(...) | Q(...).
		"""
		test_contact = Contact(first_name='sf_test', last_name='my')
		test_contact.save()
		try:
			contacts = Contact.objects.filter(Q(account__isnull=True) |
					Q(account=None), account=None, account__isnull=True,
					first_name='sf_test')
			self.assertEqual(len(contacts), 1)
		finally:
			test_contact.delete()
开发者ID:cloudanswers,项目名称:django-salesforce,代码行数:14,代码来源:test_integration.py

示例7: test_date_comparison

	def test_date_comparison(self):
		"""
		Test that date comparisons work properly.
		"""
		today = round_datetime_utc(datetime.datetime(2013, 8, 27))
		yesterday = today - datetime.timedelta(days=1)
		tomorrow = today + datetime.timedelta(days=1)
		contact = Contact(FirstName='sf_test', LastName='date',
				EmailBouncedDate=today)
		contact.save()
		try:
			contacts1 = Contact.objects.filter(EmailBouncedDate__gt=yesterday)
			self.assertEqual(len(contacts1), 1)
			contacts2 = Contact.objects.filter(EmailBouncedDate__gt=tomorrow)
			self.assertEqual(len(contacts2), 0)
		finally:
			contact.delete()
开发者ID:jacobwegner,项目名称:django-salesforce,代码行数:17,代码来源:test_integration.py

示例8: test_date_comparison

 def test_date_comparison(self):
     """Test that date comparisons work properly.
     """
     today = datetime.datetime(2013, 8, 27)
     if settings.USE_TZ:
         today = timezone.make_aware(today, pytz.utc)
     yesterday = today - datetime.timedelta(days=1)
     tomorrow = today + datetime.timedelta(days=1)
     contact = Contact(first_name='sf_test' + uid, last_name='date',
             email_bounced_date=today)
     contact.save()
     try:
         contacts1 = Contact.objects.filter(email_bounced_date__gt=yesterday, first_name='sf_test' + uid)
         self.assertEqual(len(contacts1), 1)
         contacts2 = Contact.objects.filter(email_bounced_date__gt=tomorrow, first_name='sf_test' + uid)
         self.assertEqual(len(contacts2), 0)
     finally:
         contact.delete()
开发者ID:KristianOellegaard,项目名称:django-salesforce,代码行数:18,代码来源:test_integration.py

示例9: test_double_delete

	def test_double_delete(self):
		"""
		Test that repeated delete of the same object is ignored the same way
		like "DELETE FROM Contact WHERE Id='deleted yet'" would do.
		"""
		contact = Contact(last_name='sf_test',
				owner=User.objects.get(Username=current_user))
		contact.save()
		contact_id = contact.pk
		Contact(pk=contact_id).delete()
		# Id of a deleted object or a too small valid Id shouldn't raise
		Contact(pk=contact_id).delete()
		# Simulate the same with obsoleted oauth session
		# It is not possible to use salesforce.auth.expire_token() to simulate
		# expiration because it forces reauhentication before the next request
		salesforce.auth.oauth_data[sf_alias]['access_token'] = '* something invalid *'
		Contact(pk=contact_id).delete()
		# Id of completely deleted item or fake but valid item.
		Contact(pk='003000000000000AAA').delete()
开发者ID:cloudanswers,项目名称:django-salesforce,代码行数:19,代码来源:test_integration.py

示例10: test_expired_auth_id

	def test_expired_auth_id(self):
		"""
		Test the code for expired auth ID for multiple SF databases.
		No similar test exists for a single db.
		"""
		self.assertGreaterEqual(len(sf_databases), 1)
		objects = []
		for db in sf_databases:
			c = Contact(last_name='sf_test %s' % db)
			c.save(using=db)
			objects.append(c)
		try:
			# simulate that a request with invalid/expired auth ID re-authenticates
			# and succeeds.
			for db in sf_databases:
				salesforce.auth.oauth_data[db]['access_token'] += 'simulated invalid/expired'
			for x in objects:
				self.assertTrue(refresh(x))
		finally:
			for x in objects:
				x.delete()
开发者ID:cloudanswers,项目名称:django-salesforce,代码行数:21,代码来源:test_integration.py

示例11: test_update_date

	def test_update_date(self):
		"""
		Test updating a date.
		"""
		now = timezone.now().replace(microsecond=0)
		contact = Contact(first_name = 'sf_test', last_name='my')
		contact.save()
		contact = refresh(contact)
		try:
			contact.email_bounced_date = now
			contact.save()
			self.assertEqual(refresh(contact).email_bounced_date, now)
		finally:
			contact.delete()
开发者ID:cloudanswers,项目名称:django-salesforce,代码行数:14,代码来源:test_integration.py

示例12: test_multiple_sf_databases

	def test_multiple_sf_databases(self):
		"""
		Test a connection to two sf databases with the same user.
		(with sandboxes of the same organization)
		"""
		other_db = [db for db in sf_databases if db != sf_alias][0]
		c1 = Contact(last_name='sf_test 1')
		c2 = Contact(last_name='sf_test 2')
		c1.save()
		c2.save(using=other_db)
		try:
			user1 = refresh(c1).owner
			user2 = refresh(c2).owner
			username1 = user1.Username
			username2 = user2.Username
			# Verify different, but similar usernames like usual in sandboxes
			self.assertNotEqual(user1._state.db, user2._state.db)
			self.assertNotEqual(username1, username2)
			self.assertEqual(username1.split('@')[0], username2.split('@')[0])
		finally:
			c1.delete()
			c2.delete()
开发者ID:cloudanswers,项目名称:django-salesforce,代码行数:22,代码来源:test_integration.py

示例13: test_generic_type_field

    def test_generic_type_field(self):
        """Test that a generic foreign key can be filtered by type name and
        the type name can be referenced.
        """
        test_contact = Contact(first_name='sf_test', last_name='my')
        test_contact.save()
        note_1 = Note(title='note for Lead', parent_id=self.test_lead.pk)
        note_2 = Note(title='note for Contact', parent_id=test_contact.pk)
        note_1.save()
        note_2.save()
        try:
            self.assertEqual(Note.objects.filter(parent_type='Contact')[0].parent_type, 'Contact')
            self.assertEqual(Note.objects.filter(parent_type='Lead')[0].parent_type, 'Lead')

            note = Note.objects.filter(parent_type='Contact')[0]
            parent_model = getattr(salesforce.testrunner.example.models, note.parent_type)
            parent_object = parent_model.objects.get(pk=note.parent_id)
            self.assertEqual(parent_object.pk, note.parent_id)
        finally:
            note_1.delete()
            note_2.delete()
            test_contact.delete()
开发者ID:KristianOellegaard,项目名称:django-salesforce,代码行数:22,代码来源:test_integration.py

示例14: test_multiple_sf_databases

 def test_multiple_sf_databases(self):
     """Test a connection to two sf sandboxes of the same organization.
     """
     other_db = [db for db in sf_databases if db != sf_alias][0]
     c1 = Contact(last_name='sf_test 1')
     c2 = Contact(last_name='sf_test 2')
     c1.save()
     c2.save(using=other_db)
     try:
         user1 = refresh(c1).owner
         user2 = refresh(c2).owner
         username1 = user1.Username
         username2 = user2.Username
         # Verify different usernames, like it is usual in sandboxes
         self.assertNotEqual(user1._state.db, user2._state.db)
         self.assertNotEqual(username1, username2)
         expected_user2 = connections[other_db].settings_dict['USER']
         self.assertEqual(username1, current_user)
         self.assertEqual(username2, expected_user2)
     finally:
         c1.delete()
         c2.delete()
开发者ID:KristianOellegaard,项目名称:django-salesforce,代码行数:22,代码来源:test_integration.py

示例15: test_default_specified_by_sf

	def test_default_specified_by_sf(self):
		"""
		Verify that an object with a field with default value specified by some
		Salesforce code can be inserted. (The default is used only for a field
		unspecified in SF REST API, but not for None or any similar value.
		It was a pain for some unimportant foreign keys that don't accept null.
		"""
		# Verify a smart default is used.
		contact = Contact(FirstName = 'sf_test', LastName='my')
		contact.save()
		try:
			self.assertEqual(refresh(contact).Owner.Username, current_user)
		finally:
			contact.delete()
		# Verify that an explicit value is possible for this field.
		other_user_obj = User.objects.exclude(Username=current_user)[0]
		contact = Contact(FirstName = 'sf_test', LastName='your',
				Owner=other_user_obj)
		contact.save()
		try:
			self.assertEqual(
					refresh(contact).Owner.Username, other_user_obj.Username)
		finally:
			contact.delete()
开发者ID:jacobwegner,项目名称:django-salesforce,代码行数:24,代码来源:test_integration.py


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