def test_storage_db_clear_not_metadata(): node_storage = CrawlerNodeStorage(storage_filepath=IN_MEMORY_FILEPATH) # store some data node = create_random_mock_node() node_storage.store_node_metadata(node=node) state = create_specific_mock_state() node_storage.store_state_metadata(state=state) teacher_checksum = '0x123456789' node_storage.store_current_teacher(teacher_checksum) verify_all_db_tables(node_storage.db_conn, expect_empty=False) # only clear certificates data node_storage.clear(metadata=False, certificates=True) # db tables should not have been cleared verify_all_db_tables(node_storage.db_conn, expect_empty=False)
def test_storage_db_clear_only_metadata_not_certificates(sqlite_connection): node_storage = CrawlerNodeStorage(storage_filepath=IN_MEMORY_FILEPATH) # store some data node = create_random_mock_node() node_storage.store_node_metadata(node=node) state = create_specific_mock_state() node_storage.store_state_metadata(state=FleetSensor.abridged_state_details(state)) teacher_checksum = '0x123456789' node_storage.store_current_teacher(teacher_checksum) verify_all_db_tables(sqlite_connection, expect_empty=False) # clear metadata tables node_storage.clear(metadata=True, certificates=False) # db tables should have been cleared verify_all_db_tables(sqlite_connection, expect_empty=True)
def test_storage_db_clear(): node_storage = CrawlerNodeStorage(storage_filepath=IN_MEMORY_FILEPATH) verify_all_db_tables_exist(node_storage.db_conn) # store some data node = create_random_mock_node() node_storage.store_node_metadata(node=node) state = create_specific_mock_state() node_storage.store_state_metadata( state=FleetStateTracker.abridged_state_details(state)) teacher_checksum = '0x123456789' node_storage.store_current_teacher(teacher_checksum) verify_all_db_tables(node_storage.db_conn, expect_empty=False) # clear tables node_storage.clear() # db tables should have been cleared verify_all_db_tables(node_storage.db_conn, expect_empty=True)