|
@@ -30,15 +30,15 @@ def result_sorted(result):
|
|
|
return result
|
|
|
|
|
|
|
|
|
-@freeze_time("2018-12-11 03:21:34")
|
|
|
+@freeze_time("2018-12-11 03:21:00")
|
|
|
def test_round_range():
|
|
|
start, end, interval = _get_constrained_date_range({"statsPeriod": "2d"})
|
|
|
assert start == datetime(2018, 12, 9, 4, tzinfo=pytz.utc)
|
|
|
- assert end == datetime(2018, 12, 11, 4, tzinfo=pytz.utc)
|
|
|
+ assert end == datetime(2018, 12, 11, 3, 22, tzinfo=pytz.utc)
|
|
|
|
|
|
start, end, interval = _get_constrained_date_range({"statsPeriod": "2d", "interval": "1d"})
|
|
|
assert start == datetime(2018, 12, 10, tzinfo=pytz.utc)
|
|
|
- assert end == datetime(2018, 12, 12, tzinfo=pytz.utc)
|
|
|
+ assert end == datetime(2018, 12, 11, 3, 22, tzinfo=pytz.utc)
|
|
|
|
|
|
|
|
|
def test_invalid_interval():
|
|
@@ -126,7 +126,8 @@ def test_hourly_rounded_start():
|
|
|
actual_timestamps = _get_timestamps(query)
|
|
|
|
|
|
assert actual_timestamps[0] == "2021-03-08T09:00:00Z"
|
|
|
- assert len(actual_timestamps) == 60
|
|
|
+ assert actual_timestamps[-1] == "2021-03-08T09:34:00Z"
|
|
|
+ assert len(actual_timestamps) == 35
|
|
|
|
|
|
# in this case "45m" means from 08:49:00-09:34:00, but since we round start/end
|
|
|
# to hours, we extend the start time to 08:00:00.
|
|
@@ -135,7 +136,8 @@ def test_hourly_rounded_start():
|
|
|
actual_timestamps = _get_timestamps(query)
|
|
|
|
|
|
assert actual_timestamps[0] == "2021-03-08T08:00:00Z"
|
|
|
- assert len(actual_timestamps) == 120
|
|
|
+ assert actual_timestamps[-1] == "2021-03-08T09:34:00Z"
|
|
|
+ assert len(actual_timestamps) == 95
|
|
|
|
|
|
|
|
|
def test_rounded_end():
|
|
@@ -221,6 +223,8 @@ def test_massage_empty():
|
|
|
result_timeseries = []
|
|
|
|
|
|
expected_result = {
|
|
|
+ "start": "2020-12-18T00:00:00Z",
|
|
|
+ "end": "2020-12-18T11:15:00Z",
|
|
|
"query": "",
|
|
|
"intervals": ["2020-12-18T00:00:00Z"],
|
|
|
"groups": [],
|
|
@@ -241,6 +245,8 @@ def test_massage_unbalanced_results():
|
|
|
result_timeseries = []
|
|
|
|
|
|
expected_result = {
|
|
|
+ "start": "2020-12-18T00:00:00Z",
|
|
|
+ "end": "2020-12-18T11:15:00Z",
|
|
|
"query": "",
|
|
|
"intervals": ["2020-12-18T00:00:00Z"],
|
|
|
"groups": [
|
|
@@ -266,6 +272,8 @@ def test_massage_unbalanced_results():
|
|
|
]
|
|
|
|
|
|
expected_result = {
|
|
|
+ "start": "2020-12-18T00:00:00Z",
|
|
|
+ "end": "2020-12-18T11:15:00Z",
|
|
|
"query": "",
|
|
|
"intervals": ["2020-12-18T00:00:00Z"],
|
|
|
"groups": [
|
|
@@ -295,6 +303,8 @@ def test_massage_simple_timeseries():
|
|
|
]
|
|
|
|
|
|
expected_result = {
|
|
|
+ "start": "2020-12-17T12:00:00Z",
|
|
|
+ "end": "2020-12-18T11:15:00Z",
|
|
|
"query": "",
|
|
|
"intervals": [
|
|
|
"2020-12-17T12:00:00Z",
|
|
@@ -323,6 +333,8 @@ def test_massage_exact_timeseries():
|
|
|
]
|
|
|
|
|
|
expected_result = {
|
|
|
+ "start": "2020-12-17T12:00:00Z",
|
|
|
+ "end": "2020-12-18T12:00:00Z",
|
|
|
"query": "",
|
|
|
"intervals": [
|
|
|
"2020-12-17T12:00:00Z",
|
|
@@ -368,6 +380,8 @@ def test_massage_groupby_timeseries():
|
|
|
]
|
|
|
|
|
|
expected_result = {
|
|
|
+ "start": "2020-12-17T12:00:00Z",
|
|
|
+ "end": "2020-12-18T11:15:00Z",
|
|
|
"query": "",
|
|
|
"intervals": [
|
|
|
"2020-12-17T12:00:00Z",
|
|
@@ -438,6 +452,8 @@ def test_massage_virtual_groupby_timeseries():
|
|
|
]
|
|
|
|
|
|
expected_result = {
|
|
|
+ "start": "2020-12-17T18:00:00Z",
|
|
|
+ "end": "2020-12-18T13:26:00Z",
|
|
|
"query": "",
|
|
|
"intervals": [
|
|
|
"2020-12-17T18:00:00Z",
|
|
@@ -504,6 +520,8 @@ def test_nan_duration():
|
|
|
]
|
|
|
|
|
|
expected_result = {
|
|
|
+ "start": "2020-12-17T12:00:00Z",
|
|
|
+ "end": "2020-12-18T11:15:00Z",
|
|
|
"query": "",
|
|
|
"intervals": [
|
|
|
"2020-12-17T12:00:00Z",
|