def test_equal_update_raw_property_actions_are_equal(self): """Verify that equal update raw property actions are equal.""" action1 = actions.UpdateRawPropertyAction( 'id', 'uuid', None, 'p', 't', 'd') action2 = actions.UpdateRawPropertyAction( 'id', 'uuid', None, 'p', 't', 'd') self.assertEqual(action1, action2) action1 = actions.UpdateRawPropertyAction( 'id', None, 'action', 'p', 't', 'd') action2 = actions.UpdateRawPropertyAction( 'id', None, 'action', 'p', 't', 'd') self.assertEqual(action1, action2)
def _parse_update_raw_property_action(self, phase, index, part, parts, data): if 'object' not in data: phase.error(ActionObjectUndefinedError(phase, part)) else: obj = self._load_object_or_action_reference(phase, part, data) prop = self._load_raw_property_name(phase, part, data) if index >= len(parts) - 2: phase.error(ActionRawPropertyDataMissingError(phase, part)) if not phase.errors: raw_data_part = parts[index + 1] if 'Content-Type' not in raw_data_part: phase.error( ActionRawPropertyContentTypeUndefinedError(phase, part)) if not phase.errors: uuid = obj.get('uuid', None) action_id = obj.get('action', None) content_type = raw_data_part['Content-Type'] raw_data = raw_data_part.get_payload() action = actions.UpdateRawPropertyAction(data.get('id', None), uuid, action_id, prop, content_type, raw_data) return action, index + 2
def test_constructor_sets_action_id_uuid_property_etc(self): """Verify that the constructor sets the action id, uuid etc.""" action = actions.UpdateRawPropertyAction( 'foo', '7b6b8292-7b01-4cea-87c9-6ad3b771314c', None, 'avatar', 'image/png', 'image data') self.assertEqual(action.id, 'foo') self.assertEqual(action.uuid, '7b6b8292-7b01-4cea-87c9-6ad3b771314c') self.assertEqual(action.action_id, None) self.assertEqual(action.property, 'avatar') self.assertEqual(action.content_type, 'image/png') self.assertEqual(action.data, 'image data') action = actions.UpdateRawPropertyAction( 'bar', None, 'action ID', 'patch', 'text/plain', 'patch content') self.assertEqual(action.id, 'bar') self.assertEqual(action.uuid, None) self.assertEqual(action.action_id, 'action ID') self.assertEqual(action.property, 'patch') self.assertEqual(action.content_type, 'text/plain') self.assertEqual(action.data, 'patch content')
def test_equality_operator_is_false_if_action_classes_dont_match(self): """Verify that the equality operator is false if classes differ.""" acts = [ actions.BeginAction('foo', 'source'), actions.CommitAction( 'foo', 'target', 'author', 'author date', 'committer', 'committer date', 'message'), actions.CreateAction('foo', 'klass', []), actions.DeleteAction('foo', 'uuid', None), actions.UpdateAction('foo', 'uuid', None, []), actions.UpdateRawPropertyAction( 'foo', 'uuid', None, 'p', 't', 'data'), actions.UnsetRawPropertyAction('foo', 'uuid', None, 'prop'), ] for action1, action2 in itertools.permutations(acts, 2): self.assertFalse(action1 == action2)
def test_different_update_raw_property_actions_are_different(self): """Verify that different update raw property actions are different.""" action1 = actions.UpdateRawPropertyAction( 'id', 'uuid', None, 'property', 'content-type', 'data1') action2 = actions.UpdateRawPropertyAction( 'id', 'uuid', None, 'property', 'content-type', 'data2') self.assertFalse(action1 == action2) action1 = actions.UpdateRawPropertyAction( 'id', 'uuid', None, 'property', 'content-type1', 'data') action2 = actions.UpdateRawPropertyAction( 'id', 'uuid', None, 'property', 'content-type2', 'data') self.assertFalse(action1 == action2) action1 = actions.UpdateRawPropertyAction( 'id', 'uuid', None, 'property1', 'content-type', 'data') action2 = actions.UpdateRawPropertyAction( 'id', 'uuid', None, 'property2', 'content-type', 'data') self.assertFalse(action1 == action2) action1 = actions.UpdateRawPropertyAction( 'id', 'uuid1', None, 'property', 'content-type', 'data') action2 = actions.UpdateRawPropertyAction( 'id', 'uuid2', None, 'property', 'content-type', 'data') self.assertFalse(action1 == action2) action1 = actions.UpdateRawPropertyAction( 'id1', 'uuid', None, 'property', 'content-type', 'data') action2 = actions.UpdateRawPropertyAction( 'id2', 'uuid', None, 'property', 'content-type', 'data') self.assertFalse(action1 == action2) action1 = actions.UpdateRawPropertyAction( 'id', None, 'action1', 'property', 'content-type', 'data') action2 = actions.UpdateRawPropertyAction( 'id', None, 'action2', 'property', 'content-type', 'data') self.assertFalse(action1 == action2)