Ejemplo n.º 1
0
def test_delete_row(send_mock, data_fixture):
    user = data_fixture.create_user()
    user_2 = data_fixture.create_user()
    table = data_fixture.create_database_table(name='Car', user=user)
    data_fixture.create_text_field(table=table, name='Name', text_default='Test')

    handler = RowHandler()
    model = table.get_model()
    row = handler.create_row(user=user, table=table)
    handler.create_row(user=user, table=table)

    with pytest.raises(UserNotInGroupError):
        handler.delete_row(user=user_2, table=table, row_id=row.id)

    with pytest.raises(RowDoesNotExist):
        handler.delete_row(user=user, table=table, row_id=99999)

    row_id = row.id
    handler.delete_row(user=user, table=table, row_id=row.id)
    assert model.objects.all().count() == 1
    send_mock.assert_called_once()
    assert send_mock.call_args[1]['row_id'] == row_id
    assert send_mock.call_args[1]['row']
    assert send_mock.call_args[1]['user'].id == user.id
    assert send_mock.call_args[1]['table'].id == table.id
    assert send_mock.call_args[1]['model']._generated_table_model
Ejemplo n.º 2
0
def test_delete_row(data_fixture):
    user = data_fixture.create_user()
    user_2 = data_fixture.create_user()
    table = data_fixture.create_database_table(name='Car', user=user)
    data_fixture.create_text_field(table=table, name='Name', text_default='Test')

    handler = RowHandler()
    model = table.get_model()
    row = handler.create_row(user=user, table=table)
    handler.create_row(user=user, table=table)

    with pytest.raises(UserNotInGroupError):
        handler.delete_row(user=user_2, table=table, row_id=row.id)

    with pytest.raises(RowDoesNotExist):
        handler.delete_row(user=user, table=table, row_id=99999)

    handler.delete_row(user=user, table=table, row_id=row.id)
    assert model.objects.all().count() == 1
Ejemplo n.º 3
0
def test_delete_row(before_send_mock, send_mock, data_fixture):
    user = data_fixture.create_user()
    user_2 = data_fixture.create_user()
    table = data_fixture.create_database_table(name="Car", user=user)
    data_fixture.create_text_field(table=table,
                                   name="Name",
                                   text_default="Test")

    handler = RowHandler()
    model = table.get_model()
    row = handler.create_row(user=user, table=table)
    handler.create_row(user=user, table=table)

    with pytest.raises(UserNotInGroup):
        handler.delete_row(user=user_2, table=table, row_id=row.id)

    with pytest.raises(RowDoesNotExist):
        handler.delete_row(user=user, table=table, row_id=99999)

    row_id = row.id
    handler.delete_row(user=user, table=table, row_id=row.id)
    assert model.objects.all().count() == 1

    before_send_mock.assert_called_once()
    assert before_send_mock.call_args[1]["row"]
    assert before_send_mock.call_args[1]["user"].id == user.id
    assert before_send_mock.call_args[1]["table"].id == table.id
    assert before_send_mock.call_args[1]["model"]._generated_table_model

    send_mock.assert_called_once()
    assert send_mock.call_args[1]["row_id"] == row_id
    assert send_mock.call_args[1]["row"]
    assert send_mock.call_args[1]["user"].id == user.id
    assert send_mock.call_args[1]["table"].id == table.id
    assert send_mock.call_args[1]["model"]._generated_table_model
    assert send_mock.call_args[1][
        "before_return"] == before_send_mock.return_value