def test_fix_on_put(self): """if parameter `effective_date` in URL query string has value `fix`, the change should not be logged into the `changes` field""" modified = self.sample_person.copy() modified['email'] = '*****@*****.**' vpapi.put( 'people/%s' % self.person_id, modified, effective_date='fix') result = vpapi.get('people/%s' % self.person_id) self.assertNotIn('changes', result)
def test_changes_on_put_with_effective_date(self): """if parameter `effective_date` is sent in URL query string then the change should be assumed at the given date and not today""" modified = self.sample_person.copy() modified['email'] = '*****@*****.**' vpapi.put( 'people/%s' % self.person_id, modified, effective_date='2000-01-01') expected_change = { 'property': 'email', 'value': '*****@*****.**', 'end_date': '1999-12-31' } result = vpapi.get('people/%s' % self.person_id) self.assertIn(expected_change, result.get('changes'))
def test_changes_on_put(self): """changed value in any of the fields with tracked history should be logged into the `changes` field with `end_date` equal to yesterday. Explicitly sent changes should be merged with the automatically managed ones.""" modified = self.sample_person.copy() modified['email'] = '*****@*****.**' explicit_change = { 'property': 'abc', 'value': 'xyz' } modified['changes'] = [explicit_change] vpapi.put( 'people/%s' % self.person_id, modified) expected_change = { 'property': 'email', 'value': '*****@*****.**', 'end_date': datestring_add(date.today().isoformat(), -1) } result = vpapi.get('people/%s' % self.person_id) self.assertIn('changes', result) self.assertEqual(len(result['changes']), 2) self.assertEqual(expected_change, result['changes'][0]) self.assertEqual(explicit_change, result['changes'][1])