Posts

Showing posts from March, 2016

User Model Test Case

# Hi, if you are writing model level test cases then you can try something like this from django.test import TestCase from django.contrib.auth import get_user_model from s3boto.models import Resource import tempfile class UserTestCase(TestCase): def _create_image(self): from PIL import Image # path='/Users/Mac/Downloads/' with tempfile.NamedTemporaryFile(suffix='.png', delete=False) as f: image = Image.new('RGB', (200, 200), 'white') image.save(f, 'PNG') return open(f.name, mode='rb') def setUp(self): self.image = self._create_image() self.name = self.image.name.split('.')[0] self.ext = self.image.name.split('.')[1] self.resource = Resource( name=self.name, ext=self.ext, bucket='test', data_source_type=0, type=1, descr