Пример #1
0
	def setUp(self):
		# authorize to xx/example parliament
		vpapi.parliament('xx/example')
		vpapi.authorize('scraper', 'secret')

		# ensure exactly one person with the sample value
		result = vpapi.get('people', where={'identifiers': {'$elemMatch': self.sample_identifier}})
		if result['_items']:
			vpapi.delete('people/%s' % result['_items'][0]['id'])
		result = vpapi.post('people', self.sample_person)
		self.person_id = result['id']
		# and no person with specified id
		result = vpapi.get('people', where={'id': self.person_with_id['id']})
		if result['_items']:
			vpapi.delete('people/%s' % self.person_with_id['id'])

		# ensure exactly one organization with the sample value
		result = vpapi.get('organizations', where={'name': 'ABC, Inc.'})
		if result['_items']:
			vpapi.delete('organizations/%s' % result['_items'][0]['id'])
		result = vpapi.post('organizations', self.sample_organization)
		self.organization_id = result['id']

		# ensure exactly one membership with the sample value
		result = vpapi.get('memberships', where={'label': 'Kitchen assistant at ABC, Inc.'})
		if result['_items']:
			vpapi.delete('memberships/%s' % result['_items'][0]['id'])
		self.sample_membership['person_id'] = self.person_id
		self.sample_membership['organization_id'] = self.organization_id
		result = vpapi.post('memberships', self.sample_membership)
		self.membership_id = result['id']
Пример #2
0
	def test_id_field(self):
		"""entity should use `id` instead of `_id`"""
		result = vpapi.get('people/%s' % self.person_id)
		self.assertIn('id', result)
		self.assertNotIn('_id', result)
		result = vpapi.post('people', self.person_with_id)
		self.assertIn('id', result)
		self.assertNotIn('_id', result)
		self.assertEqual(result['id'], self.person_with_id['id'])
		result = vpapi.patch('people/%s' % result['id'], {'name': 'Baggins, Bilbo'})
		self.assertEqual(result['id'], self.person_with_id['id'])
		vpapi.delete('people/%s' % self.person_with_id['id'])