lundi 24 septembre 2018

Django url testing

urls.py of my web application is as follows

urlpatterns = [
    path('u/<int:unit_id>/', views.unit_view, name='unit_view'),
    path('u/<int:unit_id>/edit/', views.unit_edit, name='unit_edit'),
]

I tried to write test as following. Unable to run the tests. Not even getting errors

from django.urls import reverse, resolve


class TestUrls:

    def test_unit_view_url(self):
        path = reverse('unit_view', kwargs={'unit_id': 1})
        assert resolve(path).views.unit_view == 'unit_view'

    def test_unit_edit_url(self):
        path = reverse('unit_edit', kwargs={'unit_id': 1})
        assert resolve(path).views.unit_edit == 'unit_edit'

Aucun commentaire:

Enregistrer un commentaire