def test_post_ajax_carrier_url(self, resolve_mock): """ Previously the URL was getting improperly munged because we thought there was a /<carrier>/ URL prefix if there was a carrier set. This should never raise a `Resolver404` (which means the URL was bad). """ set_carrier(mkt.carriers.TELEFONICA.slug) # This is the location to which we are redirecting. location = reverse('ratings.list', args=['omg-yes']) # Mock away. request = mock.Mock(method='POST', POST={'_hijacked': 'true'}, META={}) response = mock.Mock(status_code=302) response.__getitem__ = lambda self, header: location # I care only about resolving the URL. I don't care about the view. resolve_mock.func = mock.Mock() HijackRedirectMiddleware().process_response(request, response) resolve_mock.assert_called_with(location)
def setUp(self): set_carrier(None)