def test_update_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(database=database) handler = TableHandler() with pytest.raises(UserNotInGroupError): handler.update_table(user=user_2, table=table, name='Test 1') handler.update_table(user=user, table=table, name='Test 1') table.refresh_from_db() assert table.name == 'Test 1'
def test_update_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(database=database) handler = TableHandler() with pytest.raises(UserNotInGroup): handler.update_table(user=user_2, table=table, name="Test 1") handler.update_table(user=user, table=table, name="Test 1") 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 table.refresh_from_db() assert table.name == "Test 1"