当前位置: 首页>>代码示例>>Python>>正文


Python app.app方法代码示例

本文整理汇总了Python中app.app方法的典型用法代码示例。如果您正苦于以下问题:Python app.app方法的具体用法?Python app.app怎么用?Python app.app使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app的用法示例。


在下文中一共展示了app.app方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_bad_items

# 需要导入模块: import app [as 别名]
# 或者: from app import app [as 别名]
def test_bad_items(self) -> None:
        """Test bad output from view.

        If our view returns JSON that does not match openapi.yaml schema,
        then we should render a 500 error.
        """
        with mock.patch("app.ITEMS", ["foo", "bar"]):
            res = self.testapp.get("/", status=500)
        self.assertEqual(
            res.json,
            [
                {
                    "exception": "ValidationError",
                    "message": "'foo' is not of type object",
                },
                {
                    "exception": "ValidationError",
                    "message": "'bar' is not of type object",
                },
            ],
        ) 
开发者ID:Pylons,项目名称:pyramid_openapi3,代码行数:23,代码来源:tests.py

示例2: test_basic_query

# 需要导入模块: import app [as 别名]
# 或者: from app import app [as 别名]
def test_basic_query():
    client = TestClient(app)
    response = client.get(url=f"http://localhost/v1/pois/osm:way:63178753?lang=fr",)

    assert response.status_code == 200
    assert response.headers.get("Access-Control-Allow-Origin") == "*"

    resp = response.json()

    assert resp["id"] == "osm:way:63178753"
    assert resp["name"] == "Musée d'Orsay"
    assert resp["local_name"] == "Musée d'Orsay"
    assert resp["class_name"] == "museum"
    assert resp["subclass_name"] == "museum"
    assert resp["address"]["label"] == "1 Rue de la Légion d'Honneur (Paris)"
    assert resp["blocks"][0]["type"] == "opening_hours"
    assert resp["blocks"][1]["type"] == "phone"
    assert resp["blocks"][0]["is_24_7"] == False 
开发者ID:QwantResearch,项目名称:idunn,代码行数:20,代码来源:test_api.py

示例3: test_lang

# 需要导入模块: import app [as 别名]
# 或者: from app import app [as 别名]
def test_lang():
    client = TestClient(app)
    response = client.get(url=f"http://localhost/v1/pois/osm:way:63178753?lang=it",)

    assert response.status_code == 200

    resp = response.json()

    assert resp["id"] == "osm:way:63178753"
    assert resp["name"] == "Museo d'Orsay"
    assert resp["local_name"] == "Musée d'Orsay"
    assert resp["class_name"] == "museum"
    assert resp["subclass_name"] == "museum"
    assert resp["address"]["label"] == "1 Rue de la Légion d'Honneur (Paris)"
    assert resp["blocks"][0]["type"] == "opening_hours"
    assert resp["blocks"][1]["type"] == "phone"
    assert resp["blocks"][0]["is_24_7"] == False 
开发者ID:QwantResearch,项目名称:idunn,代码行数:19,代码来源:test_api.py

示例4: test_contact_phone

# 需要导入模块: import app [as 别名]
# 或者: from app import app [as 别名]
def test_contact_phone():
    """
    The louvre museum has the tag 'contact:phone'
    We test this tag is correct here
    """
    client = TestClient(app)
    response = client.get(url=f"http://localhost/v1/pois/osm:relation:7515426",)

    assert response.status_code == 200

    resp = response.json()

    assert resp["id"] == "osm:relation:7515426"
    assert resp["name"] == "Louvre Museum"
    assert resp["local_name"] == "Musée du Louvre"
    assert resp["class_name"] == "museum"
    assert resp["subclass_name"] == "museum"
    assert resp["blocks"][1]["type"] == "phone"
    assert resp["blocks"][1]["url"] == "tel:+33140205229"
    assert resp["blocks"][1]["international_format"] == "+33 1 40 20 52 29"
    assert resp["blocks"][1]["local_format"] == "01 40 20 52 29" 
开发者ID:QwantResearch,项目名称:idunn,代码行数:23,代码来源:test_api.py

示例5: test_block_null

# 需要导入模块: import app [as 别名]
# 或者: from app import app [as 别名]
def test_block_null():
    """
    The query corresponding to POI id 'osm:way:55984117' doesn't contain any 'opening_hour' block (the block is null).
    We check the API answer is ok (status_code == 200) with the correct fields.
    """
    client = TestClient(app)
    response = client.get(url=f"http://localhost/v1/pois/osm:way:55984117?lang=fr",)

    assert response.status_code == 200

    resp = response.json()

    assert resp["id"] == "osm:way:55984117"
    assert resp["name"] == "Église Notre-Dame-des-Blancs-Manteaux"
    assert resp["local_name"] == "Église Notre-Dame-des-Blancs-Manteaux"
    assert resp["class_name"] == "place_of_worship"
    assert resp["subclass_name"] == "place_of_worship"
    assert resp["blocks"][0]["type"] == "phone"
    assert resp["address"]["label"] == "Rue Aubriot (Paris)"
    assert resp["blocks"][0]["url"] == "tel:+33142720937" 
开发者ID:QwantResearch,项目名称:idunn,代码行数:22,代码来源:test_api.py

示例6: test_orsay_images

# 需要导入模块: import app [as 别名]
# 或者: from app import app [as 别名]
def test_orsay_images():
    client = TestClient(app)
    response = client.get(url=f"http://localhost/v1/places/osm:way:63178753?lang=fr",)

    assert response.status_code == 200
    assert response.headers.get("Access-Control-Allow-Origin") == "*"
    resp = response.json()

    assert resp["blocks"][4]["type"] == "images"
    assert resp["blocks"][4]["images"] == [
        {
            "url": "https://s2.qwant.com/thumbr/0x0/3/9/43f34b2898978cd1c6cbfa90766ef432d761f02d31f32120eff6db12f616b5/1024px-Logo_musée_d'Orsay.png?u=https%3A%2F%2Fupload.wikimedia.org%2Fwikipedia%2Ffr%2Fthumb%2F7%2F73%2FLogo_mus%25C3%25A9e_d%2527Orsay.png%2F1024px-Logo_mus%25C3%25A9e_d%2527Orsay.png&q=0&b=1&p=0&a=0",
            "alt": "Musée d'Orsay",
            "credits": "",
            "source_url": "https://upload.wikimedia.org/wikipedia/fr/thumb/7/73/Logo_mus%C3%A9e_d%27Orsay.png/1024px-Logo_mus%C3%A9e_d%27Orsay.png",
        },
    ] 
开发者ID:QwantResearch,项目名称:idunn,代码行数:19,代码来源:test_wiki_images.py

示例7: test_image_for_unnamed_poi

# 需要导入模块: import app [as 别名]
# 或者: from app import app [as 别名]
def test_image_for_unnamed_poi():
    client = TestClient(app)
    response = client.get(url=f"http://localhost/v1/places/osm:way:63178753?lang=fr",)

    assert response.status_code == 200
    assert response.headers.get("Access-Control-Allow-Origin") == "*"
    resp = response.json()

    assert resp["blocks"][4]["type"] == "images"
    assert resp["blocks"][4]["images"] == [
        {
            "url": "https://s2.qwant.com/thumbr/0x0/3/9/43f34b2898978cd1c6cbfa90766ef432d761f02d31f32120eff6db12f616b5/1024px-Logo_musée_d'Orsay.png?u=https%3A%2F%2Fupload.wikimedia.org%2Fwikipedia%2Ffr%2Fthumb%2F7%2F73%2FLogo_mus%25C3%25A9e_d%2527Orsay.png%2F1024px-Logo_mus%25C3%25A9e_d%2527Orsay.png&q=0&b=1&p=0&a=0",
            "alt": "",
            "credits": "",
            "source_url": "https://upload.wikimedia.org/wikipedia/fr/thumb/7/73/Logo_mus%C3%A9e_d%27Orsay.png/1024px-Logo_mus%C3%A9e_d%27Orsay.png",
        },
    ] 
开发者ID:QwantResearch,项目名称:idunn,代码行数:19,代码来源:test_wiki_images.py

示例8: test_undefined_wheelchairs

# 需要导入模块: import app [as 别名]
# 或者: from app import app [as 别名]
def test_undefined_wheelchairs():
    """
    Test that when wheelchair and toilets_wheelchair are not
    defined there is no block 'accessibility'
    """
    client = TestClient(app)
    response = client.get(url=f"http://localhost/v1/pois/osm:node:738042332?lang=fr",)

    assert response.status_code == 200
    assert response.headers.get("Access-Control-Allow-Origin") == "*"

    resp = response.json()

    assert resp["id"] == "osm:node:738042332"
    assert resp["name"] == "Boulangerie Patisserie Peron"
    assert resp["local_name"] == "Boulangerie Patisserie Peron"
    assert resp["class_name"] == "bakery"
    assert resp["subclass_name"] == "bakery"
    assert resp["blocks"] == [] 
开发者ID:QwantResearch,项目名称:idunn,代码行数:21,代码来源:test_accessibility.py

示例9: test_pj_place_with_missing_data

# 需要导入模块: import app [as 别名]
# 或者: from app import app [as 别名]
def test_pj_place_with_missing_data():
    musee_picasso_short = read_fixture("musee_picasso_short.json")
    with mock.patch.object(
        places_utils.pj_source.es,
        "search",
        new=lambda *x, **y: {"hits": {"hits": [musee_picasso_short]}},
    ):
        client = TestClient(app)
        response = client.get(url=f"http://localhost/v1/places/pj:05360257?lang=fr")

        assert response.status_code == 200
        resp = response.json()
        assert resp["id"] == "pj:05360257"
        assert resp["name"] == "Musée Picasso"
        assert resp["address"]["label"] == ""
        assert resp["class_name"] == "museum"
        assert resp["subclass_name"] == "museum"
        assert resp["type"] == "poi"
        assert resp["meta"]["source"] == "pages_jaunes"
        assert resp["geometry"]["center"] == [2.362634, 48.859702] 
开发者ID:QwantResearch,项目名称:idunn,代码行数:22,代码来源:test_pj_poi.py

示例10: test_extend_bbox

# 需要导入模块: import app [as 别名]
# 或者: from app import app [as 别名]
def test_extend_bbox():
    client = TestClient(app)
    small_bbox = "2.350,48.850,2.351,48.851"

    response = client.get(
        url=f"http://localhost/v1/places?bbox={small_bbox}&raw_filter=museum,museum"
    )
    assert response.status_code == 200
    assert len(response.json()["places"]) == 0

    response = client.get(
        url=f"http://localhost/v1/places?bbox={small_bbox}&raw_filter=museum,museum&extend_bbox=true"
    )
    assert response.status_code == 200
    data = response.json()
    assert len(data["places"]) == 1
    assert data["bbox_extended"] == True
    assert data["bbox"] == [2.338028, 48.861147, 2.338028, 48.861147] 
开发者ID:QwantResearch,项目名称:idunn,代码行数:20,代码来源:test_categories.py

示例11: test_endpoint_categories

# 需要导入模块: import app [as 别名]
# 或者: from app import app [as 别名]
def test_endpoint_categories():
    """
        Test the endpoint 'categories':
    """
    client = TestClient(app)

    response = client.get(url=f"http://localhost/v1/categories")

    assert response.status_code == 200

    resp = response.json()
    categories = resp["categories"]

    assert len(categories) == 12
    assert categories[0] == {"name": "restaurant", "raw_filters": ["restaurant,*", "fast_food,*"]}
    assert categories[1] == {"name": "hotel", "raw_filters": ["*,hotel"]} 
开发者ID:QwantResearch,项目名称:idunn,代码行数:18,代码来源:test_categories.py

示例12: test_type_query_poi

# 需要导入模块: import app [as 别名]
# 或者: from app import app [as 别名]
def test_type_query_poi():
    client = TestClient(app)
    response = client.get(url=f"http://localhost/v1/places/osm:way:63178753?lang=fr&type=poi",)

    assert response.status_code == 200
    assert response.headers.get("Access-Control-Allow-Origin") == "*"

    resp = response.json()

    assert resp["id"] == "osm:way:63178753"
    assert resp["name"] == "Musée d'Orsay"
    assert resp["local_name"] == "Musée d'Orsay"
    assert resp["class_name"] == "museum"
    assert resp["subclass_name"] == "museum"
    assert resp["blocks"][0]["type"] == "opening_hours"
    assert resp["blocks"][1]["type"] == "phone"
    assert resp["blocks"][0]["is_24_7"] == False 
开发者ID:QwantResearch,项目名称:idunn,代码行数:19,代码来源:test_places.py

示例13: test_basic_short_query_poi

# 需要导入模块: import app [as 别名]
# 或者: from app import app [as 别名]
def test_basic_short_query_poi():
    client = TestClient(app)
    response = client.get(
        url=f"http://localhost/v1/places/osm:way:63178753?lang=fr&verbosity=short",
    )
    assert response.status_code == 200
    assert response.headers.get("Access-Control-Allow-Origin") == "*"

    resp = response.json()

    assert resp["id"] == "osm:way:63178753"
    assert resp["name"] == "Musée d'Orsay"
    assert resp["local_name"] == "Musée d'Orsay"
    assert resp["class_name"] == "museum"
    assert resp["subclass_name"] == "museum"
    assert resp["blocks"][0]["type"] == "opening_hours"
    assert len(resp["blocks"]) == 1  # it contains only the block opening hours 
开发者ID:QwantResearch,项目名称:idunn,代码行数:19,代码来源:test_places.py

示例14: test_wiki_cache_unavailable

# 需要导入模块: import app [as 别名]
# 或者: from app import app [as 别名]
def test_wiki_cache_unavailable(cache_test_normal, mock_wikipedia):
    """
    Wikipedia should NOT be called if cache is enabled in settings,
    and redis is not reachable
    """

    def fake_get(*args):
        # A method 'get' for Redis,
        # that behaves as if redis is not available
        raise RedisError

    with mock.patch.object(Redis, "get", fake_get):
        client = TestClient(app)
        response = client.get(url="http://localhost/v1/pois/osm:relation:7515426?lang=es",)
        assert response.status_code == 200
        resp = response.json()
        assert len(mock_wikipedia.calls) == 0
        assert not any(b["type"] == "wikipedia" for b in resp["blocks"][2].get("blocks")) 
开发者ID:QwantResearch,项目名称:idunn,代码行数:20,代码来源:test_cache.py

示例15: test_wikipedia_another_language

# 需要导入模块: import app [as 别名]
# 或者: from app import app [as 别名]
def test_wikipedia_another_language():
    """
    The louvre museum has the tag 'wikipedia' with value 'fr:Musée du Louvre'
    We check that wikipedia block is built using data from the wikipedia page
    in another language.
    """
    client = TestClient(app)
    response = client.get(url=f"http://localhost/v1/pois/osm:relation:7515426?lang=es",)

    assert response.status_code == 200

    resp = response.json()

    assert resp["id"] == "osm:relation:7515426"
    assert resp["name"] == "Museo del Louvre"
    assert resp["local_name"] == "Musée du Louvre"
    assert resp["class_name"] == "museum"
    assert resp["subclass_name"] == "museum"
    assert resp["blocks"][2].get("blocks")[0] == {
        "type": "wikipedia",
        "url": "https://es.wikipedia.org/wiki/Museo_del_Louvre",
        "title": "Museo del Louvre",
        "description": "El Museo del Louvre es el museo nacional de Francia ...",
    } 
开发者ID:QwantResearch,项目名称:idunn,代码行数:26,代码来源:test_api_with_wiki.py


注:本文中的app.app方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。