コード例 #1
0
def test_typeahead_api_unit_only(rf, typeahead_test_objects, typeahead_view):
    unit = typeahead_test_objects["unit"]
    sauna = typeahead_test_objects["sauna"]

    # Test just the unit; the resource must not be there
    response = typeahead_view(request=rf.get("/", {"input": "testi", "types": "unit"}))
    assert_response_does_not_contain(response, '"id":"%s"' % sauna.id)
    assert_response_contains(response, '"id":"%s"' % unit.id)
コード例 #2
0
def test_typeahead_api_unlimited(rf, typeahead_test_objects, typeahead_view):
    unit = typeahead_test_objects["unit"]
    sauna = typeahead_test_objects["sauna"]

    # Test unlimited requested objects; "testi" should get both the resource and the unit
    response = typeahead_view(request=rf.get("/", {"input": "testi"}))
    assert_response_contains(response, '"id":"%s"' % sauna.id)
    assert_response_contains(response, '"id":"%s"' % unit.id)
コード例 #3
0
def test_typeahead_api_unlimited(rf, typeahead_test_objects, typeahead_view):
    unit = typeahead_test_objects["unit"]
    sauna = typeahead_test_objects["sauna"]

    # Test unlimited requested objects; "testi" should get both the resource and the unit
    response = typeahead_view(request=rf.get("/", {"input": "testi"}))
    assert_response_contains(response, '"id":"%s"' % sauna.id)
    assert_response_contains(response, '"id":"%s"' % unit.id)
コード例 #4
0
def test_typeahead_api_unit_only(rf, typeahead_test_objects, typeahead_view):
    unit = typeahead_test_objects["unit"]
    sauna = typeahead_test_objects["sauna"]

    # Test just the unit; the resource must not be there
    response = typeahead_view(request=rf.get("/", {
        "input": "testi",
        "types": "unit"
    }))
    assert_response_does_not_contain(response, '"id":"%s"' % sauna.id)
    assert_response_contains(response, '"id":"%s"' % unit.id)
コード例 #5
0
def test_period_inline_containing_admins_work(rf, admin_user, model, space_resource, test_unit):
    if model is Resource:
        instance = space_resource
    elif model is Unit:
        instance = test_unit
    else:
        raise NotImplementedError("Unexpected parametrization")

    admin = admin_site._registry[model]  # Sorry for accessing a private member :(
    request = rf.get("/")
    request.user = admin_user
    response = admin.change_view(request, instance.pk)
    assert_response_contains(response, prefix_weekday(2, "opens"))  # should have a weekday field
コード例 #6
0
def test_period_inline_containing_admins_work(rf, admin_user, model,
                                              space_resource, test_unit):
    if model is Resource:
        instance = space_resource
    elif model is Unit:
        instance = test_unit
    else:
        raise NotImplementedError("Unexpected parametrization")

    admin = admin_site._registry[
        model]  # Sorry for accessing a private member :(
    request = rf.get("/")
    request.user = admin_user
    response = admin.change_view(request, instance.pk)
    assert_response_contains(response, prefix_weekday(
        2, "opens"))  # should have a weekday field