def test_modelviewset_list_action_breadcrumbs(self): url = '/resources/list_action/' assert get_breadcrumbs(url) == [ ('Root', '/'), ('Resource List', '/resources/'), ('List action', '/resources/list_action/'), ]
def test_nested_resource_breadcrumbs(self): url = '/resource/123/' assert get_breadcrumbs(url) == [('Root', '/'), ('Resource Root', '/resource/'), ('Resource Instance', '/resource/123'), ('Nested Resource Root', '/resource/123/')]
def test_modelviewset_action_suffix_kwarg(self): url = '/resources/1/suffixed_action/' assert get_breadcrumbs(url) == [ ('Root', '/'), ('Resource List', '/resources/'), ('Resource Instance', '/resources/1/'), ('Resource Custom Suffix', '/resources/1/suffixed_action/'), ]
def test_modelviewset_action_name_kwarg(self): url = '/resources/1/named_action/' assert get_breadcrumbs(url) == [ ('Root', '/'), ('Resource List', '/resources/'), ('Resource Instance', '/resources/1/'), ('Custom Name', '/resources/1/named_action/'), ]
def test_modelviewset_detail_action_breadcrumbs(self): url = '/resources/1/detail_action/' assert get_breadcrumbs(url) == [ ('Root', '/'), ('Resource List', '/resources/'), ('Resource Instance', '/resources/1/'), ('Detail action', '/resources/1/detail_action/'), ]
def get_breadcrumbs(self, request): return get_breadcrumbs(request.path, request)
def test_resource_instance_customname_breadcrumbs(self): url = '/resource/customname' assert get_breadcrumbs(url) == [('Root', '/'), ('Resource Root', '/resource/'), ('Foo', '/resource/customname')]
def test_resource_root_breadcrumbs(self): url = '/resource/' assert get_breadcrumbs(url) == [('Root', '/'), ('Resource Root', '/resource/')]
def test_root_breadcrumbs(self): url = '/' assert get_breadcrumbs(url) == [('Root', '/')]
def test_modelviewset_resource_instance_breadcrumbs(self): url = '/resources/1/' assert get_breadcrumbs(url) == [('Root', '/'), ('Resource List', '/resources/'), ('Resource Instance', '/resources/1/')]
def test_broken_url_breadcrumbs_handled_gracefully(self): url = '/foobar' assert get_breadcrumbs(url) == [('Root', '/')]