def test_empty_file(self):
        """
        When given an empty file path,
        create_deleted_views should return an empty list
        """

        self.assertEqual(
            create_deleted_views(path="{this_dir}/fixtures/empty.yaml"), [])
    def test_missing_file(self):
        """
        When given a non-existent file path,
        create_deleted_views should return an empty list
        """

        self.assertEqual(
            create_deleted_views(path="/tmp/non-existent-file.yaml"), [])
# Core
import os

# Packages
from django.conf.urls import url
from django.http import HttpResponse
from canonicalwebteam.yaml_responses.django_helpers import create_deleted_views

parent_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))

# Add redirects
urlpatterns = create_deleted_views(path=f"{parent_dir}/deleted.yaml")

# Standard patterns
urlpatterns += [url("homepage", lambda request: HttpResponse("hello world"))]
예제 #4
0
# Third party modules
from django.conf.urls import include, url
from canonicalwebteam.yaml_responses.django_helpers import (
    create_deleted_views,
    create_redirect_views,
)

# Local code
from .views import UbuntuTemplateFinder, DownloadView, ResourcesView, search


urlpatterns = create_redirect_views()
urlpatterns += create_deleted_views()
urlpatterns += [
    url("", include("django_prometheus.urls")),
    url(
        r"^(?P<template>download/(desktop|server|cloud)/thank-you)$",
        DownloadView.as_view(),
    ),
    url(r"^resources", ResourcesView.as_view()),
    url(r"^search$", search),
    url(r"^(?P<template>.*)[^\/]$", UbuntuTemplateFinder.as_view()),
    url(r"$^", UbuntuTemplateFinder.as_view()),
]
예제 #5
0
# Third party modules
from django.conf.urls import url, include
from django.urls import path
from canonicalwebteam.yaml_responses.django_helpers import (
    create_deleted_views,
    create_redirect_views,
)
from canonicalwebteam.blog.django.views import group, topic

# Local code
from .views import UbuntuTemplateFinder, DownloadView, ResourcesView, search

urlpatterns = create_redirect_views()
urlpatterns += create_deleted_views()
urlpatterns += [
    path(
        "blog/cloud-and-server",
        group,
        {
            "slug": "cloud-and-server",
            "template_path": "blog/cloud-and-server.html",
        },
        name="group",
    ),
    path(
        "blog/desktop",
        group,
        {
            "slug": "desktop",
            "template_path": "blog/desktop.html"
        },
# Core
import os

# Packages
from django.http import HttpResponseGone
from canonicalwebteam.yaml_responses.django_helpers import create_deleted_views

parent_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))

# Add redirects
urlpatterns = create_deleted_views(
    path=f"{parent_dir}/deleted.yaml",
    view_callback=lambda request, context, settings: HttpResponseGone(
        "custom callback"),
)