コード例 #1
0
 def test_saving_and_retrieving_scene_descriptions(self):
     self.artist_ = Author.objects.create(first_name='First',
                                          last_name='Last')
     self.artwork_ = Artwork.objects.create(title='Artwork Title',
                                            artist=self.artist_)
     scene = Scene(artwork=self.artwork_)
     scene.description = 'the first list item described'
     scene.longitude = -122.41575
     scene.latitude = 37.749202
     scene.save()
     self.assertEqual(Scene.objects.count(), 1)
     scene.delete()
     self.assertEqual(Scene.objects.count(), 0)
コード例 #2
0
ファイル: test_views.py プロジェクト: stevenyoung/pdp-django
 def setUp(self):
     artist_ = Artist.objects.create(full_name="bad brains")
     artwork_ = Artwork.objects.create(artist=artist_,
                                       title='Banned in D.C.')
     scene = Scene()
     scene.description = 'can save a post request',
     scene.longitude = -122.41575
     scene.latitude = 37.749202
     scene.artwork = artwork_
     scene.save()
     new_item = Scene.objects.first()
     self.new_scene_url = '/places/api/' + str(new_item.id)
コード例 #3
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)
コード例 #4
0
ファイル: test_views.py プロジェクト: stevenyoung/pdp-django
 def sample_scene_input(self):
     artist_ = Artist.objects.create(full_name="Bad Brains")
     artwork_ = Artwork.objects.create(artist=artist_,
                                       title='Banned in D.C.')
     scene = Scene()
     scene.description = 'can save a post request'
     scene.longitude = -122.41575
     scene.latitude = 37.749202
     scene.artwork = artwork_
     return scene
コード例 #5
0
    def test_scene_supports_spatial_fields(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.longitude = -122.41575
        scene.latitude = 37.749202

        scene.save()
        self.assertIsNotNone(scene.latitude)
        self.assertIsNotNone(scene.longitude)
        self.assertIsNotNone(scene.coordinates)
        self.assertIsInstance(scene.coordinates, Point)
コード例 #6
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)