Ejemplo n.º 1
0
    def test_post_save_document_file_count_update(self):
        observation = ObservationFactory()
        document_file = DocumentFile.objects.create(
            name='Test name',
            description='Test Description',
            contribution=observation,
            creator=UserFactory.create(),
            document=get_pdf_document()
        )
        DocumentFile.objects.create(
            status='deleted',
            name='Test name',
            description='Test Description',
            contribution=observation,
            creator=UserFactory.create(),
            document=get_pdf_document()
        )

        post_save_count_update(
            DocumentFile,
            instance=document_file,
            created=True)

        observation.refresh_from_db()
        self.assertEqual(observation.num_media, 1)
        self.assertEqual(observation.num_comments, 0)
Ejemplo n.º 2
0
    def test_post_save_audio_file_count_update(self):
        observation = ObservationFactory()
        audio_file = AudioFile.objects.create(
            name='Test name',
            description='Test Description',
            contribution=observation,
            creator=UserFactory.create(),
            audio=get_image()
        )
        AudioFile.objects.create(
            status='deleted',
            name='Test name',
            description='Test Description',
            contribution=observation,
            creator=UserFactory.create(),
            audio=get_image()
        )

        post_save_count_update(
            AudioFile,
            instance=audio_file,
            created=True)

        observation.refresh_from_db()
        self.assertEqual(observation.num_media, 1)
        self.assertEqual(observation.num_comments, 0)
Ejemplo n.º 3
0
    def test_post_save_video_file_count_update(self):
        observation = ObservationFactory()
        video_file = VideoFile.objects.create(
            name='Test name',
            description='Test Description',
            contribution=observation,
            creator=UserFactory.create(),
            video=get_image(),
            youtube_link='http://example.com/1122323',
            swf_link='http://example.com/1122323.swf'
        )
        VideoFile.objects.create(
            status='deleted',
            name='Test name',
            description='Test Description',
            contribution=observation,
            creator=UserFactory.create(),
            video=get_image(),
            youtube_link='http://example.com/1122323',
            swf_link='http://example.com/1122323.swf'
        )

        post_save_count_update(
            VideoFile,
            instance=video_file,
            created=True)

        observation.refresh_from_db()
        self.assertEqual(observation.num_media, 1)
        self.assertEqual(observation.num_comments, 0)
Ejemplo n.º 4
0
    def test_post_save_audio_file_count_update(self):
        observation = ObservationFactory()
        audio_file = AudioFile.objects.create(name='Test name',
                                              description='Test Description',
                                              contribution=observation,
                                              creator=UserFactory.create(),
                                              audio=get_image())
        AudioFile.objects.create(status='deleted',
                                 name='Test name',
                                 description='Test Description',
                                 contribution=observation,
                                 creator=UserFactory.create(),
                                 audio=get_image())

        post_save_count_update(AudioFile, instance=audio_file, created=True)

        observation.refresh_from_db()
        self.assertEqual(observation.num_media, 1)
        self.assertEqual(observation.num_comments, 0)
Ejemplo n.º 5
0
    def test_post_save_document_file_count_update(self):
        observation = ObservationFactory()
        document_file = DocumentFile.objects.create(
            name='Test name',
            description='Test Description',
            contribution=observation,
            creator=UserFactory.create(),
            document=get_pdf_document())
        DocumentFile.objects.create(status='deleted',
                                    name='Test name',
                                    description='Test Description',
                                    contribution=observation,
                                    creator=UserFactory.create(),
                                    document=get_pdf_document())

        post_save_count_update(DocumentFile,
                               instance=document_file,
                               created=True)

        observation.refresh_from_db()
        self.assertEqual(observation.num_media, 1)
        self.assertEqual(observation.num_comments, 0)
Ejemplo n.º 6
0
    def test_post_save_video_file_count_update(self):
        observation = ObservationFactory()
        video_file = VideoFile.objects.create(
            name='Test name',
            description='Test Description',
            contribution=observation,
            creator=UserFactory.create(),
            video=get_image(),
            youtube_link='http://example.com/1122323',
            swf_link='http://example.com/1122323.swf')
        VideoFile.objects.create(status='deleted',
                                 name='Test name',
                                 description='Test Description',
                                 contribution=observation,
                                 creator=UserFactory.create(),
                                 video=get_image(),
                                 youtube_link='http://example.com/1122323',
                                 swf_link='http://example.com/1122323.swf')

        post_save_count_update(VideoFile, instance=video_file, created=True)

        observation.refresh_from_db()
        self.assertEqual(observation.num_media, 1)
        self.assertEqual(observation.num_comments, 0)