def setUp(self): en = Language(pk='en') self.john = Author(first_name="John", last_name="Lennon") self.john.save() self.song1 = Song(title="Give Peace a Chance", composed_year=1971, language=en) self.song1.save() self.song1.composed_by.add(self.john) self.john.songs_composed.create(title="Imagine", composed_year=1971, language=en)
class TestCase(unittest.TestCase): def setUp(self): en = Language(pk='en') self.john=Author(first_name="John",last_name="Lennon") self.john.save() self.song1=Song(title="Give Peace a Chance", composed_year=1971,language=en) self.song1.save() self.song1.composed_by.add(self.john) self.john.songs_composed.create(title="Imagine", composed_year=1971,language=en) def test01(self): self.assertEquals(unicode(self.song1), 'Give Peace a Chance (1)') self.assertEquals(self.john.songs_composed.count(), 2) self.assertEquals(Song.objects.count(), 2)
class TestCase(unittest.TestCase): def setUp(self): en = Language(pk='en') self.john = Author(first_name="John", last_name="Lennon") self.john.save() self.song1 = Song(title="Give Peace a Chance", composed_year=1971, language=en) self.song1.save() self.song1.composed_by.add(self.john) self.john.songs_composed.create(title="Imagine", composed_year=1971, language=en) def test01(self): self.assertEquals(unicode(self.song1), 'Give Peace a Chance (1)') self.assertEquals(self.john.songs_composed.count(), 2) self.assertEquals(Song.objects.count(), 2)
def setUp(self): en = Language(pk='en') self.john=Author(first_name="John",last_name="Lennon") self.john.save() self.song1=Song(title="Give Peace a Chance", composed_year=1971,language=en) self.song1.save() self.song1.composed_by.add(self.john) self.john.songs_composed.create(title="Imagine", composed_year=1971,language=en)