Last active
August 29, 2015 13:57
-
-
Save mineta/9452602 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import nose.tools as nt | |
import factory | |
from django.test import TestCase | |
from myapp.models import House | |
class HouseFactory(factory.DjangoModelFactory): | |
FATORY_FOR = House | |
location = "Barcelona" | |
rooms = 3 | |
class TestHouseCreation(TestCase): | |
def setUp(self): | |
self.house1 = HouseFactory.create(balkon=True) | |
def tearDown(self): | |
self.house1.delete() | |
def test_house_created(self): | |
nt.eq_(self.house1.location, "Barcelona") | |
nt.eq_(self.house1.rooms, 3) | |
nt.eq_(self.house1.balkon, True) | |
def test_second_house_created(self): | |
house2 = HouseFactory.create(location="Hannover", balkon=False) | |
self.assertNotEqual(self.house1.location, house2.location) | |
self.assertEqual(self.house1.rooms, house2.rooms) | |
self.assertNotEqual(self.house1.balkon, house2.balkon) | |
house2.delete() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment