-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(graphs): filter data points by date filters
In order to narrow down graphs range, date filters were added (by start and end date) with ability to quickly switch between 1,3 and 6 recent months. Last 3 months filter is on by default. closes: #474
- Loading branch information
Showing
5 changed files
with
189 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
argus/backend/tests/results_service/test_results_service.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
from datetime import datetime, timedelta | ||
from uuid import uuid4 | ||
|
||
import pytest | ||
from argus.backend.models.result import ArgusGenericResultMetadata, ArgusGenericResultData, ColumnMetadata | ||
from argus.backend.service.results_service import ResultsService | ||
|
||
@pytest.fixture | ||
def setup_data(argus_db): | ||
test_id = uuid4() | ||
table = ArgusGenericResultMetadata( | ||
test_id=test_id, | ||
name='Test Table', | ||
columns_meta=[ | ||
ColumnMetadata(name='col1', unit='ms', type='FLOAT', higher_is_better=False) | ||
], | ||
rows_meta=['row1'], | ||
validation_rules={} | ||
) | ||
data = [ | ||
ArgusGenericResultData( | ||
test_id=test_id, | ||
name=table.name, | ||
run_id=uuid4(), | ||
column='col1', | ||
row='row1', | ||
sut_timestamp=datetime.today() - timedelta(days=10), | ||
value=100.0, | ||
status='UNSET' | ||
).save(), | ||
ArgusGenericResultData( | ||
test_id=test_id, | ||
name=table.name, | ||
run_id=uuid4(), | ||
column='col1', | ||
row='row1', | ||
sut_timestamp=datetime.today() - timedelta(days=5), | ||
value=150.0, | ||
status='UNSET' | ||
).save(), | ||
ArgusGenericResultData( | ||
test_id=test_id, | ||
name=table.name, | ||
run_id=uuid4(), | ||
column='col1', | ||
row='row1', | ||
sut_timestamp=datetime.today() - timedelta(days=1), | ||
value=200.0, | ||
status='UNSET' | ||
).save() | ||
] | ||
return test_id, table, data | ||
|
||
|
||
def test_results_service_should_return_results_within_date_range(setup_data): | ||
test_id, table, data = setup_data | ||
service = ResultsService() | ||
|
||
start_date = datetime.today() - timedelta(days=7) | ||
end_date = datetime.today() - timedelta(days=2) | ||
|
||
filtered_data = service._get_tables_data( | ||
test_id=test_id, | ||
table_name=table.name, | ||
ignored_runs=[], | ||
start_date=start_date, | ||
end_date=end_date | ||
) | ||
|
||
assert len(filtered_data) == 1 | ||
assert filtered_data[0].value == 150.0 | ||
|
||
def test_results_service_should_return_no_results_outside_date_range(setup_data): | ||
test_id, table, data = setup_data | ||
service = ResultsService() | ||
|
||
start_date = datetime.today() - timedelta(days=20) | ||
end_date = datetime.today() - timedelta(days=15) | ||
|
||
filtered_data = service._get_tables_data( | ||
test_id=test_id, | ||
table_name=table.name, | ||
ignored_runs=[], | ||
start_date=start_date, | ||
end_date=end_date | ||
) | ||
|
||
assert len(filtered_data) == 0 | ||
|
||
def test_results_service_should_return_all_results_with_no_date_range(setup_data): | ||
test_id, table, data = setup_data | ||
service = ResultsService() | ||
|
||
filtered_data = service._get_tables_data( | ||
test_id=test_id, | ||
table_name=table.name, | ||
ignored_runs=[] | ||
) | ||
|
||
assert len(filtered_data) == 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters