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']
def setUp(self): vpapi.parliament('xx/example') vpapi.deauthorize()