Example #1
0
 def test_unicode(self):
     """
     Scenario: Given a blog named Icecream
     Expected:
     - its unicode should be (<id>) Icecream
     """
     # Arrage
     blog = Blog(title='Icecream') 
     blog.user = self.user
     blog.category = self.category
     blog.location = self.location
     blog.save()
     printed_unicode = '(%s) Icecream' % blog.id
     # Act
     result = blog.__unicode__()
     # Assert
     self.assertEquals(printed_unicode, result)
Example #2
0
def create_blog(title='Icecream', user = None, category = None, location = None, mood=1, private=True, draft=False, tags='hastags,foo,bar', trash=False, allow_download=True):
    user = user or create_user()
    category = category or create_category()
    location = location or create_location()
    
    blog = Blog(title = title) 
    blog.user = user
    blog.category = category
    blog.location = location
    blog.mood = mood
    blog.private = private
    blog.draft = draft
    blog.trash = trash
    blog.allow_download = allow_download
    blog.save()
    blog.save_tags(tags)
    blog.image.save('blog_%s.jpg' % blog.id, DjangoFile(open('static/tests/blog.jpg'), 'blog.jpg'))
    blog.published = datetime.now()
    blog.save()
    
    return blog