예제 #1
0
 def test_create(self):
     owner = User_factory.build()
     category = Category_factory.build()
     data = Category_serializer(category).data
     category_result = Category_serializer(data=data)
     is_valid = category_result.is_valid()
     self.assertTrue(is_valid, category_result.errors)
     category = category_result.save(owner=owner)
     self.assertTrue(isinstance(category, Category_model))
     self.assertEqual(category.owner.username, owner.username)
예제 #2
0
 def test_create_new_category(self, category_get):
     category_get.side_effect = Category_model.DoesNotExist
     owner = User_factory.build()
     category = Category_factory.build()
     category = Category_serializer(category).data
     category.pop("owner")
     item = Item_factory.build()
     data = Item_serializer(item).data
     result = Item_serializer(data=data)
     is_valid = result.is_valid()
     self.assertTrue(is_valid, result.errors)
     item = result.save(category=category, owner=owner)
     self.assertTrue(isinstance(item, Item_model))
예제 #3
0
파일: user.py 프로젝트: dem4ply/sebastian
from django.test import TestCase
from users.models import User
from users.factories import User_factory

user_latest = User_factory.build()


def user_manager_latest(cosa):
    return user_latest


class test_user(TestCase):
    def test_get_full_name(self):
        user = User(username="******", first_name="first", last_name="last")
        self.assertEqual(user.get_full_name(), "first last")
        self.assertEqual(str(user), "user_name")

    def test_get_full_name(self):
        user = User(username="******", first_name="first", last_name="last")
        self.assertEqual(user.get_short_name(), "user_name")
        self.assertEqual(str(user), "user_name")

    def test_get_full_name(self):
        user = User(username="******", first_name="first", last_name="last")
        full = user.get_full_name()
        short = user.get_short_name()
        self.assertEqual(str(user), "None - user_name # first last")