def test_get_transaction_instances_notransaction_field(self): _ctx = self._gen_ctx() client = self._gen_rest_client() instance_a = Mock() instance_a.id = 'a_id' instance_a.node_id = 'a_type' instance_a.runtime_properties = { 'name': 'value' } client.node_instances.list = Mock(return_value=[instance_a]) with patch( "cloudify_scalelist.workflows.get_rest_client", Mock(return_value=client) ): self.assertEqual( workflows._get_transaction_instances( ctx=_ctx, scale_transaction_field=None, scale_node_name=None, scale_node_field="name", scale_node_field_values=["value"] ), ({'a_type': ['a_id']}, ['a_id']) ) client.node_instances.list.assert_called_with( _include=['runtime_properties', 'node_id', 'id'], deployment_id='deployment_id', node_id=None)
def test_get_transaction_instances(self): _ctx = self._gen_ctx() client = self._gen_rest_client() with patch( "cloudify_scalelist.workflows.get_rest_client", Mock(return_value=client) ): self.assertEqual( workflows._get_transaction_instances( ctx=_ctx, scale_transaction_field='_transaction', scale_node_name="a", scale_node_field="name", scale_node_field_values=["value"] ), ({ 'a_type': ['a_id'], 'b_type': ['b_id'], }, ['a_id', 'b_id']) )
def test_get_transaction_instances_nosuch(self): _ctx = self._gen_ctx() client = self._gen_rest_client() client.node_instances.list = Mock(return_value=[]) with patch( "cloudify_scalelist.workflows.get_rest_client", Mock(return_value=client) ): self.assertEqual( workflows._get_transaction_instances( ctx=_ctx, scale_transaction_field='_transaction', scale_node_name="node", scale_node_field="name", scale_node_field_values=["value"] ), ({}, []) ) client.node_instances.list.assert_called_with( _include=['runtime_properties', 'node_id', 'id'], deployment_id='deployment_id', node_id='node')