EOX GitLab Instance

Commit 36af03c1 authored by Nikola Jankovic's avatar Nikola Jankovic 💻
Browse files

updated unittests

moved client away from main function due to handling it in the new app
parent 9164eb7f
Pipeline #22622 passed with stage
in 42 seconds
......@@ -12,14 +12,12 @@ def test_stacapi(
requests_mocker: requests_mock.Mocker,
config: dict,
data_map: dict,
client: unittest.mock.MagicMock,
):
mock_data = data_map[value]
for url, mock_json in mock_data:
requests_mocker.get(url=url, json=mock_json)
main(config, value, client)
client.lpush.assert_called()
main(config, value)
@pytest.mark.parametrize("value", [("Creodias-Opensearch")])
......@@ -28,15 +26,13 @@ def test_opensearch(
requests_mocker: requests_mock.Mocker,
config: dict,
data_map: dict,
client: unittest.mock.MagicMock,
):
mock_data = data_map[value]
requests_mocker.get(url=mock_data["describe"][0], text=mock_data["describe"][1])
requests_mocker.get(url=mock_data["data"][0], json=mock_data["data"][1])
requests_mocker.get(url=mock_data["empty"][0], json=mock_data["empty"][1])
main(config, value, client)
client.lpush.assert_called()
main(config, value)
@pytest.mark.parametrize("value", [("Fusion-data")])
......@@ -45,38 +41,23 @@ def test_s3(
mocker: pytest_mock.MockFixture,
config: dict,
data_map: dict,
client: unittest.mock.MagicMock,
):
mock_data = data_map[value]
session_mock = mocker.patch("harvester.source.s3.boto3.session.Session")
session_mock().client().get_paginator().paginate.return_value = mock_data
main(config, value, client)
client.lpush.assert_called()
main(config, value)
def test_get_harvester_config():
# testing list style
test_config = {
"harvesters": [
{
"name": "myname",
"type": "TestType",
"properties": {}
}
]
"harvesters": [{"name": "myname", "type": "TestType", "properties": {}}]
}
config = get_harvest_config(test_config, "myname", {})
assert config == test_config["harvesters"][0]
# testing list style
test_config = {
"harvesters": {
"myname": {
"type": "TestType",
"properties": {}
}
}
}
test_config = {"harvesters": {"myname": {"type": "TestType", "properties": {}}}}
config = get_harvest_config(test_config, "myname", {})
assert config == test_config["harvesters"]["myname"]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment