def test_prune(local_config): """Tests the prune() functionality.""" manager = StateManager(local_config) manager.set_checkpoint('DEFGHIJK', 'default', 'DONE', '2020-01-15T12:00:00') manager.set_checkpoint('ABCDEFGH', 'default', 'DONE', '2020-01-10T12:00:00') manager.set_checkpoint('MNOPQRST', 'default', 'DONE', '2020-01-15T12:00:00') manager.set_checkpoint('JKLMNOPQ', 'default', 'DONE', '2020-01-10T14:00:00') manager.prune("2020-01-12T00:00:00") return_list = manager.get_previous_hashes('default') assert return_list == ['DEFGHIJK', 'MNOPQRST']
def test_exception_handling(local_config): """Tests that OperationalError is handled by all methods without throwing an exception.""" manager = StateManager(local_config) manager._persistor._cursor_factory = BreakingCursor manager.set_checkpoint('ABCDEFGH', 'default', 'ALPHA') assert manager.get_previous_hashes('default') == [] manager.prune("2020-01-12T00:00:00") manager.add_report_item(6, 'default', {'keyval': 1}) assert manager.get_current_report_items(6, 'default') == [] manager.clear_report_items(6, 'default')
def test_prune(local_config): """Test the prune() API.""" manager = StateManager(local_config) manager.prune("2020-01-01T00:00:00") assert getattr(manager._persistor, "_sc", 0) == 0 assert getattr(manager._persistor, "_gph", 0) == 0 assert getattr(manager._persistor, "_guh", 0) == 0 assert getattr(manager._persistor, "_p", 0) == 1 assert getattr(manager._persistor, "_ari", 0) == 0 assert getattr(manager._persistor, "_gcri", 0) == 0 assert getattr(manager._persistor, "_cri", 0) == 0