def test_delete_database_table(send_mock, data_fixture): user = data_fixture.create_user() user_2 = data_fixture.create_user() group = data_fixture.create_group(user=user) database = data_fixture.create_database_application(group=group) table = data_fixture.create_database_table(user=user, database=database) handler = TableHandler() with pytest.raises(UserNotInGroup): handler.delete_table(user=user_2, table=table) assert Table.objects.all().count() == 1 assert f"database_table_{table.id}" in connection.introspection.table_names( ) table_id = table.id handler.delete_table(user=user, table=table) send_mock.assert_called_once() assert send_mock.call_args[1]["table_id"] == table_id assert send_mock.call_args[1]["user"].id == user.id assert Table.objects.all().count() == 0 assert f"database_table_{table.id}" not in connection.introspection.table_names( )
def test_delete_database_table(data_fixture): user = data_fixture.create_user() user_2 = data_fixture.create_user() group = data_fixture.create_group(user=user) database = data_fixture.create_database_application(group=group) table = data_fixture.create_database_table(user=user, database=database) handler = TableHandler() with pytest.raises(UserNotInGroupError): handler.delete_table(user=user_2, table=table) assert Table.objects.all().count() == 1 assert f'database_table_{table.id}' in connection.introspection.table_names() handler.delete_table(user=user, table=table) assert Table.objects.all().count() == 0 assert f'database_table_{table.id}' not in connection.introspection.table_names()