Пример #1
0
def test_table_view(app, test_request_context):
    @default_view(app, WidgetTestModel)
    @app.route("/dummy_view/<object_id>")
    def dummy_view(object_id):
        pass

    request_started.send(app)  # needed for deferJS tag
    columns = ["name", "price"]
    view = MainTableView(columns)

    model1 = WidgetTestModel(id=1, name="Renault Megane", price=10000)
    model2 = WidgetTestModel(id=2, name="Peugeot 308", price=12000)
    models = [model1, model2]
    res = view.render(models)

    assert model1._display_value_called
    assert model2._display_value_called
    assert "Renault Megane" in res
    assert "10000" in res
Пример #2
0
def test_table_view(app, test_request_context):
    @default_view(app, WidgetTestModel)
    @app.route("/dummy_view/<object_id>")
    def dummy_view(object_id):
        pass

    request_started.send(app)  # needed for deferJS tag
    columns = ["name", "price"]
    view = MainTableView(columns)

    model1 = WidgetTestModel(id=1, name="Renault Megane", price=10000)
    model2 = WidgetTestModel(id=2, name="Peugeot 308", price=12000)
    models = [model1, model2]
    res = view.render(models)

    assert model1._display_value_called
    assert model2._display_value_called
    assert "Renault Megane" in res
    assert "10000" in res
Пример #3
0
def test_table_view(app: Flask, test_request_context: RequestContext) -> None:
    @default_view(app, WidgetTestModel)
    @app.route("/dummy_view/<object_id>")
    def dummy_view(object_id):
        pass

    request_started.send(app)  # needed for deferJS tag
    columns = [{"name": "name"}, {"name": "price"}]
    view = MainTableView(columns)

    model1 = WidgetTestModel(id=1, name="Renault Megane", price=10000)
    model2 = WidgetTestModel(id=2, name="Peugeot 308", price=12000)
    models = [model1, model2]
    # pyre-fixme[6]: Expected `List[Entity]` for 1st param but got
    #  `List[WidgetTestModel]`.
    res = view.render(models)

    assert model1._display_value_called
    assert model2._display_value_called
    assert "Renault Megane" in res
    assert "10000" in res