Skip to content

Commit

Permalink
Merge pull request #115 from statisticsnorway/fix-enum-bug-in-url
Browse files Browse the repository at this point in the history
Fix enum bug in url
  • Loading branch information
aecorn authored Apr 2, 2024
2 parents 296143a + d945ee4 commit 0ea89af
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "dapla-statbank-client"
version = "1.1.1"
version = "1.1.2"
description = "Handles data transfer Statbank <-> Dapla for Statistics Norway"
authors = ["Statistics Norway", "Carl F. Corneil <[email protected]>"]
license = "MIT"
Expand Down
5 changes: 4 additions & 1 deletion src/statbank/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,12 @@ def __init__( # noqa: PLR0913
self._validate_date()
self.date = self.date.replace(hour=8, minute=0, second=0, microsecond=0)
if self.check_username_password:
logger.info(
"Checking filbeskrivelse of random tableid 05300 to double-check username & password early.",
)
self.get_description(
"05300",
) # Random tableid to double check username&password early
)
logger.info("Publishing date set to %s", self.date.isoformat("T", "seconds"))

# Representation
Expand Down
3 changes: 2 additions & 1 deletion src/statbank/transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ def transfer(self, headers: dict[str, str] | None = None) -> None:
self.body = self._body_from_data()

url_load_params = self.urls["loader"] + urllib.parse.urlencode(self.params)
urllib.parse.urlparse(url_load_params) # Test to see if url is valid format
self.response = self._make_transfer_request(url_load_params)
self._cleanup_response()
finally:
Expand Down Expand Up @@ -289,7 +290,7 @@ def _build_params(self) -> dict[str, str | int]:
"fagansvarlig1": self.cc,
"fagansvarlig2": self.bcc,
"auto_overskriv_data": str(int(self.overwrite)),
"auto_godkjenn_data": self.approve,
"auto_godkjenn_data": str(int(self.approve)),
}

def _make_transfer_request(
Expand Down
12 changes: 12 additions & 0 deletions tests/test_statbank.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,19 +252,31 @@ def test_transfer_approve_int_intstr_str(
fake_user(),
approve=1,
).oppdragsnummer.isdigit()

assert StatbankTransfer(
fake_data(),
"10000",
fake_user(),
approve="1",
).oppdragsnummer.isdigit()

assert StatbankTransfer(
fake_data(),
"10000",
fake_user(),
approve="MANUAL",
).oppdragsnummer.isdigit()

params_dict: dict[str, str] = StatbankTransfer( # noqa: SLF001
fake_data(),
"10000",
fake_user(),
approve="MANUAL",
)._build_params()
for v in params_dict.values():
assert isinstance(v, str)
assert "Approve." not in v


def test_repr_transfer(transfer_success: StatbankTransfer):
assert "StatbankTransfer" in transfer_success.__repr__()
Expand Down

0 comments on commit 0ea89af

Please sign in to comment.