def testRequest(self): url = image_url(self.fileobj, 'test') response = self.client.get(url) self.assertEqual(response.status_code, 200) self.assertEqual(response.content, self.contents) cache_path = os.path.join(self.tmp_dir, url[len('/%s/' % URL_PREFIX):]) if not os.path.exists(cache_path): self.fail('Processed image was not cached') with open(cache_path, 'rb') as f: self.assertEqual(f.read(), self.contents)
def testTemplateTag(self): url = image_url(self.fileobj, 'test') template = Template("{% load agilethumbs %}" "{% image_url fileobj 'test'%}") tag_url = template.render(Context({'fileobj': self.fileobj})) self.assertEqual(url, tag_url)