Skip to content

Commit

Permalink
make dev client default to dev db
Browse files Browse the repository at this point in the history
  • Loading branch information
kdabrock committed Sep 26, 2024
1 parent e3d3dd8 commit f8184cc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/builda_client/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ development:
production:
api_address: https://ethos-builda.fz-juelich.de

base_url: /api/v0/
base_url: /api/v8_20240916/

nominatim:
host: 134.94.117.112
Expand Down
8 changes: 5 additions & 3 deletions src/builda_client/dev_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,9 @@ def __init__(
self,
username: str,
password: str,
phase: Phase = Phase.PRODUCTION,
phase: Phase = Phase.DEVELOPMENT,
proxy: bool = False,
version: str = "v0"
):
"""Constructor.
Expand All @@ -198,7 +199,8 @@ def __init__(
username (str): Username for API authentication.
password (str): Password for API authentication.
phase (Phase, optional): The 'phase' the client is used in, i.e. which
database to access. Defaults to Phase.PRODUCTION.
database to access. Defaults to Phase.DEVELOPMENT.
version (str, optional): The API version. Defaults to v0
"""
super().__init__()

Expand All @@ -209,7 +211,7 @@ def __init__(

address = self.config["proxy_address"] if proxy else self.config[self.phase.value]["api_address"]

self.base_url = f"""{address}{self.config['base_url']}"""
self.base_url = f"""{address}/api/{version}/"""
self.authentication_url = f"""{address}{self.AUTH_URL}"""
self.api_token = self.__get_authentication_token()

Expand Down
17 changes: 14 additions & 3 deletions tests/test_dev_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,17 @@ def test_get_buildings_base_no_type(self):
buildings = self.testee.get_buildings_base(nuts_code='01058007')
self.__then_result_list_min_length_returned(buildings, 1)

# Commented out so this will not unintentionally overwrite existing data
# def test_update_mobility_preference(self):
# self.__given_client_authenticated()
# person_count = 10000
# person_ids = self.testee.execute_query(f"SELECT id::varchar from data.persons limit {person_count}")
# person_ids = [x for xs in person_ids for x in xs]
# data = []
# for p in person_ids:
# data.append((p, '{"pref": "train"}'))

# self.testee.update_mobility_preference(data)

@pytest.mark.parametrize(
"nuts_level,country,expected_min_count",
Expand Down Expand Up @@ -137,9 +148,9 @@ def test_get_pv_potential_statistics_succeeds(self, nuts_level, country, expecte

# GIVEN
def __given_client_authenticated(self, proxy: bool = False) -> None:
username = os.getenv('API_USERNAME')
password = os.getenv('API_PASSWORD')
self.testee = BuildaDevClient(proxy=proxy, username=username, password=password, phase=Phase.PRODUCTION)
username = os.getenv('API_USERNAME_DEV')
password = os.getenv('API_PASSWORD_DEV')
self.testee = BuildaDevClient(proxy=proxy, username=username, password=password, phase=Phase.DEVELOPMENT)


# THEN
Expand Down

0 comments on commit f8184cc

Please sign in to comment.