Exemple #1
0
 def test_component_url_with_extra_context(self):
     instance = Dragonfly(pk=123)
     link = DragonflyViewSet().links["extra"]
     self.assertEqual(
         get_link_url(None, link, instance, special="param"),
         "/dragonfly/extra/123/param/",
     )
Exemple #2
0
 def test_links_that_do_not_require_an_instance_work_if_one_is_supplied(
         self):
     links = DragonflyViewSet().links
     instance = Dragonfly(pk=123)
     self.assertEqual(get_link_url(None, links["list"], instance),
                      "/dragonfly/")
     self.assertEqual(get_link_url(None, links["create"], instance),
                      "/dragonfly/create/")
Exemple #3
0
 def test_links_that_require_an_instance(self):
     links = DragonflyViewSet().links
     instance = Dragonfly(pk=123)
     self.assertEqual(get_link_url(None, links["detail"], instance),
                      "/dragonfly/123/")
     self.assertEqual(get_link_url(None, links["update"], instance),
                      "/dragonfly/123/update/")
     self.assertEqual(get_link_url(None, links["delete"], instance),
                      "/dragonfly/123/delete/")
Exemple #4
0
    def test_component_url_kwarg_from_request(self):
        class request:
            class resolver_match:
                kwargs = {"special": "from_request"}

        instance = Dragonfly(pk=123)
        url = DragonflyViewSet().links["extra"].reverse(instance, request)
        self.assertEqual(
            url,
            "/dragonfly/extra/123/from_request/",
        )
Exemple #5
0
 def test_get_url_for_related_returns_none_instead_of_raising(self):
     instance = Dragonfly(pk=123)
     url = get_url_for_related({}, instance, "extra")
     self.assertIsNone(url)
Exemple #6
0
def test_component_url_with_extra_context():
    instance = Dragonfly(pk=123)
    link = DragonflyViewSet().links["extra"]
    assert (
        get_link_url(link, instance, special="param") == "/dragonfly/extra/123/param/"
    )
Exemple #7
0
def test_get_link_urls_that_require_object(view_type, url):
    instance = Dragonfly(pk=123)
    link = dict(DragonflyViewSet().links)[view_type]
    assert get_link_url(link, instance) == url