def test_assemble_current_state(self, objects_mock):
        txs_mock = objects_mock.TransactionCollection
        transactions = [
            (1, '1', 'task1'), (2, '1', 'task2'), (2, '2', 'task2')
        ]
        txs_mock.get_successful_transactions_per_task.return_value = \
            transactions

        objects_mock.Transaction.get_deployment_info.side_effect = [
            {'common': {'key1': 'value1'},
             'nodes': {'1': {'key11': 'value11'}}},
            {'common': {'key2': 'value2'},
             'nodes': {'1': {'key21': 'value21'}, '2': {'key22': 'value22'}}},
        ]

        current_state = manager._get_current_state(
            self.cluster, self.nodes, self.tasks
        )
        expected_state = {
            'task1': {
                'common': {'key1': 'value1'},
                'nodes': {'1': {'key11': 'value11'}}
            },
            'task2': {
                'common': {'key2': 'value2'},
                'nodes': {
                    '1': {'key21': 'value21'},
                    '2': {'key22': 'value22'}
                },
            }
        }

        self.assertEqual(expected_state, current_state)
Ejemplo n.º 2
0
    def test_assemble_current_state(self, objects_mock):
        txs_mock = objects_mock.TransactionCollection
        transactions = [
            (1, '1', 'task1'), (2, '1', 'task2'), (2, '2', 'task2')
        ]
        txs_mock.get_successful_transactions_per_task.return_value = \
            transactions

        objects_mock.Transaction.get_deployment_info.side_effect = [
            {'common': {'key1': 'value1'},
             'nodes': {'1': {'key11': 'value11'}}},
            {'common': {'key2': 'value2'},
             'nodes': {'1': {'key21': 'value21'}, '2': {'key22': 'value22'}}},
        ]

        current_state = manager._get_current_state(
            self.cluster, self.nodes, self.tasks
        )
        expected_state = {
            'task1': {
                'common': {'key1': 'value1'},
                'nodes': {'1': {'key11': 'value11'}}
            },
            'task2': {
                'common': {'key2': 'value2'},
                'nodes': {
                    '1': {'key21': 'value21'},
                    '2': {'key22': 'value22'}
                },
            }
        }

        self.assertEqual(expected_state, current_state)
Ejemplo n.º 3
0
 def test_get_current_state_if_there_is_no_deployment(self, objects_mock):
     txs_mock = objects_mock.TransactionCollection
     txs_mock.get_successful_transactions_per_task.return_value = []
     nodes = {'1': self.nodes[0], '2': self.nodes[1], 'master': None}
     current_state = manager._get_current_state(self.cluster, self.nodes,
                                                self.tasks)
     self.assertEqual({}, current_state)
     txs_mock.get_successful_transactions_per_task.assert_called_once_with(
         self.cluster.id, ['task1', 'task2'], nodes)
 def test_get_current_state_if_there_is_no_deployment(self, objects_mock):
     txs_mock = objects_mock.TransactionCollection
     txs_mock.get_successful_transactions_per_task.return_value = []
     nodes = {'1': self.nodes[0], '2': self.nodes[1], 'master': None}
     current_state = manager._get_current_state(
         self.cluster, self.nodes, self.tasks
     )
     self.assertEqual({}, current_state)
     txs_mock.get_successful_transactions_per_task.assert_called_once_with(
         self.cluster.id, ['task1', 'task2'], nodes
     )
 def test_get_current_state_with_force(self):
     current_state = manager._get_current_state(
         self.cluster, self.nodes, self.tasks, force=True
     )
     self.assertEqual({}, current_state)
Ejemplo n.º 6
0
 def test_get_current_state_with_force(self):
     current_state = manager._get_current_state(self.cluster,
                                                self.nodes,
                                                self.tasks,
                                                force=True)
     self.assertEqual({}, current_state)