Skip to content

Commit

Permalink
adjusted and fixed existing tests
Browse files Browse the repository at this point in the history
Signed-off-by: Amelie Regl <[email protected]>
  • Loading branch information
heskil committed Dec 10, 2024
1 parent 70bd1a7 commit 8c39ae8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions apps/analyzer/metadata_analyzer/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def _send_Backups():

for result in results:
# Only send real backups
if result.is_backup <= 0:
if (result.is_backup is not None) and (result.is_backup <= 0):
continue

# Only send backups where the relevant data is not null
Expand Down Expand Up @@ -141,7 +141,7 @@ def simple_time_series_analysis(
variable, task_id, frequency, backup_type, window_size
):
result = Analyzer.time_series_analyzer.k_means_analyze(
variable, task_id, frequency, backup_type, window_size
variable, task_id, frequency, backup_type, window_size)

def simple_rule_based_analysis_creation_dates(alert_limit):
data = list(Analyzer.database.get_results())
Expand Down
4 changes: 2 additions & 2 deletions apps/analyzer/tests/test_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_update_data_all_types():

database = MockDatabase(mock_results, mock_tasks)
backend = MockBackend()
Analyzer.init(database, backend, None, None)
Analyzer.init(database, backend, None, None, None)
Analyzer.update_data()

assert backend.backups == [{
Expand Down Expand Up @@ -84,7 +84,7 @@ def test_update_data_not_a_backup():

database = MockDatabase([mock_result1], [])
backend = MockBackend()
Analyzer.init(database, backend, None, None)
Analyzer.init(database, backend, None, None, None)
Analyzer.update_data()

assert backend.backups == []
36 changes: 18 additions & 18 deletions apps/analyzer/tests/test_simple_rule_based_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def test_alert_full_start_date():
backend = MockBackend()
backend.set_latest_alert_id("SIZE_ALERT", "FULL", "2")
simple_rule_based_analyzer = SimpleRuleBasedAnalyzer(backend, 0.2, 0.2, 0.2, 0.2)
Analyzer.init(database, backend, None, simple_rule_based_analyzer)
Analyzer.init(database, backend, None, simple_rule_based_analyzer, None)
Analyzer.simple_rule_based_analysis(-1)

assert backend.size_alerts == [{
Expand Down Expand Up @@ -222,7 +222,7 @@ def test_alert_diff_start_date():
backend = MockBackend()
backend.set_latest_alert_id("SIZE_ALERT", "DIFFERENTIAL", "2")
simple_rule_based_analyzer = SimpleRuleBasedAnalyzer(backend, 0.2, 0.2, 0.2, 0.2)
Analyzer.init(database, backend, None, simple_rule_based_analyzer)
Analyzer.init(database, backend, None, simple_rule_based_analyzer, None)
Analyzer.simple_rule_based_analysis_diff(-1)

assert backend.size_alerts == [{
Expand Down Expand Up @@ -452,7 +452,7 @@ def test_alert_diff_start_date():
backend = MockBackend()
backend.set_latest_alert_id("SIZE_ALERT", "INCREMENTAL", "2")
simple_rule_based_analyzer = SimpleRuleBasedAnalyzer(backend, 0.2, 0.2, 0.2, 0.2)
Analyzer.init(database, backend, None, simple_rule_based_analyzer)
Analyzer.init(database, backend, None, simple_rule_based_analyzer, None)
Analyzer.simple_rule_based_analysis_inc(-1)

assert backend.size_alerts == [{
Expand Down Expand Up @@ -530,7 +530,7 @@ def test_alert_exact_time():
database = MockDatabase([mock_result1, mock_result2, mock_result3, mock_result4])
backend = MockBackend()
simple_rule_based_analyzer = SimpleRuleBasedAnalyzer(backend, 0.2, 0.2, 0.2, 0.2)
Analyzer.init(database, backend, None, simple_rule_based_analyzer)
Analyzer.init(database, backend, None, simple_rule_based_analyzer, None)
Analyzer.simple_rule_based_analysis_creation_dates(-1)

assert backend.creation_date_alerts == []
Expand All @@ -546,7 +546,7 @@ def test_alert_small_time_deviation():
database = MockDatabase([mock_result1, mock_result2, mock_result3, mock_result4, mock_result5])
backend = MockBackend()
simple_rule_based_analyzer = SimpleRuleBasedAnalyzer(backend, 0.2, 0.2, 0.2, 0.2)
Analyzer.init(database, backend, None, simple_rule_based_analyzer)
Analyzer.init(database, backend, None, simple_rule_based_analyzer, None)
Analyzer.simple_rule_based_analysis_creation_dates(-1)

assert backend.creation_date_alerts == []
Expand All @@ -559,7 +559,7 @@ def test_alert_time_on_the_limit():
database = MockDatabase([mock_result1, mock_result2])
backend = MockBackend()
simple_rule_based_analyzer = SimpleRuleBasedAnalyzer(backend, 0.2, 0.2, 0.2, 0.2)
Analyzer.init(database, backend, None, simple_rule_based_analyzer)
Analyzer.init(database, backend, None, simple_rule_based_analyzer, None)
Analyzer.simple_rule_based_analysis_creation_dates(-1)

assert backend.creation_date_alerts == []
Expand All @@ -575,7 +575,7 @@ def test_alert_moving_schedule():
database = MockDatabase([mock_result1, mock_result2, mock_result3, mock_result4, mock_result5])
backend = MockBackend()
simple_rule_based_analyzer = SimpleRuleBasedAnalyzer(backend, 0.2, 0.2, 0.2, 0.2)
Analyzer.init(database, backend, None, simple_rule_based_analyzer)
Analyzer.init(database, backend, None, simple_rule_based_analyzer, None)
Analyzer.simple_rule_based_analysis_creation_dates(-1)

assert backend.creation_date_alerts == []
Expand All @@ -591,7 +591,7 @@ def test_alert_time_midnight_no_alert():
database = MockDatabase([mock_result1, mock_result2, mock_result3, mock_result4, mock_result5])
backend = MockBackend()
simple_rule_based_analyzer = SimpleRuleBasedAnalyzer(backend, 0.2, 0.2, 0.2, 0.2)
Analyzer.init(database, backend, None, simple_rule_based_analyzer)
Analyzer.init(database, backend, None, simple_rule_based_analyzer, None)
Analyzer.simple_rule_based_analysis_creation_dates(-1)

assert backend.creation_date_alerts == []
Expand All @@ -606,7 +606,7 @@ def test_alert_unusual_time():
database = MockDatabase([mock_result1, mock_result2, mock_result3, mock_result4])
backend = MockBackend()
simple_rule_based_analyzer = SimpleRuleBasedAnalyzer(backend, 0.2, 0.2, 0.2, 0.2)
Analyzer.init(database, backend, None, simple_rule_based_analyzer)
Analyzer.init(database, backend, None, simple_rule_based_analyzer, None)
Analyzer.simple_rule_based_analysis_creation_dates(-1)

assert backend.creation_date_alerts == [{
Expand All @@ -625,7 +625,7 @@ def test_alert_two_different_schedules_same_task():
database = MockDatabase([mock_result1, mock_result2, mock_result3, mock_result4])
backend = MockBackend()
simple_rule_based_analyzer = SimpleRuleBasedAnalyzer(backend, 0.2, 0.2, 0.2, 0.2)
Analyzer.init(database, backend, None, simple_rule_based_analyzer)
Analyzer.init(database, backend, None, simple_rule_based_analyzer, None)
Analyzer.simple_rule_based_analysis_creation_dates(-1)

assert backend.creation_date_alerts == [{
Expand All @@ -643,7 +643,7 @@ def test_alert_time_midnight_alerts():
database = MockDatabase([mock_result1, mock_result2, mock_result3])
backend = MockBackend()
simple_rule_based_analyzer = SimpleRuleBasedAnalyzer(backend, 0.2, 0.2, 0.2, 0.2)
Analyzer.init(database, backend, None, simple_rule_based_analyzer)
Analyzer.init(database, backend, None, simple_rule_based_analyzer, None)
Analyzer.simple_rule_based_analysis_creation_dates(-1)

assert backend.creation_date_alerts == [{
Expand All @@ -666,7 +666,7 @@ def test_alert_creation_date_unordered():
database = MockDatabase([mock_result4, mock_result2, mock_result3, mock_result1])
backend = MockBackend()
simple_rule_based_analyzer = SimpleRuleBasedAnalyzer(backend, 0.2, 0.2, 0.2, 0.2)
Analyzer.init(database, backend, None, simple_rule_based_analyzer)
Analyzer.init(database, backend, None, simple_rule_based_analyzer, None)
Analyzer.simple_rule_based_analysis_creation_dates(-1)

assert backend.creation_date_alerts == [{
Expand All @@ -689,7 +689,7 @@ def test_alert_creation_date_different_tasks():
database = MockDatabase([mock_result4, mock_result2, mock_result3, mock_result1])
backend = MockBackend()
simple_rule_based_analyzer = SimpleRuleBasedAnalyzer(backend, 0.2, 0.2, 0.2, 0.2)
Analyzer.init(database, backend, None, simple_rule_based_analyzer)
Analyzer.init(database, backend, None, simple_rule_based_analyzer, None)
Analyzer.simple_rule_based_analysis_creation_dates(-1)

assert backend.creation_date_alerts == [{
Expand All @@ -709,7 +709,7 @@ def test_alert_latest_creation_date():
backend = MockBackend()
backend.set_latest_alert_id("CREATION_DATE_ALERT", None, "3")
simple_rule_based_analyzer = SimpleRuleBasedAnalyzer(backend, 0.2, 0.2, 0.2, 0.2)
Analyzer.init(database, backend, None, simple_rule_based_analyzer)
Analyzer.init(database, backend, None, simple_rule_based_analyzer, None)
Analyzer.simple_rule_based_analysis_creation_dates(-1)

assert backend.creation_date_alerts == [{
Expand All @@ -728,7 +728,7 @@ def test_storage_fill_alert_empty():
database = MockDatabase([], [], [mock_data_store1])
backend = MockBackend()
simple_rule_based_analyzer = SimpleRuleBasedAnalyzer(backend, 0.2, 0.2, 0.2, 0.2)
Analyzer.init(database, backend, None, simple_rule_based_analyzer)
Analyzer.init(database, backend, None, simple_rule_based_analyzer, None)
Analyzer.simple_rule_based_analysis_storage_capacity(-1)

assert backend.storage_fill_alerts == []
Expand All @@ -745,7 +745,7 @@ def test_storage_fill_alert_enough_capacity_left():
)
backend = MockBackend()
simple_rule_based_analyzer = SimpleRuleBasedAnalyzer(backend, 0.2, 0.2, 0.2, 0.2)
Analyzer.init(database, backend, None, simple_rule_based_analyzer)
Analyzer.init(database, backend, None, simple_rule_based_analyzer, None)
Analyzer.simple_rule_based_analysis_storage_capacity(-1)

assert backend.storage_fill_alerts == []
Expand All @@ -762,7 +762,7 @@ def test_storage_fill_alert_enough_capacity_left():
)
backend = MockBackend()
simple_rule_based_analyzer = SimpleRuleBasedAnalyzer(backend, 0.2, 0.2, 0.2, 0.2)
Analyzer.init(database, backend, None, simple_rule_based_analyzer)
Analyzer.init(database, backend, None, simple_rule_based_analyzer, None)
Analyzer.simple_rule_based_analysis_storage_capacity(-1)

assert backend.storage_fill_alerts == [
Expand Down Expand Up @@ -798,7 +798,7 @@ def test_storage_fill_alert_missing_data():
)
backend = MockBackend()
simple_rule_based_analyzer = SimpleRuleBasedAnalyzer(backend, 0.2, 0.2, 0.2, 0.2)
Analyzer.init(database, backend, None, simple_rule_based_analyzer)
Analyzer.init(database, backend, None, simple_rule_based_analyzer, None)
Analyzer.simple_rule_based_analysis_storage_capacity(-1)

assert backend.storage_fill_alerts == []

0 comments on commit 8c39ae8

Please sign in to comment.