Esempio n. 1
0
    def test_state_computation(self):
        instance = {'vm_state': mock.sentinel.vm_state,
                    'task_state': mock.sentinel.task_state}
        states = notifications._compute_states_payload(instance)
        self.assertEqual(mock.sentinel.vm_state, states['state'])
        self.assertEqual(mock.sentinel.vm_state, states['old_state'])
        self.assertEqual(mock.sentinel.task_state, states['old_task_state'])
        self.assertEqual(mock.sentinel.task_state, states['new_task_state'])

        states = notifications._compute_states_payload(
            instance,
            old_vm_state=mock.sentinel.old_vm_state,
        )
        self.assertEqual(mock.sentinel.vm_state, states['state'])
        self.assertEqual(mock.sentinel.old_vm_state, states['old_state'])
        self.assertEqual(mock.sentinel.task_state, states['old_task_state'])
        self.assertEqual(mock.sentinel.task_state, states['new_task_state'])

        states = notifications._compute_states_payload(
            instance,
            old_vm_state=mock.sentinel.old_vm_state,
            old_task_state=mock.sentinel.old_task_state,
            new_vm_state=mock.sentinel.new_vm_state,
            new_task_state=mock.sentinel.new_task_state,
        )

        self.assertEqual(mock.sentinel.new_vm_state, states['state'])
        self.assertEqual(mock.sentinel.old_vm_state, states['old_state'])
        self.assertEqual(mock.sentinel.old_task_state,
                         states['old_task_state'])
        self.assertEqual(mock.sentinel.new_task_state,
                         states['new_task_state'])
Esempio n. 2
0
    def test_state_computation(self):
        instance = {"vm_state": mock.sentinel.vm_state, "task_state": mock.sentinel.task_state}
        states = notifications._compute_states_payload(instance)
        self.assertEqual(mock.sentinel.vm_state, states["state"])
        self.assertEqual(mock.sentinel.vm_state, states["old_state"])
        self.assertEqual(mock.sentinel.task_state, states["old_task_state"])
        self.assertEqual(mock.sentinel.task_state, states["new_task_state"])

        states = notifications._compute_states_payload(instance, old_vm_state=mock.sentinel.old_vm_state)
        self.assertEqual(mock.sentinel.vm_state, states["state"])
        self.assertEqual(mock.sentinel.old_vm_state, states["old_state"])
        self.assertEqual(mock.sentinel.task_state, states["old_task_state"])
        self.assertEqual(mock.sentinel.task_state, states["new_task_state"])

        states = notifications._compute_states_payload(
            instance,
            old_vm_state=mock.sentinel.old_vm_state,
            old_task_state=mock.sentinel.old_task_state,
            new_vm_state=mock.sentinel.new_vm_state,
            new_task_state=mock.sentinel.new_task_state,
        )

        self.assertEqual(mock.sentinel.new_vm_state, states["state"])
        self.assertEqual(mock.sentinel.old_vm_state, states["old_state"])
        self.assertEqual(mock.sentinel.old_task_state, states["old_task_state"])
        self.assertEqual(mock.sentinel.new_task_state, states["new_task_state"])