Exemplo n.º 1
0
    def test_equal_unset_raw_property_actions_are_equal(self):
        """Verify that equal unset raw property actions are equal."""

        action1 = actions.UnsetRawPropertyAction('id', 'uuid', None, 'prop')
        action2 = actions.UnsetRawPropertyAction('id', 'uuid', None, 'prop')
        self.assertEqual(action1, action2)

        action1 = actions.UnsetRawPropertyAction('id', None, 'action', 'prop')
        action2 = actions.UnsetRawPropertyAction('id', None, 'action', 'prop')
        self.assertEqual(action1, action2)
Exemplo n.º 2
0
    def test_constructor_sets_action_id_uuid_and_property(self):
        """Verify that the constructor sets the action id, uuid, property."""

        action = actions.UnsetRawPropertyAction(
            'foo', '7b6b8292-7b01-4cea-87c9-6ad3b771314c', None, 'avatar')
        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')

        action = actions.UnsetRawPropertyAction(
            'bar', None, 'other action', 'patch')
        self.assertEqual(action.id, 'bar')
        self.assertEqual(action.uuid, None)
        self.assertEqual(action.action_id, 'other action')
        self.assertEqual(action.property, 'patch')
Exemplo n.º 3
0
    def _parse_unset_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 not phase.errors:
            uuid = obj.get('uuid', None)
            action_id = obj.get('action', None)
            action = actions.UnsetRawPropertyAction(data.get('id', None), uuid,
                                                    action_id, prop)
            return action, index + 1
Exemplo n.º 4
0
    def test_different_unset_raw_property_actions_are_different(self):
        """Verify that different unset raw property actions are different."""

        action1 = actions.UnsetRawPropertyAction('id', 'uuid', None, 'prop1')
        action2 = actions.UnsetRawPropertyAction('id', 'uuid', None, 'prop2')
        self.assertFalse(action1 == action2)

        action1 = actions.UnsetRawPropertyAction('id', 'uuid1', None, 'prop')
        action2 = actions.UnsetRawPropertyAction('id', 'uuid2', None, 'prop')
        self.assertFalse(action1 == action2)

        action1 = actions.UnsetRawPropertyAction('id1', 'uuid', None, 'prop')
        action2 = actions.UnsetRawPropertyAction('id2', 'uuid', None, 'prop')
        self.assertFalse(action1 == action2)

        action1 = actions.UnsetRawPropertyAction('id', None, 'action1', 'prop')
        action2 = actions.UnsetRawPropertyAction('id', None, 'action2', 'prop')
        self.assertFalse(action1 == action2)
Exemplo n.º 5
0
    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)