def test_get(self):
        self.requests_mock.get(self.TEST_URL + URL_TEMPLATE_NAME % 'env',
                               json=ENVIRONMENT)

        env = self.environments.get('env')

        self.assertIsNotNone(env)
        self.assertDictEqual(
            environments.Environment(self.environments, ENVIRONMENT).to_dict(),
            env.to_dict())
    def test_get(self):
        mock = self.mock_http_get(content=ENVIRONMENT)

        env = self.environments.get('env')

        self.assertIsNotNone(env)
        self.assertDictEqual(
            environments.Environment(self.environments, ENVIRONMENT).to_dict(),
            env.to_dict()
        )

        mock.assert_called_once_with(URL_TEMPLATE_NAME % 'env')
    def test_list(self):
        self.requests_mock.get(self.TEST_URL + URL_TEMPLATE,
                               json={'environments': [ENVIRONMENT]})

        environment_list = self.environments.list()

        self.assertEqual(1, len(environment_list))

        env = environment_list[0]

        self.assertDictEqual(
            environments.Environment(self.environments, ENVIRONMENT).to_dict(),
            env.to_dict())
    def test_list(self):
        mock = self.mock_http_get(content={'environments': [ENVIRONMENT]})

        environment_list = self.environments.list()

        self.assertEqual(1, len(environment_list))

        env = environment_list[0]

        self.assertDictEqual(
            environments.Environment(self.environments, ENVIRONMENT).to_dict(),
            env.to_dict()
        )

        mock.assert_called_once_with(URL_TEMPLATE)
Esempio n. 5
0
ENVIRONMENT_DICT = {
    'name': 'env1',
    'description': 'Test Environment #1',
    'scope': 'private',
    'variables': {
        'server': 'localhost',
        'database': 'test',
        'timeout': 600,
        'verbose': True
    },
    'created_at': str(datetime.datetime.utcnow()),
    'updated_at': str(datetime.datetime.utcnow())
}

ENVIRONMENT = environments.Environment(mock, ENVIRONMENT_DICT)
EXPECTED_RESULT = (ENVIRONMENT_DICT['name'], ENVIRONMENT_DICT['description'],
                   json.dumps(ENVIRONMENT_DICT['variables'], indent=4),
                   ENVIRONMENT_DICT['scope'], ENVIRONMENT_DICT['created_at'],
                   ENVIRONMENT_DICT['updated_at'])


class TestCLIEnvironmentsV2(base.BaseCommandTest):
    def _test_create(self, content):
        self.client.environments.create.return_value = ENVIRONMENT

        with tempfile.NamedTemporaryFile() as f:
            f.write(content.encode('utf-8'))
            f.flush()
            file_path = os.path.abspath(f.name)
            result = self.call(environment_cmd.Create, app_args=[file_path])