Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix-353 #364

Merged
merged 8 commits into from
Sep 25, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions src/reporter/tests/test_1T1ENA.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,90 @@ def test_1T1ENA_fromDate_toDate(service, reporter_dataset):
assert_1T1ENA_response(obtained, expected)


@pytest.mark.parametrize("service", services)
def test_1T1ENA_fromDate(service, reporter_dataset):
# Query
query_params = {
'type': entity_type,
'fromDate': "1970-01-24T00:00:00+00:00"
}
h = {'Fiware-Service': service}

r = requests.get(query_url(), params=query_params, headers=h)
assert r.status_code == 200, r.text

# Expect only last N
expected_temperatures = list(range(23, 30))
expected_pressures = [t*10 for t in expected_temperatures]
expected_index = [
'1970-01-{:02}T00:00:00+00:00'.format(i+1) for i in expected_temperatures
]
assert len(expected_index) == 7
assert expected_index[0] == "1970-01-24T00:00:00+00:00"
assert expected_index[-1] == "1970-01-30T00:00:00+00:00"

# Assert
expected = {
'entityId': entity_id,
'index': expected_index,
'attributes': [
{
'attrName': pressure,
'values': expected_pressures,
},
{
'attrName': temperature,
'values': expected_temperatures,
}
]
}
obtained = r.json()
assert_1T1ENA_response(obtained, expected)

#see #353
@pytest.mark.parametrize("service", services)
@pytest.mark.parametrize("last", [1, 3, 10, 10000])
def test_1T1ENA_fromDate_and_last(service, last, reporter_dataset):
# Query
query_params = {
'type': entity_type,
'lastN': last,
'fromDate': "1970-01-24T00:00:00+00:00"
}
h = {'Fiware-Service': service}

r = requests.get(query_url(), params=query_params, headers=h)
assert r.status_code == 200, r.text

# Expect only last N
max_range = 7
if last < 7:
max_range = last
expected_temperatures = list(range(30 - max_range, 30))
expected_pressures = [t*10 for t in expected_temperatures]
expected_index = [
'1970-01-{:02}T00:00:00+00:00'.format(i+1) for i in expected_temperatures
]
assert len(expected_index) == max_range

# Assert
expected = {
'entityId': entity_id,
'index': expected_index,
'attributes': [
{
'attrName': pressure,
'values': expected_pressures,
},
{
'attrName': temperature,
'values': expected_temperatures,
}
]
}
obtained = r.json()
assert_1T1ENA_response(obtained, expected)

@pytest.mark.parametrize("service", services)
def test_1T1ENA_fromDate_toDate_with_quotes(service, reporter_dataset):
# Query
Expand Down
2 changes: 0 additions & 2 deletions src/tests/run_load_tests.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/usr/bin/env bash

docker build --cache-from smartsdk/quantumleap -t smartsdk/quantumleap ../../
c0c0n3 marked this conversation as resolved.
Show resolved Hide resolved

docker-compose up -d
docker-compose stop orion
docker-compose stop mongo
Expand Down