def test_api_url(self): plain_config = random_config() api_url = os.environ.get('ABEJA_API_URL', 'https://api.dev.abeja.io') config = Config(**plain_config, api_url=api_url) assert config.api_url == api_url d = config.asdict() assert d['abeja-api-url'] == config.api_url
def test_without_env(self): plain_config = random_config() config = Config(**plain_config) assert config.name is None assert config.user == ('user-' + plain_config['user']) assert config.token == plain_config['token'] assert config.organization == plain_config['organization'] assert config.asdict() == { 'abeja-platform-user': plain_config['user'], 'personal-access-token': plain_config['token'], 'organization-name': plain_config['organization'] }
def test_with_environ(self, fake_environ): with mock.patch.dict(os.environ, fake_environ): plain_config = random_config() config = Config(**plain_config) assert config.name is None assert config.user == fake_environ['ABEJA_CLI_USER'] assert config.token == fake_environ['ABEJA_CLI_TOKEN'] assert config.organization == fake_environ[ 'ABEJA_CLI_ORGANIZATION'] assert config.asdict() == { 'abeja-platform-user': plain_config['user'], 'personal-access-token': plain_config['token'], 'organization-name': plain_config['organization'] }
def test_with_environ_platform_auth_token(self, fake_environ_auth_token): with mock.patch.dict(os.environ, fake_environ_auth_token): config = Config(None, None, None) assert config assert config.name is None assert config.user is None assert config.token is None assert config.organization == fake_environ_auth_token[ 'ABEJA_CLI_ORGANIZATION'] assert config.platform_auth_token == fake_environ_auth_token[ 'PLATFORM_AUTH_TOKEN'] assert config.asdict() == { 'abeja-platform-user': None, 'personal-access-token': None, 'organization-name': None }
def test_with_environ_deprecated(self, fake_environ_deprecated): with mock.patch.dict(os.environ, fake_environ_deprecated): plain_config = random_config() config = Config(**plain_config) assert config assert config.name is None assert config.user == fake_environ_deprecated[ 'ABEJA_PLATFORM_USER'] assert config.token == fake_environ_deprecated[ 'PERSONAL_ACCESS_TOKEN'] assert config.organization == fake_environ_deprecated[ 'ORGANIZATION_NAME'] assert config.asdict() == { 'abeja-platform-user': plain_config['user'], 'personal-access-token': plain_config['token'], 'organization-name': plain_config['organization'] }
def test_name(self): plain_config = random_config() config = Config(**plain_config, name='A') assert config.name == 'A' d = config.asdict() assert d['configuration-name'] == config.name