From 166d3c57d337ac846cb693f62a066e644470de3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Foellmi?= Date: Sat, 11 Jan 2020 15:07:03 +0100 Subject: [PATCH 01/19] Adding a test flag --- arcsecond/options.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/arcsecond/options.py b/arcsecond/options.py index b63352a..68182d9 100644 --- a/arcsecond/options.py +++ b/arcsecond/options.py @@ -2,16 +2,26 @@ class State(object): - def __init__(self, verbose=0, debug=False, open=None, organisation=None, is_using_cli=True): + def __init__(self, verbose=0, debug=False, test=False, open=None, organisation=None, is_using_cli=True): self.verbose = verbose self.debug = debug + self.test = test self.open = open self.organisation = organisation self.is_using_cli = is_using_cli + def config_section(self): + if self.test: + return 'test' + elif self.debug: + return 'debug' + else: + return 'main' + def make_new_silent(self): return State(verbose=0, debug=self.debug, + test=self.test, open=self.open, organisation=self.organisation, is_using_cli=self.is_using_cli) From 23a35bd9b717b6ea09f0f022176465b31b92e661 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Foellmi?= Date: Sat, 11 Jan 2020 15:07:19 +0100 Subject: [PATCH 02/19] Changing debug flag to section name to better handle test and debug --- arcsecond/config.py | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/arcsecond/config.py b/arcsecond/config.py index 51f4dee..d4ad02a 100644 --- a/arcsecond/config.py +++ b/arcsecond/config.py @@ -11,19 +11,17 @@ def config_file_exists(): return os.path.exists(path) and os.path.isfile(path) -def config_file_is_valid(debug=False): +def config_file_is_valid(section='main'): if not config_file_exists(): return False config = ConfigParser() config.read(config_file_path()) - section = 'debug' if debug else 'main' return config[section].get('api_key') -def config_file_save_api_key(api_key, username, debug=False): +def config_file_save_api_key(api_key, username, section='main'): config = ConfigParser() config.read(config_file_path()) - section = 'debug' if debug else 'main' if section not in config.keys(): config.add_section(section) config.set(section, 'username', username) @@ -32,10 +30,9 @@ def config_file_save_api_key(api_key, username, debug=False): config.write(f) -def config_file_save_organisation_membership(subdomain, role, debug=False): +def config_file_save_organisation_membership(subdomain, role, section='main'): config = ConfigParser() config.read(config_file_path()) - section = 'debug' if debug else 'main' section += ':organisations' if section not in config.keys(): config.add_section(section) @@ -44,39 +41,37 @@ def config_file_save_organisation_membership(subdomain, role, debug=False): config.write(f) -def config_file_read_organisation_memberships(debug=False): +def config_file_read_organisation_memberships(section='main'): config = ConfigParser() config.read(config_file_path()) - section = 'debug' if debug else 'main' section += ':organisations' if section not in config.sections(): return {} return config[section] -def config_file_read_key(key, debug=False): +def config_file_read_key(key, section='main'): config = ConfigParser() config.read(config_file_path()) - section = 'debug' if debug else 'main' if section not in config.sections(): return None return config[section].get(key, None) -def config_file_read_api_key(debug=False): - return config_file_read_key('api_key', debug=debug) +def config_file_read_api_key(section='main'): + return config_file_read_key('api_key', section=section) -def config_file_read_username(debug=False): - return config_file_read_key('username', debug=debug) +def config_file_read_username(section='main'): + return config_file_read_key('username', section=section) -def config_file_clear_debug_session(): +def config_file_clear_section(section): config = ConfigParser() config.read(config_file_path()) - if 'debug' in config.sections(): + if section in config.sections(): del config['debug'] - if 'debug:organisations' in config.sections(): - del config['debug:organisations'] + if section + ':organisations' in config.sections(): + del config[section + ':organisations'] with open(config_file_path(), 'w') as f: config.write(f) From 6d67bf0414fbbb80283213cbe58519322584b63f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Foellmi?= Date: Sat, 11 Jan 2020 15:08:12 +0100 Subject: [PATCH 03/19] Cirrectly handling test flag --- arcsecond/api/main.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arcsecond/api/main.py b/arcsecond/api/main.py index e9c178b..270e268 100644 --- a/arcsecond/api/main.py +++ b/arcsecond/api/main.py @@ -59,6 +59,8 @@ def get_api_state(state=None, **kwargs): if 'debug' in kwargs.keys(): state.debug = kwargs.get('debug') + if 'test' in kwargs.keys(): + state.test = kwargs.get('test') if 'verbose' in kwargs.keys(): state.verbose = kwargs.get('verbose') if 'organisation' in kwargs.keys(): From b67168b9c80a8d31857a2f61569f935b9f041d4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Foellmi?= Date: Sat, 11 Jan 2020 15:08:40 +0100 Subject: [PATCH 04/19] Adding access to username and memberships --- arcsecond/api/main.py | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/arcsecond/api/main.py b/arcsecond/api/main.py index 270e268..2c2b795 100644 --- a/arcsecond/api/main.py +++ b/arcsecond/api/main.py @@ -14,6 +14,8 @@ from arcsecond.config import (config_file_path, config_file_read_api_key, config_file_save_api_key, + config_file_read_username, + config_file_read_organisation_memberships, config_file_save_organisation_membership) from arcsecond.options import State @@ -83,8 +85,16 @@ def factory(endpoint_class, state, **kwargs): @set_api_factory class Arcsecond(object): @classmethod - def is_logged_in(cls, state=None): - return ArcsecondAPI.is_logged_in(state) + def is_logged_in(cls, state=None, **kwargs): + return ArcsecondAPI.is_logged_in(state, **kwargs) + + @classmethod + def username(cls, state=None, **kwargs): + return ArcsecondAPI.username(state, **kwargs) + + @classmethod + def memberships(cls, state=None, **kwargs): + return ArcsecondAPI.memberships(state, **kwargs) @classmethod def login(cls, username, password, subdomain, state=None): @@ -231,9 +241,19 @@ def _get_and_save_api_key(cls, state, username, auth_token): return result @classmethod - def is_logged_in(cls, state=None): - state = get_api_state(state) - return config_file_read_api_key(debug=state.debug) is not None + def is_logged_in(cls, state=None, **kwargs): + state = get_api_state(state, **kwargs) + return config_file_read_api_key(section=state.config_section()) is not None + + @classmethod + def username(cls, state=None, **kwargs): + state = get_api_state(state, **kwargs) + return config_file_read_username(section=state.config_section()) or '' + + @classmethod + def memberships(cls, state=None, **kwargs): + state = get_api_state(state, **kwargs) + return config_file_read_organisation_memberships(section=state.config_section()) @classmethod def login(cls, username, password, subdomain, state=None): From 74815d651a21ea83a7e571693de8fa275d28807e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Foellmi?= Date: Sat, 11 Jan 2020 15:08:51 +0100 Subject: [PATCH 05/19] Correctly handling test flag using helper method --- arcsecond/api/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arcsecond/api/main.py b/arcsecond/api/main.py index 2c2b795..1009770 100644 --- a/arcsecond/api/main.py +++ b/arcsecond/api/main.py @@ -212,7 +212,7 @@ def delete(self, id_name_uuid, **headers): def _check_organisation_membership(cls, state, username, subdomain): if state.verbose: click.echo('Checking Membership of Organisation with subdomain "{}"...'.format(subdomain)) - profile, error = PersonalProfileAPIEndPoint(State(verbose=False, debug=state.debug)).read(username) + profile, error = PersonalProfileAPIEndPoint(state.make_new_silent()).read(username) if error: ArcsecondAPI._echo_error(state, error) else: From df684f5c9ce41ebdad30931b803844796066703a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Foellmi?= Date: Sat, 11 Jan 2020 15:09:06 +0100 Subject: [PATCH 06/19] Some helpers for tests --- tests/utils.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/utils.py b/tests/utils.py index 00cf45b..97ff994 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -1,8 +1,12 @@ import json import httpretty -from arcsecond.api.constants import API_AUTH_PATH_LOGIN, ARCSECOND_API_URL_DEV + from arcsecond import cli +from arcsecond.api.constants import API_AUTH_PATH_LOGIN, ARCSECOND_API_URL_DEV +from arcsecond.config import (config_file_clear_section, + config_file_save_api_key, + config_file_save_organisation_membership) TEST_LOGIN_USERNAME = 'robot1' TEST_LOGIN_PASSWORD = 'robotpass' @@ -75,6 +79,18 @@ def register_successful_organisation_login(runner, subdomain, role): input=TEST_LOGIN_USERNAME + '\n' + TEST_LOGIN_PASSWORD) +def save_test_credentials(username, memberships=None): + if memberships is None: + memberships = dict() + config_file_save_api_key(TEST_API_KEY, username, section='test') + for k, v in memberships.items(): + config_file_save_organisation_membership(k, v, 'test') + + +def clear_test_credentials(): + config_file_clear_section('test') + + def mock_url_path(method, path, body='', query='', status=200): path = path + '/' if path[-1] != '/' else path httpretty.register_uri(method, ARCSECOND_API_URL_DEV + path + query, status=status, body=body) From 241ca882c31f5804e5ef3fa255b832bb68c6ecf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Foellmi?= Date: Sat, 11 Jan 2020 15:09:14 +0100 Subject: [PATCH 07/19] Using new config method --- tests/test_datasets_organisations.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_datasets_organisations.py b/tests/test_datasets_organisations.py index 348fefd..90b3a69 100644 --- a/tests/test_datasets_organisations.py +++ b/tests/test_datasets_organisations.py @@ -4,7 +4,7 @@ from arcsecond import cli from arcsecond.api.error import ArcsecondError -from arcsecond.config import config_file_clear_debug_session +from arcsecond.config import config_file_clear_section from .utils import (register_successful_personal_login, register_successful_organisation_login, @@ -14,7 +14,7 @@ class DatasetsInOrganisationsTestCase(TestCase): def setUp(self): - config_file_clear_debug_session() + config_file_clear_section('debug') httpretty.enable() def tearDown(self): From 3723b45bc1e2e8087b89b14b3189694125ac07cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Foellmi?= Date: Sat, 11 Jan 2020 15:09:20 +0100 Subject: [PATCH 08/19] New tests --- tests/test_arcsecond_root.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tests/test_arcsecond_root.py diff --git a/tests/test_arcsecond_root.py b/tests/test_arcsecond_root.py new file mode 100644 index 0000000..8badabf --- /dev/null +++ b/tests/test_arcsecond_root.py @@ -0,0 +1,23 @@ +from arcsecond import Arcsecond +from .utils import save_test_credentials, clear_test_credentials + + +def test_default_empty_state(): + clear_test_credentials() + assert Arcsecond.is_logged_in(test=True) is False + assert Arcsecond.username(test=True) == '' + assert Arcsecond.memberships(test=True) == {} + + +def test_default_logged_in_state(): + save_test_credentials('cedric') + assert Arcsecond.is_logged_in(test=True) is True + assert Arcsecond.username(test=True) == 'cedric' + assert Arcsecond.memberships(test=True) == {} + + +def test_default_logged_in_with_membership_state(): + save_test_credentials('cedric', {'saao': 'superadmin'}) + assert Arcsecond.is_logged_in(test=True) is True + assert Arcsecond.username(test=True) == 'cedric' + assert Arcsecond.memberships(test=True) == {'saao': 'superadmin'} From 247de7edbc57a1fd933e7a2115e6b44b24dded01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Foellmi?= Date: Sat, 11 Jan 2020 15:09:30 +0100 Subject: [PATCH 09/19] Bumping version --- arcsecond/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arcsecond/__init__.py b/arcsecond/__init__.py index 1461fb1..219fb48 100644 --- a/arcsecond/__init__.py +++ b/arcsecond/__init__.py @@ -7,4 +7,4 @@ "ArcsecondConnectionError", "ArcsecondInvalidEndpointError"] -__version__ = '0.7.2' +__version__ = '0.7.3' From fb1427e368b864b90e523b3cb63b10b6be62bf8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Foellmi?= Date: Sat, 11 Jan 2020 15:31:09 +0100 Subject: [PATCH 10/19] Using DEV urls not only for debug but also test --- arcsecond/api/endpoints/_base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arcsecond/api/endpoints/_base.py b/arcsecond/api/endpoints/_base.py index d8636e7..22c376f 100644 --- a/arcsecond/api/endpoints/_base.py +++ b/arcsecond/api/endpoints/_base.py @@ -30,7 +30,7 @@ def __init__(self, state=None, prefix=''): self.organisation = state.organisation or '' def _get_base_url(self): - return ARCSECOND_API_URL_DEV if self.state.debug else ARCSECOND_API_URL_PROD + return ARCSECOND_API_URL_DEV if (self.state.debug or self.state.test) else ARCSECOND_API_URL_PROD def _root_url(self): prefix = self.prefix @@ -44,7 +44,7 @@ def _build_url(self, *args): def _root_open_url(self): if hasattr(self.state, 'open'): - return ARCSECOND_WWW_URL_DEV if self.state.debug is True else ARCSECOND_WWW_URL_PROD + return ARCSECOND_WWW_URL_DEV if (self.state.debug or self.state.test) is True else ARCSECOND_WWW_URL_PROD def _list_url(self, name=''): raise Exception('You must override this method.') From 07569ae524193ee53d1c34982a7fe7f2bb84118a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Foellmi?= Date: Sat, 11 Jan 2020 15:31:15 +0100 Subject: [PATCH 11/19] Using correct section --- arcsecond/api/endpoints/_base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arcsecond/api/endpoints/_base.py b/arcsecond/api/endpoints/_base.py index 22c376f..65077d8 100644 --- a/arcsecond/api/endpoints/_base.py +++ b/arcsecond/api/endpoints/_base.py @@ -70,7 +70,7 @@ def _check_and_set_api_key(self, headers, url): if self.state.verbose: click.echo('Checking local API key... ', nl=False) - api_key = config_file_read_api_key(self.state.debug) + api_key = config_file_read_api_key(self.state.config_section()) if not api_key: raise ArcsecondError('Missing API key. You must login first: $ arcsecond login') @@ -81,7 +81,7 @@ def _check_and_set_api_key(self, headers, url): return headers def _check_organisation_membership_and_permission(self, method_name, organisation): - memberships = config_file_read_organisation_memberships(self.state.debug) + memberships = config_file_read_organisation_memberships(self.state.config_section()) if self.state.organisation not in memberships.keys(): raise ArcsecondError('No membership found for organisation {}'.format(organisation)) membership = memberships[self.state.organisation] From 7afcdd3aadeafa6c7bdf2eccafe10b646c3feb9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Foellmi?= Date: Sat, 11 Jan 2020 15:34:25 +0100 Subject: [PATCH 12/19] Fixed parameter --- arcsecond/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arcsecond/config.py b/arcsecond/config.py index d4ad02a..3c68318 100644 --- a/arcsecond/config.py +++ b/arcsecond/config.py @@ -70,7 +70,7 @@ def config_file_clear_section(section): config = ConfigParser() config.read(config_file_path()) if section in config.sections(): - del config['debug'] + del config[section] if section + ':organisations' in config.sections(): del config[section + ':organisations'] with open(config_file_path(), 'w') as f: From e3ba6155630f372816e0567baf283bb9925128bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Foellmi?= Date: Sat, 11 Jan 2020 15:34:38 +0100 Subject: [PATCH 13/19] There is in fact, no need for another flag... --- arcsecond/options.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/arcsecond/options.py b/arcsecond/options.py index 68182d9..75e467f 100644 --- a/arcsecond/options.py +++ b/arcsecond/options.py @@ -2,26 +2,19 @@ class State(object): - def __init__(self, verbose=0, debug=False, test=False, open=None, organisation=None, is_using_cli=True): + def __init__(self, verbose=0, debug=False, open=None, organisation=None, is_using_cli=True): self.verbose = verbose self.debug = debug - self.test = test self.open = open self.organisation = organisation self.is_using_cli = is_using_cli def config_section(self): - if self.test: - return 'test' - elif self.debug: - return 'debug' - else: - return 'main' + return 'debug' if self.debug else 'main' def make_new_silent(self): return State(verbose=0, debug=self.debug, - test=self.test, open=self.open, organisation=self.organisation, is_using_cli=self.is_using_cli) From e919b9b36efe9501025f02c5537034e578e1093d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Foellmi?= Date: Sat, 11 Jan 2020 15:34:43 +0100 Subject: [PATCH 14/19] Using debug flag --- tests/test_arcsecond_root.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/test_arcsecond_root.py b/tests/test_arcsecond_root.py index 8badabf..acdb5aa 100644 --- a/tests/test_arcsecond_root.py +++ b/tests/test_arcsecond_root.py @@ -4,20 +4,20 @@ def test_default_empty_state(): clear_test_credentials() - assert Arcsecond.is_logged_in(test=True) is False - assert Arcsecond.username(test=True) == '' - assert Arcsecond.memberships(test=True) == {} + assert Arcsecond.is_logged_in(debug=True) is False + assert Arcsecond.username(debug=True) == '' + assert Arcsecond.memberships(debug=True) == {} def test_default_logged_in_state(): save_test_credentials('cedric') - assert Arcsecond.is_logged_in(test=True) is True - assert Arcsecond.username(test=True) == 'cedric' - assert Arcsecond.memberships(test=True) == {} + assert Arcsecond.is_logged_in(debug=True) is True + assert Arcsecond.username(debug=True) == 'cedric' + assert Arcsecond.memberships(debug=True) == {} def test_default_logged_in_with_membership_state(): save_test_credentials('cedric', {'saao': 'superadmin'}) - assert Arcsecond.is_logged_in(test=True) is True - assert Arcsecond.username(test=True) == 'cedric' - assert Arcsecond.memberships(test=True) == {'saao': 'superadmin'} + assert Arcsecond.is_logged_in(debug=True) is True + assert Arcsecond.username(debug=True) == 'cedric' + assert Arcsecond.memberships(debug=True) == {'saao': 'superadmin'} From 932f02dd9be8af6c881c658a84a5cca8bb5d44b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Foellmi?= Date: Sat, 11 Jan 2020 15:34:53 +0100 Subject: [PATCH 15/19] =?UTF-8?q?Using=20debug=20flag=20instead=20of=20?= =?UTF-8?q?=E2=80=98test=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/utils.py b/tests/utils.py index 97ff994..2bd5010 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -82,13 +82,13 @@ def register_successful_organisation_login(runner, subdomain, role): def save_test_credentials(username, memberships=None): if memberships is None: memberships = dict() - config_file_save_api_key(TEST_API_KEY, username, section='test') + config_file_save_api_key(TEST_API_KEY, username, section='debug') for k, v in memberships.items(): - config_file_save_organisation_membership(k, v, 'test') + config_file_save_organisation_membership(k, v, 'debug') def clear_test_credentials(): - config_file_clear_section('test') + config_file_clear_section('debug') def mock_url_path(method, path, body='', query='', status=200): From 6e46f77a8cbdcefdc4bed51f1ab5c5db9c9fd5bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Foellmi?= Date: Sat, 11 Jan 2020 15:35:00 +0100 Subject: [PATCH 16/19] Fixed correct section --- arcsecond/cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arcsecond/cli.py b/arcsecond/cli.py index 04c4ec1..772d213 100644 --- a/arcsecond/cli.py +++ b/arcsecond/cli.py @@ -56,7 +56,7 @@ def login(state, username, password, organisation=None): @pass_state def me(state): """Fetch your complete user profile.""" - username = config_file_read_username(state.debug) + username = config_file_read_username(state.config_section()) if not username: msg = 'Invalid/missing username: {}. Make sure to login first: $ arcsecond login'.format(username) raise ArcsecondError(msg) From 82de95a4f3d07f8aee5359a9cc98659490d78ce2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Foellmi?= Date: Sat, 11 Jan 2020 15:35:09 +0100 Subject: [PATCH 17/19] No need for test flag --- arcsecond/api/main.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/arcsecond/api/main.py b/arcsecond/api/main.py index 1009770..23b747e 100644 --- a/arcsecond/api/main.py +++ b/arcsecond/api/main.py @@ -61,8 +61,6 @@ def get_api_state(state=None, **kwargs): if 'debug' in kwargs.keys(): state.debug = kwargs.get('debug') - if 'test' in kwargs.keys(): - state.test = kwargs.get('test') if 'verbose' in kwargs.keys(): state.verbose = kwargs.get('verbose') if 'organisation' in kwargs.keys(): From 1e28cb613a26dc9f1c47920710c834cc1751afc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Foellmi?= Date: Sat, 11 Jan 2020 15:35:14 +0100 Subject: [PATCH 18/19] Using correct sections --- arcsecond/api/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arcsecond/api/main.py b/arcsecond/api/main.py index 23b747e..5d5136a 100644 --- a/arcsecond/api/main.py +++ b/arcsecond/api/main.py @@ -219,7 +219,7 @@ def _check_organisation_membership(cls, state, username, subdomain): if state.verbose: click.echo('Membership confirmed. Role is "{}", stored in {}.' .format(memberships[subdomain], config_file_path())) - config_file_save_organisation_membership(subdomain, memberships[subdomain], state.debug) + config_file_save_organisation_membership(subdomain, memberships[subdomain], state.config_section()) else: if state.verbose: click.echo('Membership denied.') @@ -233,7 +233,7 @@ def _get_and_save_api_key(cls, state, username, auth_token): return ArcsecondAPI._echo_error(state, error) if result: api_key = result['api_key'] - config_file_save_api_key(api_key, username, state.debug) + config_file_save_api_key(api_key, username, state.config_section()) if state.verbose: click.echo('Successful API key retrieval and storage in {}. Enjoy.'.format(config_file_path())) return result From 5b7b17140e434deaa1dd1e8531ed26258f0c6c03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Foellmi?= Date: Sat, 11 Jan 2020 15:35:21 +0100 Subject: [PATCH 19/19] Removing test flag --- arcsecond/api/endpoints/_base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arcsecond/api/endpoints/_base.py b/arcsecond/api/endpoints/_base.py index 65077d8..8f03f97 100644 --- a/arcsecond/api/endpoints/_base.py +++ b/arcsecond/api/endpoints/_base.py @@ -30,7 +30,7 @@ def __init__(self, state=None, prefix=''): self.organisation = state.organisation or '' def _get_base_url(self): - return ARCSECOND_API_URL_DEV if (self.state.debug or self.state.test) else ARCSECOND_API_URL_PROD + return ARCSECOND_API_URL_DEV if self.state.debug else ARCSECOND_API_URL_PROD def _root_url(self): prefix = self.prefix @@ -44,7 +44,7 @@ def _build_url(self, *args): def _root_open_url(self): if hasattr(self.state, 'open'): - return ARCSECOND_WWW_URL_DEV if (self.state.debug or self.state.test) is True else ARCSECOND_WWW_URL_PROD + return ARCSECOND_WWW_URL_DEV if self.state.debug is True else ARCSECOND_WWW_URL_PROD def _list_url(self, name=''): raise Exception('You must override this method.')