def responses(code, path=None, redirection=None, headers={'Content-Type': 'text/xml'}): response = _Response() response.status_code = code if path is not None: with open(test_file(path), 'r') as f: response.raw = StringIO(f.read()) if redirection is not None: temp = _Response() temp.status_code = 301 if 'permanent' in redirection else 302 temp.url = path response.history.append(temp) response.url = redirection response.headers = headers return response
def responses(code, path=None, redirection=None, headers={'Content-Type': 'text/xml'}): response = _Response() response.status_code = code if path is not None: with open(os.path.join(ROOT, path), 'r') as f: response.raw = StringIO(f.read()) if redirection is not None: response.history.append('yo') response.url = redirection response.headers = headers return response
def setUp(self, get): """Main stuff we need for testing the app - this is mainly for signed in users.""" # We'll need a user... self.user = User.objects.create_user('testuser', '*****@*****.**', 'pass') # ... a category... self.cat = Category.objects.create(name='Cat', slug='cat', user=self.user, delete_after='never') # ... and a feed. response = _Response() response.status_code = 304 get.return_value = response self.feed = self.cat.feeds.create(name='Test Feed', url='sw-all.xml') get.assert_called_with( 'sw-all.xml', headers={'User-Agent': USER_AGENT % '1 subscriber'}, timeout=10) # The user is logged in self.client.login(username='******', password='******')