def test_0009(req, with_arrays, before, after):  # pragma: postgres
    orm_models = get_models(req)
    valid = int("wtf" not in before)

    view = View.objects.create(model_name="array.ArrayModel", query=before)
    migration_helpers.forwards_0009(View)
    view.refresh_from_db()
    assert view.query == after
    assert len(BoundQuery.bind(view.get_query(), orm_models).valid_filters) == valid
Beispiel #2
0
def test_0009_multiple_filters(models):
    view = View.objects.create(
        model_name="core.Product",
        query="name__is_null=True&boat__gt=1&name__is_null__equals=True",
    )
    migration_helpers.forwards_0009(View)
    view.refresh_from_db()
    assert view.query == "name__is_null=IsNull&boat__gt=1&name__is_null__equals=IsNull"
    assert len(BoundQuery.bind(view.get_query(), models).valid_filters) == 3
Beispiel #3
0
def test_0009(models, before, after):
    valid = int("wtf" not in before)

    view = View.objects.create(model_name="core.Product", query=before)
    migration_helpers.forwards_0009(View)
    view.refresh_from_db()
    assert view.query == after
    assert len(BoundQuery.bind(view.get_query(),
                               models).valid_filters) == valid

    view = View.objects.create(model_name="core.SKU",
                               query=f"product__{before}")
    migration_helpers.forwards_0009(View)
    view.refresh_from_db()
    assert view.query == f"product__{after}"
    assert len(BoundQuery.bind(view.get_query(),
                               models).valid_filters) == valid
Beispiel #4
0
def test_0009_no_filters():
    view = View.objects.create(model_name="core.Product")
    migration_helpers.forwards_0009(View)
    view.refresh_from_db()
    assert view.query == ""
def forwards(apps, schema_editor):
    View = apps.get_model("data_browser", "View")
    if View.objects.exists():
        from data_browser.migration_helpers import forwards_0009

        forwards_0009(View)