Exemplo n.º 1
0
    def test_update_organization(self):
        """@Test: Update environment organization with new value

        @Feature: Environment - Update

        @Assert: Environment Update finished and new organization is assigned

        """
        try:
            old_org = make_org()
            new_org = make_org()
            env_name = gen_string('alphanumeric', 10)
            make_environment({
                'name': env_name,
                'organization-ids': old_org['id'],
            })
        except CLIFactoryError as err:
            self.fail(err)
        result = Environment.info({'name': env_name})
        self.assertIn(old_org['name'], result.stdout['organizations'])

        result = Environment.update({
            'name': env_name,
            'organization-ids': new_org['id']
        })
        self.assertEqual(result.return_code, 0)

        result = Environment.info({'name': env_name})
        self.assertIn(new_org['name'], result.stdout['organizations'])
        self.assertNotIn(old_org['name'], result.stdout['organizations'])
Exemplo n.º 2
0
def test_positive_CRUD_with_attributes(module_org, module_locs):
    """Check if Environment with attributes can be created, updated and removed

    :id: d2187971-86b2-40c9-a93c-66f37691ae2b

    :BZ: 1337947

    :expectedresults:
        1. Environment is created and has parameters assigned
        2. Environment can be listed by parameters
        3. Environment can be updated
        4. Environment can be removed

    :CaseImportance: Critical
    """
    # Create with attributes
    env_name = gen_string('alpha')
    environment = make_environment(
        {'location-ids': module_locs[0].id, 'organization-ids': module_org.id, 'name': env_name}
    )
    assert module_locs[0].name in environment['locations']
    assert module_org.name in environment['organizations']
    assert env_name == environment['name']

    # List by name
    result = Environment.list({'search': f'name={env_name}'})
    assert len(result) == 1
    assert result[0]['name'] == env_name
    # List by org loc id
    results = Environment.list({'organization-id': module_org.id, 'location-id': module_locs[0].id})
    assert env_name in [res['name'] for res in results]
    # List by org loc name
    results = Environment.list({'organization': module_org.name, 'location': module_locs[0].name})
    assert env_name in [res['name'] for res in results]

    # Update org and loc
    new_org = entities.Organization().create()
    Environment.update(
        {
            'location-ids': module_locs[1].id,
            'organization-ids': new_org.id,
            'name': environment['name'],
        }
    )
    env_info = Environment.info({'name': environment['name']})
    assert module_locs[1].name in env_info['locations']
    assert module_locs[0].name not in env_info['locations']
    assert new_org.name in env_info['organizations']
    assert module_org.name not in env_info['organizations']
    # Update name
    new_env_name = gen_string('alpha')
    Environment.update({'id': environment['id'], 'new-name': new_env_name})
    env_info = Environment.info({'id': environment['id']})
    assert env_info['name'] == new_env_name

    # Delete
    Environment.delete({'id': environment['id']})
    with pytest.raises(CLIReturnCodeError):
        Environment.info({'id': environment['id']})
Exemplo n.º 3
0
    def test_positive_delete_by_name(self):
        """Delete the environment by its name.

        @id: 48765173-6086-4b91-9da7-594135f68751

        @Assert: Environment is deleted.
        """
        environment = make_environment()
        Environment.delete({'name': environment['name']})
        with self.assertRaises(CLIReturnCodeError):
            Environment.info({'name': environment['name']})
Exemplo n.º 4
0
    def test_positive_delete_by_name(self):
        """Delete the environment by its name.

        @Feature: Environment

        @Assert: Environment is deleted.
        """
        environment = make_environment()
        Environment.delete({'name': environment['name']})
        with self.assertRaises(CLIReturnCodeError):
            Environment.info({'name': environment['name']})
Exemplo n.º 5
0
    def test_positive_delete_by_name(self):
        """Delete the environment by its name.

        @id: 48765173-6086-4b91-9da7-594135f68751

        @Assert: Environment is deleted.
        """
        environment = make_environment()
        Environment.delete({'name': environment['name']})
        with self.assertRaises(CLIReturnCodeError):
            Environment.info({'name': environment['name']})
Exemplo n.º 6
0
    def test_positive_delete_by_name(self):
        """Delete the environment by its name.

        @Feature: Environment

        @Assert: Environment is deleted.
        """
        environment = make_environment()
        Environment.delete({'name': environment['name']})
        with self.assertRaises(CLIReturnCodeError):
            Environment.info({'name': environment['name']})
Exemplo n.º 7
0
    def test_positive_delete_by_name(self):
        """Delete the environment by its name.

        :id: 48765173-6086-4b91-9da7-594135f68751

        :expectedresults: Environment is deleted.

        :CaseImportance: Critical
        """
        environment = make_environment()
        Environment.delete({'name': environment['name']})
        with self.assertRaises(CLIReturnCodeError):
            Environment.info({'name': environment['name']})
Exemplo n.º 8
0
    def test_positive_delete_by_name(self):
        """Delete the environment by its name.

        :id: 48765173-6086-4b91-9da7-594135f68751

        :expectedresults: Environment is deleted.

        :CaseImportance: Critical
        """
        environment = make_environment()
        Environment.delete({'name': environment['name']})
        with self.assertRaises(CLIReturnCodeError):
            Environment.info({'name': environment['name']})
Exemplo n.º 9
0
    def test_positive_delete_by_id(self):
        """Create Environment with valid values then delete it
        by ID

        @feature: Environment

        @assert: Environment is deleted
        """
        for name in valid_environments_list():
            with self.subTest(name):
                environment = make_environment({'name': name})
                Environment.delete({'id': environment['id']})
                with self.assertRaises(CLIReturnCodeError):
                    Environment.info({'id': environment['id']})
Exemplo n.º 10
0
    def test_positive_delete_by_id(self):
        """Create Environment with valid values then delete it
        by ID

        @feature: Environment

        @assert: Environment is deleted
        """
        for name in valid_environments_list():
            with self.subTest(name):
                environment = make_environment({'name': name})
                Environment.delete({'id': environment['id']})
                with self.assertRaises(CLIReturnCodeError):
                    Environment.info({'id': environment['id']})
Exemplo n.º 11
0
    def test_positive_update_org(self):
        """Update environment organization with new value

        :id: 2c40caf9-95a0-4b87-bd97-0a4448746052

        :expectedresults: Environment Update finished and new organization is
            assigned


        :CaseImportance: Critical
        """
        old_org = make_org()
        new_org = make_org()
        env_name = gen_string('alphanumeric', 10)
        env = make_environment({
            'name': env_name,
            'organization-ids': old_org['id'],
        })
        self.assertIn(old_org['name'], env['organizations'])
        Environment.update({
            'name': env_name,
            'organization-ids': new_org['id']
        })
        env = Environment.info({'name': env_name})
        self.assertIn(new_org['name'], env['organizations'])
        self.assertNotIn(old_org['name'], env['organizations'])
Exemplo n.º 12
0
 def setUpClass(cls):
     """Import some parametrized puppet classes. This is required to make
     sure that we have smart class variable available.
     Read all available smart class parameters for imported puppet class to
     be able to work with unique entity for each specific test. Raise an
     exception and skip all tests in case not enough parameters returned.
     """
     super(SmartClassParametersTestCase, cls).setUpClass()
     cls.host_name = settings.server.hostname
     ssh.command('puppet module install --force puppetlabs/ntp')
     cls.env = Environment.info({u'name': 'production'})
     Proxy.importclasses({
         u'environment': cls.env['name'],
         u'name': cls.host_name,
     })
     cls.puppet = Puppet.info({u'name': 'ntp'})
     sc_params_list = SmartClassParameter.list({
         'environment':
         cls.env['name'],
         'search':
         'puppetclass=ntp'
     })
     if len(sc_params_list) < 45:
         raise RuntimeError('There are not enough smart class parameters to'
                            ' work with in provided puppet class')
     cls.sc_params_ids_list = [
         sc_param['id'] for sc_param in sc_params_list
     ]
Exemplo n.º 13
0
    def test_positive_delete_by_id(self):
        """Create Environment with valid values then delete it
        by ID

        :id: e25af73a-d4ef-4287-83bf-625337d91392

        :expectedresults: Environment is deleted

        :CaseImportance: Critical
        """
        for name in valid_environments_list():
            with self.subTest(name):
                environment = make_environment({'name': name})
                Environment.delete({'id': environment['id']})
                with self.assertRaises(CLIReturnCodeError):
                    Environment.info({'id': environment['id']})
Exemplo n.º 14
0
    def test_update_negative(self, test_data):
        """@Test: Update the environment with invalid values

        @Feature: Environment - Update

        @Assert: Environment is not updated

        """
        orig_dict, updates_dict = test_data
        try:
            env = make_environment({'name': orig_dict['name']})
        except CLIFactoryError as err:
            self.fail(err)

        result = Environment.update({
            'name': orig_dict['name'],
            'new-name': updates_dict['new-name']
        })
        self.assertNotEqual(result.return_code, 0)
        self.assertNotEqual(len(result.stderr), 0)

        result = Environment.info({'id': env['id']})
        # Verify that value is not updated and left as it was before update
        # command was executed
        self.assertEqual(result.stdout['name'], orig_dict['name'])
        self.assertNotEqual(result.stdout['name'], updates_dict['new-name'])
Exemplo n.º 15
0
    def test_update(self, test_data):
        """@Test: Update the environment

        @Feature: Environment - Update

        @Assert: Environment Update is displayed

        """
        orig_dict, updates_dict = test_data
        try:
            make_environment({'name': orig_dict['name']})
        except CLIFactoryError as err:
            self.fail(err)

        result = Environment.update({
            'name': orig_dict['name'],
            'new-name': updates_dict['new-name']
        })
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)

        result = Environment.info({'name': updates_dict['new-name']})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)
        self.assertEqual(result.stdout['name'], updates_dict['new-name'])
Exemplo n.º 16
0
    def test_positive_update_org(self):
        """Update environment organization with new value

        :id: 2c40caf9-95a0-4b87-bd97-0a4448746052

        :expectedresults: Environment Update finished and new organization is
            assigned


        :CaseImportance: Critical
        """
        old_org = make_org()
        new_org = make_org()
        env_name = gen_string('alphanumeric', 10)
        env = make_environment({
            'name': env_name,
            'organization-ids': old_org['id'],
        })
        self.assertIn(old_org['name'], env['organizations'])
        Environment.update({
            'name': env_name,
            'organization-ids': new_org['id']
        })
        env = Environment.info({'name': env_name})
        self.assertIn(new_org['name'], env['organizations'])
        self.assertNotIn(old_org['name'], env['organizations'])
Exemplo n.º 17
0
    def test_update(self, test_data):
        """@Test: Update the environment

        @Feature: Environment - Update

        @Assert: Environment Update is displayed

        """
        orig_dict, updates_dict = test_data
        try:
            make_environment({'name': orig_dict['name']})
        except CLIFactoryError as err:
            self.fail(err)

        result = Environment.update({
            'name': orig_dict['name'],
            'new-name': updates_dict['new-name']
        })
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)

        result = Environment.info({'name': updates_dict['new-name']})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)
        self.assertEqual(result.stdout['name'], updates_dict['new-name'])
Exemplo n.º 18
0
    def test_positive_delete_by_id(self):
        """Create Environment with valid values then delete it
        by ID

        :id: e25af73a-d4ef-4287-83bf-625337d91392

        :expectedresults: Environment is deleted

        :CaseImportance: Critical
        """
        for name in valid_environments_list():
            with self.subTest(name):
                environment = make_environment({'name': name})
                Environment.delete({'id': environment['id']})
                with self.assertRaises(CLIReturnCodeError):
                    Environment.info({'id': environment['id']})
Exemplo n.º 19
0
 def setUpClass(cls):
     """Import a parametrized puppet class.
     """
     super(PuppetClassTestCase, cls).setUpClass()
     cls.host_name = settings.server.hostname
     ssh.command('puppet module install --force puppetlabs/ntp')
     cls.env = Environment.info({u'name': 'production'})
     Proxy.importclasses({
         u'environment': cls.env['name'],
         u'name': cls.host_name,
     })
     cls.puppet = Puppet.info({u'name': 'ntp'})
Exemplo n.º 20
0
def test_negative_update_name(new_name):
    """Update the Environment with invalid values

    :id: adc5ad73-0547-40f9-b4d4-649780cfb87a

    :parametrized: yes

    :expectedresults: Environment is not updated

    """
    environment = make_environment()
    with pytest.raises(CLIReturnCodeError):
        Environment.update({'id': environment['id'], 'new-name': new_name})
    result = Environment.info({'id': environment['id']})
    assert environment['name'] == result['name']
Exemplo n.º 21
0
    def test_positive_update_name(self):
        """Update the environment

        @id: 7b34ce64-24be-4b3b-8f7e-1de07daafdd9

        @Assert: Environment Update is displayed
        """
        environment = make_environment()
        for new_name in valid_environments_list():
            with self.subTest(new_name):
                Environment.update({
                    'id': environment['id'],
                    'new-name': new_name,
                })
                environment = Environment.info({'id': environment['id']})
                self.assertEqual(environment['name'], new_name)
Exemplo n.º 22
0
    def test_positive_update_name(self):
        """Update the environment

        @Feature: Environment - Update

        @Assert: Environment Update is displayed
        """
        environment = make_environment()
        for new_name in valid_environments_list():
            with self.subTest(new_name):
                Environment.update({
                    'id': environment['id'],
                    'new-name': new_name,
                })
                environment = Environment.info({'id': environment['id']})
                self.assertEqual(environment['name'], new_name)
Exemplo n.º 23
0
 def setUpClass(cls):
     """Import some parametrized puppet classes. This is required to make
     sure that we have data to be able to perform interactions with smart
     class variables.
     """
     super(SmartVariablesTestCase, cls).setUpClass()
     cls.puppet_module = "puppetlabs/ntp"
     cls.host_name = settings.server.hostname
     ssh.command('puppet module install --force {0}'.format(
         cls.puppet_module))
     cls.env = Environment.info({u'name': 'production'})
     Proxy.importclasses({
         u'environment': cls.env['name'],
         u'name': cls.host_name,
     })
     cls.puppet = Puppet.info({u'name': 'ntp'})
Exemplo n.º 24
0
    def test_positive_update_name(self):
        """Update the environment

        @id: 7b34ce64-24be-4b3b-8f7e-1de07daafdd9

        @Assert: Environment Update is displayed
        """
        environment = make_environment()
        for new_name in valid_environments_list():
            with self.subTest(new_name):
                Environment.update({
                    'id': environment['id'],
                    'new-name': new_name,
                })
                environment = Environment.info({'id': environment['id']})
                self.assertEqual(environment['name'], new_name)
Exemplo n.º 25
0
    def test_update(self, new_name):
        """@Test: Update the environment

        @Feature: Environment - Update

        @Assert: Environment Update is displayed

        """
        name = gen_string('alphanumeric')
        make_environment({'name': name})
        Environment.update({
            'name': name,
            'new-name': new_name,
        })
        env = Environment.info({'name': new_name})
        self.assertEqual(env['name'], new_name)
Exemplo n.º 26
0
    def test_positive_update_name(self):
        """Update the environment

        @Feature: Environment - Update

        @Assert: Environment Update is displayed
        """
        environment = make_environment()
        for new_name in valid_environments_list():
            with self.subTest(new_name):
                Environment.update({
                    'id': environment['id'],
                    'new-name': new_name,
                })
                environment = Environment.info({'id': environment['id']})
                self.assertEqual(environment['name'], new_name)
Exemplo n.º 27
0
 def setUpClass(cls):
     """Import some parametrized puppet classes. This is required to make
     sure that we have smart class variable available.
     Read all available smart class parameters for imported puppet class to
     be able to work with unique entity for each specific test. Raise an
     exception and skip all tests in case not enough parameters returned.
     """
     super(SmartClassParametersTestCase, cls).setUpClass()
     cls.host_name = settings.server.hostname
     ssh.command("puppet module install --force puppetlabs/ntp")
     cls.env = Environment.info({u"name": "production"})
     Proxy.importclasses({u"environment": cls.env["name"], u"name": cls.host_name})
     cls.puppet = Puppet.info({u"name": "ntp"})
     sc_params_list = SmartClassParameter.list({"environment": cls.env["name"], "search": "puppetclass=ntp"})
     if len(sc_params_list) < 45:
         raise RuntimeError("There are not enough smart class parameters to" " work with in provided puppet class")
     cls.sc_params_ids_list = [sc_param["id"] for sc_param in sc_params_list]
Exemplo n.º 28
0
    def test_negative_update_name(self):
        """Update the Environment with invalid values

        @Feature: Environment

        @Assert: Environment is not updated
        """
        environment = make_environment()
        for new_name in invalid_values_list():
            with self.subTest(new_name):
                with self.assertRaises(CLIReturnCodeError):
                    Environment.update({
                        'id': environment['id'],
                        'new-name': new_name,
                    })
                result = Environment.info({'id': environment['id']})
                self.assertEqual(environment['name'], result['name'])
Exemplo n.º 29
0
    def test_negative_update_name(self):
        """Update the Environment with invalid values

        @Feature: Environment

        @Assert: Environment is not updated
        """
        environment = make_environment()
        for new_name in invalid_values_list():
            with self.subTest(new_name):
                with self.assertRaises(CLIReturnCodeError):
                    Environment.update({
                        'id': environment['id'],
                        'new-name': new_name,
                    })
                result = Environment.info({'id': environment['id']})
                self.assertEqual(environment['name'], result['name'])
Exemplo n.º 30
0
    def test_negative_update_name(self):
        """Update the Environment with invalid values

        :id: adc5ad73-0547-40f9-b4d4-649780cfb87a

        :expectedresults: Environment is not updated

        """
        environment = make_environment()
        for new_name in invalid_values_list():
            with self.subTest(new_name):
                with self.assertRaises(CLIReturnCodeError):
                    Environment.update({
                        'id': environment['id'],
                        'new-name': new_name,
                    })
                result = Environment.info({'id': environment['id']})
                self.assertEqual(environment['name'], result['name'])
Exemplo n.º 31
0
    def test_positive_update_name(self):
        """Update the environment

        :id: 7b34ce64-24be-4b3b-8f7e-1de07daafdd9

        :expectedresults: Environment Update is displayed

        :CaseImportance: Critical
        """
        environment = make_environment()
        for new_name in valid_environments_list():
            with self.subTest(new_name):
                Environment.update({
                    'id': environment['id'],
                    'new-name': new_name,
                })
                environment = Environment.info({'id': environment['id']})
                self.assertEqual(environment['name'], new_name)
Exemplo n.º 32
0
    def test_positive_update_name(self):
        """Update the environment

        :id: 7b34ce64-24be-4b3b-8f7e-1de07daafdd9

        :expectedresults: Environment Update is displayed

        :CaseImportance: Critical
        """
        environment = make_environment()
        for new_name in valid_environments_list():
            with self.subTest(new_name):
                Environment.update({
                    'id': environment['id'],
                    'new-name': new_name,
                })
                environment = Environment.info({'id': environment['id']})
                self.assertEqual(environment['name'], new_name)
Exemplo n.º 33
0
    def test_positive_update_loc(self):
        """Update environment location with new value

        @id: d58d6dc5-a820-4c61-bd69-0c631c2d3f2e

        @Assert: Environment Update finished and new location is assigned

        """
        old_loc = make_location()
        new_loc = make_location()
        new_env = make_environment({'location-ids': old_loc['id']})
        self.assertIn(old_loc['name'], new_env['locations'])
        Environment.update({
            'location-ids': new_loc['id'],
            'name': new_env['name'],
        })
        new_env = Environment.info({'name': new_env['name']})
        self.assertIn(new_loc['name'], new_env['locations'])
        self.assertNotIn(old_loc['name'], new_env['locations'])
Exemplo n.º 34
0
    def test_positive_update_loc(self):
        """Update environment location with new value

        @id: d58d6dc5-a820-4c61-bd69-0c631c2d3f2e

        @Assert: Environment Update finished and new location is assigned

        """
        old_loc = make_location()
        new_loc = make_location()
        new_env = make_environment({'location-ids': old_loc['id']})
        self.assertIn(old_loc['name'], new_env['locations'])
        Environment.update({
            'location-ids': new_loc['id'],
            'name': new_env['name'],
        })
        new_env = Environment.info({'name': new_env['name']})
        self.assertIn(new_loc['name'], new_env['locations'])
        self.assertNotIn(old_loc['name'], new_env['locations'])
Exemplo n.º 35
0
    def test_positive_update_loc(self):
        """Update environment location with new value

        @Feature: Environment - Update

        @Assert: Environment Update finished and new location is assigned

        """
        old_loc = make_location()
        new_loc = make_location()
        new_env = make_environment({'location-ids': old_loc['id']})
        self.assertIn(old_loc['name'], new_env['locations'])
        Environment.update({
            'location-ids': new_loc['id'],
            'name': new_env['name'],
        })
        new_env = Environment.info({'name': new_env['name']})
        self.assertIn(new_loc['name'], new_env['locations'])
        self.assertNotIn(old_loc['name'], new_env['locations'])
Exemplo n.º 36
0
    def test_negative_update_name(self):
        """Update the Environment with invalid values

        :id: adc5ad73-0547-40f9-b4d4-649780cfb87a

        :expectedresults: Environment is not updated

        :CaseImportance: Critical
        """
        environment = make_environment()
        for new_name in invalid_values_list():
            with self.subTest(new_name):
                with self.assertRaises(CLIReturnCodeError):
                    Environment.update({
                        'id': environment['id'],
                        'new-name': new_name,
                    })
                result = Environment.info({'id': environment['id']})
                self.assertEqual(environment['name'], result['name'])
Exemplo n.º 37
0
    def test_positive_update_loc(self):
        """Update environment location with new value

        @Feature: Environment - Update

        @Assert: Environment Update finished and new location is assigned

        """
        old_loc = make_location()
        new_loc = make_location()
        new_env = make_environment({'location-ids': old_loc['id']})
        self.assertIn(old_loc['name'], new_env['locations'])
        Environment.update({
            'location-ids': new_loc['id'],
            'name': new_env['name'],
        })
        new_env = Environment.info({'name': new_env['name']})
        self.assertIn(new_loc['name'], new_env['locations'])
        self.assertNotIn(old_loc['name'], new_env['locations'])
Exemplo n.º 38
0
    def test_update_negative(self, new_name):
        """@Test: Update the environment with invalid values

        @Feature: Environment - Update

        @Assert: Environment is not updated

        """
        name = gen_string('alphanumeric')
        env = make_environment({'name': name})
        with self.assertRaises(CLIReturnCodeError):
            Environment.update({
                'name': name,
                'new-name': new_name,
            })
        env = Environment.info({'id': env['id']})
        # Verify that value is not updated and left as it was before update
        # command was executed
        self.assertEqual(env['name'], name)
        self.assertNotEqual(env['name'], new_name)
Exemplo n.º 39
0
    def test_positive_update_org(self):
        """Update environment organization with new value

        @Feature: Environment - Update

        @Assert: Environment Update finished and new organization is assigned

        """
        old_org = make_org()
        new_org = make_org()
        env_name = gen_string('alphanumeric', 10)
        env = make_environment({
            'name': env_name,
            'organization-ids': old_org['id'],
        })
        self.assertIn(old_org['name'], env['organizations'])
        Environment.update({
            'name': env_name,
            'organization-ids': new_org['id']
        })
        env = Environment.info({'name': env_name})
        self.assertIn(new_org['name'], env['organizations'])
        self.assertNotIn(old_org['name'], env['organizations'])
Exemplo n.º 40
0
    def test_positive_update_org(self):
        """Update environment organization with new value

        @Feature: Environment - Update

        @Assert: Environment Update finished and new organization is assigned

        """
        old_org = make_org()
        new_org = make_org()
        env_name = gen_string('alphanumeric', 10)
        env = make_environment({
            'name': env_name,
            'organization-ids': old_org['id'],
        })
        self.assertIn(old_org['name'], env['organizations'])
        Environment.update({
            'name': env_name,
            'organization-ids': new_org['id']
        })
        env = Environment.info({'name': env_name})
        self.assertIn(new_org['name'], env['organizations'])
        self.assertNotIn(old_org['name'], env['organizations'])
Exemplo n.º 41
0
    def test_positive_CRUD_with_attributes(self):
        """Check if Environment with attributes can be created, updated and removed

        :id: d2187971-86b2-40c9-a93c-66f37691ae2b

        :bz: 1337947

        :expectedresults:
            1. Environment is created and has parameters assigned
            2. Environment can be listed by parameters
            3. Environment can be updated
            4. Environment can be removed

        :CaseImportance: Critical
        """
        # Create with attributes
        env_name = gen_string('alpha')
        environment = make_environment({
            'location-ids': self.loc.id,
            'organization-ids': self.org.id,
            'name': env_name,
        })
        self.assertIn(self.loc.name, environment['locations'])
        self.assertIn(self.org.name, environment['organizations'])
        self.assertEqual(env_name, environment['name'])

        # List by name
        result = Environment.list({'search': 'name={0}'.format(env_name)})
        self.assertEqual(len(result), 1)
        self.assertEqual(result[0]['name'], env_name)
        # List by org loc id
        results = Environment.list({
            'organization-id': self.org.id,
            'location-id': self.loc.id,
        })
        self.assertIn(env_name, [res['name'] for res in results])
        # List by org loc name
        results = Environment.list({
            'organization': self.org.name,
            'location': self.loc.name,
        })
        self.assertIn(env_name, [res['name'] for res in results])

        # Update org and loc
        new_org = entities.Organization().create()
        Environment.update({
            'location-ids': self.loc2.id,
            'organization-ids': new_org.id,
            'name': environment['name'],
        })
        env_info = Environment.info({'name': environment['name']})
        self.assertIn(self.loc2.name, env_info['locations'])
        self.assertNotIn(self.loc.name, env_info['locations'])
        self.assertIn(new_org.name, env_info['organizations'])
        self.assertNotIn(self.org.name, env_info['organizations'])
        # Update name
        new_env_name = gen_string('alpha')
        Environment.update({
            'id': environment['id'],
            'new-name': new_env_name,
        })
        env_info = Environment.info({'id': environment['id']})
        self.assertEqual(env_info['name'], new_env_name)

        # Delete
        Environment.delete({'id': environment['id']})
        with self.assertRaises(CLIReturnCodeError):
            Environment.info({'id': environment['id']})