

def test_node_instances2(self):
    dsl_path = resource('dsl/node_instances.yaml')
    blueprint_id1 = 'blueprint-{0}'.format(str(uuid.uuid4()))
    blueprint_id2 = 'blueprint-{0}'.format(str(uuid.uuid4()))
    deployment_id1 = 'deployment-{0}'.format(str(uuid.uuid4()))
    deployment_id2 = 'deployment-{0}'.format(str(uuid.uuid4()))
    self._create_basic_deployment(dsl_path, blueprint_id1, deployment_id1)
    self._create_basic_deployment(dsl_path, blueprint_id2, deployment_id2)
    all_instances = self.client.node_instances.list()
    dep1_instances = self.client.node_instances.list(deployment_id1)
    dep2_instances = self.client.node_instances.list(deployment_id2)
    dep1_n1_instances = self.client.node_instances.list(deployment_id1, 'node1')
    dep1_n2_instances = self.client.node_instances.list(deployment_id1, 'node2')
    dep2_n1_instances = self.client.node_instances.list(deployment_id2, 'node1')
    dep2_n2_instances = self.client.node_instances.list(deployment_id2, 'node2')
    self.assertEqual(8, len(all_instances))

    def assert_dep(expected_len, dep, instances):
        self.assertEqual(expected_len, len(instances))
        for instance in instances:
            self.assertEqual(instance.deployment_id, dep)
    assert_dep(4, deployment_id1, dep1_instances)
    assert_dep(4, deployment_id2, dep2_instances)

    def assert_dep_and_node(expected_len, dep, node_id, instances):
        self.assertEqual(expected_len, len(instances))
        for instance in instances:
            self.assertEqual(instance.deployment_id, dep)
            self.assertEqual(instance.node_id, node_id)
    assert_dep_and_node(2, deployment_id1, 'node1', dep1_n1_instances)
    assert_dep_and_node(2, deployment_id1, 'node2', dep1_n2_instances)
    assert_dep_and_node(2, deployment_id2, 'node1', dep2_n1_instances)
    assert_dep_and_node(2, deployment_id2, 'node2', dep2_n2_instances)

dataset/ETHPy150Open cloudify-cosmo/cloudify-manager/tests/workflow_tests/test_rest_api.py RestAPITest.test_node_instances2/original