예제 #1
0
 def test_from_request_raises_conflict(self):
     request = Request(
         factory.get('/',
                     HTTP_X_INERTIA=True,
                     HTTP_X_INERTIA_VERSION="1.2.4"))
     with pytest.raises(Conflict):
         Inertia.from_request(request, "Component/Path")
예제 #2
0
 def test_from_request_matching_version_does_not_raise_conflict(self):
     request = Request(
         factory.get('/',
                     HTTP_X_INERTIA=True,
                     HTTP_X_INERTIA_VERSION="unversioned"))
     try:
         Inertia.from_request(request, "Component/Path")
     except Conflict:
         pytest.fail("Matching inertia version raises Conflict")
예제 #3
0
 def test_json_request_no_inertia(self):
     request = Request(factory.get('/', HTTP_ACCEPT="application/json"))
     request.inertia = Inertia.from_request(request, "Component/Path")
     renderer, media_type = self.select_renderer(request)
     assert media_type == "application/json"
     assert isinstance(renderer, JSONRenderer)
     assert isinstance(renderer, InertiaJSONRenderer) is False
예제 #4
0
 def test_from_request_partial_data(self):
     component = "Component/Path"
     request = Request(
         factory.get('/',
                     HTTP_X_INERTIA=True,
                     HTTP_X_INERTIA_PARTIAL_DATA='prop1,prop2',
                     HTTP_X_INERTIA_PARTIAL_COMPONENT=component))
     inertia = Inertia.from_request(request, component)
     assert inertia.is_data
     assert inertia.partial_data == ['prop1', 'prop2']
예제 #5
0
 def test_html_request_selects_inertia_html_renderer(self):
     request = Request(factory.get('/', HTTP_ACCEPT="text/html"))
     request.inertia = Inertia.from_request(request, "Component/Path")
     renderer, media_type = self.select_renderer(request)
     assert media_type == "text/html"
     assert isinstance(renderer, InertiaHTMLRenderer)
예제 #6
0
 def test_inertia_request_selects_json_renderer(self):
     request = Request(factory.get('/', HTTP_X_INERTIA=True))
     request.inertia = Inertia.from_request(request, "Component/Path")
     renderer, media_type = self.select_renderer(request)
     assert media_type == "application/json"
     assert isinstance(renderer, InertiaJSONRenderer)
예제 #7
0
 def test_from_request_is_data_false(self):
     request = Request(factory.get('/'))
     inertia = Inertia.from_request(request, "Component/Path")
     assert inertia.is_data is False
예제 #8
0
 def test_from_request_is_data_true(self):
     request = Request(factory.get('/', HTTP_X_INERTIA=True))
     inertia = Inertia.from_request(request, "Component/Path")
     assert inertia.is_data
     assert inertia.component == "Component/Path"
     assert inertia.url == "/"