Skip to content

Commit

Permalink
add test for connection initialisation
Browse files Browse the repository at this point in the history
  • Loading branch information
nazarfil committed Dec 24, 2024
1 parent 2746799 commit 9c710ed
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/dhis2/test_dhis2.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,33 @@ def con():
return Connection("http://localhost:8080", "admin", "district")


@responses.activate
@pytest.mark.parametrize("version", VERSIONS)
def test_connection_from_object(version, con):
responses_dir = Path("tests", "dhis2", "responses", version)
responses._add_from_file(Path(responses_dir, "dhis2_init.yaml"))
api = DHIS2(con, cache_dir=None)
assert api is not None


@responses.activate
@pytest.mark.parametrize("version", VERSIONS)
def test_connection_from_kwargs(version):
responses_dir = Path("tests", "dhis2", "responses", version)
responses._add_from_file(Path(responses_dir, "dhis2_init.yaml"))
api = DHIS2(url="http://localhost:8080", username="admin", password="district", cache_dir=None)
assert api is not None


@responses.activate
@pytest.mark.parametrize("version", VERSIONS)
def test_connection_from_kwargs(version):
responses_dir = Path("tests", "dhis2", "responses", version)
responses._add_from_file(Path(responses_dir, "dhis2_init.yaml"))
with pytest.raises(DHIS2Error):
api = DHIS2(url="http://localhost:8080", cache_dir=None)


@responses.activate
@pytest.mark.parametrize("version", VERSIONS)
def test_data_elements(version, con):
Expand Down

0 comments on commit 9c710ed

Please sign in to comment.