class TestTransactionMiddleware(amo.tests.TestCase): def setUp(self): self.prefix = RedirectPrefixedURIMiddleware() self.transaction = APITransactionMiddleware() def test_api(self): req = RequestFactory().get('/api/foo/') self.prefix.process_request(req) ok_(req.API) def test_not_api(self): req = RequestFactory().get('/not-api/foo/') self.prefix.process_request(req) ok_(not req.API) @mock.patch('django.db.transaction.enter_transaction_management') def test_transactions(self, enter): req = RequestFactory().get('/api/foo/') self.prefix.process_request(req) self.transaction.process_request(req) ok_(enter.called) @mock.patch('django.db.transaction.enter_transaction_management') def test_not_transactions(self, enter): req = RequestFactory().get('/not-api/foo/') self.prefix.process_request(req) self.transaction.process_request(req) ok_(not enter.called)
def setUp(self): self.prefix = RedirectPrefixedURIMiddleware() self.transaction = APITransactionMiddleware()
def setUp(self): self.prefix = APIBaseMiddleware() self.transaction = APITransactionMiddleware()