예제 #1
0
 def test_model_with_zero_pk(self):
     beatles = Band(name='The Beatles',
                    members=[
                        BandMember(name='John Lennon'),
                        BandMember(name='Paul McCartney'),
                    ])
     beatles.save()
     beatles.pk = 0
     beatles.members.commit()
     beatles.save()
예제 #2
0
 def test_model_with_zero_pk(self):
     beatles = Band(name='The Beatles', members=[
         BandMember(name='John Lennon'),
         BandMember(name='Paul McCartney'),
     ])
     beatles.save()
     beatles.pk = 0
     beatles.members.commit()
     beatles.save()
     self.assertEqual(Band.objects.get(pk=0).name, 'The Beatles')
예제 #3
0
 def test_model_with_zero_pk(self):
     beatles = Band(name='The Beatles',
                    members=[
                        BandMember(name='John Lennon'),
                        BandMember(name='Paul McCartney'),
                    ])
     beatles.save()
     beatles.pk = 0
     beatles.members.commit()
     beatles.save()
     self.assertEqual(Band.objects.get(pk=0).name, 'The Beatles')
예제 #4
0
 def test_integrity_error_with_none_pk(self):
     beatles = Band(name='The Beatles',
                    members=[
                        BandMember(name='John Lennon'),
                        BandMember(name='Paul McCartney'),
                    ])
     beatles.save()
     beatles.pk = None
     self.assertRaises(IntegrityError, lambda: beatles.members.commit())
     # this should work fine, as Django will end up cloning this entity
     beatles.save()
예제 #5
0
 def test_integrity_error_with_none_pk(self):
     beatles = Band(name='The Beatles', members=[
         BandMember(name='John Lennon'),
         BandMember(name='Paul McCartney'),
     ])
     beatles.save()
     beatles.pk = None
     self.assertRaises(IntegrityError, lambda: beatles.members.commit())
     # this should work fine, as Django will end up cloning this entity
     beatles.save()
     self.assertEqual(Band.objects.get(pk=beatles.pk).name, 'The Beatles')