Пример #1
0
    def test_saving_a_movie_to_a_scene(self):
        a_ = Director.objects.create(full_name="Skip X")
        m_ = Movie.objects.create(artist=a_)

        scene = Scene(artwork=m_)
        scene.description = 'the first list item described'
        scene.notes = 'noted'
        scene.name = 'scene name'
        scene.longitude = -122.41575
        scene.latitude = 37.749202
        scene.save()
        self.assertEqual(Scene.objects.count(), 1)
        first = Scene.objects.first()
        self.assertEqual(first.artwork.artist.full_name, a_.full_name)
        scene.delete()
        scene.full_clean()
        self.assertEqual(Scene.objects.count(), 0)
Пример #2
0
 def test_to_dict_instance_method(self):
     author_ = Author.objects.create(first_name="First", last_name="Last")
     work_ = Artwork.objects.create(title="Artwork Title", artist=author_)
     scene = Scene(artwork=work_)
     scene.description = 'the first list item described'
     scene.notes = 'noted'
     scene.name = 'Scene Name'
     scene.longitude = -122.41575
     scene.latitude = 37.749202
     scene.save()
     md = {
         'artist': 'First Last',
         'artwork': 'Artwork Title',
         'description': 'the first list item described',
         'loc': {
             'coordinates': [37.749202, -122.41575],
             'type': 'Point'
         },
         'name': 'Scene Name',
         'notes': 'noted'
     }
     md['id'] = Scene.objects.first().id
     self.assertDictEqual(scene.to_dict(), md)