def test_database_insert_001(database, cause): """Test database basic insert. Insert one Snippet resource into the database. """ collection = Content.get_collection(Snippet.REMOVE) database.insert(collection) cause.assert_called_once_with('201 Created', 'content created') assert collection == TDatabase.get_snippets() assert len(TDatabase.get_snippets()) == 1
def test_database_insert_002(database, cause): """Test SqliteDb basic insert. Insert four Snippet resources into the database. This verifies with multiple items in tag and link lists. """ collection = Content.get_collection(Snippet.REMOVE) collection.migrate(Content.get_collection(Snippet.FORCED)) collection.migrate(Content.get_collection(Snippet.EXITED)) collection.migrate(Content.get_collection(Snippet.NETCAT)) database.insert(collection) cause.assert_called_once_with('201 Created', 'content created') assert collection == TDatabase.get_snippets() assert len(TDatabase.get_snippets()) == 4
def test_database_delete_001(database, cause, mocker): """Test database basic delete. Delete one row from database with long digest. """ collection = Content.get_collection(Snippet.REMOVE) collection.migrate(Content.get_collection(Snippet.FORCED)) database.insert(collection) database.delete('53908d68425c61dc310c9ce49d530bd858c5be197990491ca20dbe888e6deac5') results = [] results.append(mocker.call('201 Created', 'content created')) results.append(mocker.call('204 No Content', 'content deleted successfully')) cause.assert_has_calls(results) assert TDatabase.get_snippets() == Content.get_collection(Snippet.REMOVE) assert len(TDatabase.get_snippets()) == 1