Example #1
0
    def setUp(self):
        self.c = Client()

        relationship = RelationshipCategory(approved=True)
        relationship.save()

        adoptee = Adoptee(english_name='Madeline Jing-Mei',
                          pinyin_name='Jǐngměi',
                          chinese_name='景美')
        adoptee.save()

        prototypical_storyteller_kw_args = {'story_text': 'bs',
                                            'email': '*****@*****.**',
                                            'approved': True,
                                            'relationship_to_story': relationship,
                                            'related_adoptee': adoptee,
                                            }

        self.storyteller = StoryTeller(**prototypical_storyteller_kw_args)
        self.storyteller.save()
Example #2
0
    def setUp(self):
        self.adoptees = [
            Adoptee(english_name='Madeline Jing-Mei',
                    pinyin_name='Jǐngměi',
                    chinese_name='景美'),
            Adoptee(english_name='Kim Bla', ),
            Adoptee(english_name='Search Test',
                    pinyin_name='Lala',
                    chinese_name='搜索的一例'),
            Adoptee(chinese_name='景',
                    pinyin_name='Lola')
        ]
        for adoptee in self.adoptees:
            adoptee.save()

        self.relationship = RelationshipCategory(approved=True)
        self.relationship.save()

        prototypical_storyteller_kw_args = {'story_text': 'bs',
                                            'email': '*****@*****.**',
                                            'approved': True,
                                            'relationship_to_story': self.relationship,
                                            }
        self.storytellers = [StoryTeller(related_adoptee=adoptee,
                                         **prototypical_storyteller_kw_args)
                             for adoptee in self.adoptees]

        self.photos = []

        for storyteller in self.storytellers:
            storyteller.save()
            self.photos.append(create_random_photo(storyteller))

        for adoptee, storyteller, photo in zip(self.adoptees, self.storytellers, self.photos):
            adoptee.front_story = storyteller
            image_file = create_random_image_file(config['PHOTO_FRONT_STORY_WIDTH'],
                                                  config['PHOTO_FRONT_STORY_HEIGHT'])
            adoptee.photo_front_story.save('bs.jpg', ContentFile(image_file.getvalue()))
            adoptee.save()

        self.c = Client()
        self.adoptee_search_url_name = 'adopteeSearch'
Example #3
0
    def setUp(self):
        self.c = Client()
        self.upload_url = reverse('photoCreate')
        self.MIN_WIDTH = config['MIN_WIDTH']
        self.MIN_HEIGHT = config['MIN_HEIGHT']

        self.adoptees = [
            Adoptee(english_name='Madeline Jing-Mei',
                    pinyin_name='Jǐngměi',
                    chinese_name='景美'),
            Adoptee(english_name='Kim Bla', ),
            Adoptee(chinese_name='景',
                    pinyin_name='Lola'),
            Adoptee(english_name='Search Test',
                    pinyin_name='Lala',
                    chinese_name='搜索的一例'),
        ]
        for adoptee in self.adoptees:
            adoptee.save()

        self.relationship = RelationshipCategory(approved=True)
        self.relationship.save()

        prototypical_storyteller_kw_args = {'story_text': 'bsbs',
                                            'email': '*****@*****.**',
                                            'approved': True,
                                            'relationship_to_story': self.relationship,
                                            }
        self.storytellers = [StoryTeller(related_adoptee=adoptee,
                                         **prototypical_storyteller_kw_args)
                             for adoptee in self.adoptees]

        for i, storyteller in enumerate(self.storytellers):
            storyteller.save()
            adoptee = self.adoptees[i]
            adoptee.front_story = storyteller
            adoptee.save()
Example #4
0
class AudioCreateTestCase(TestCase):
    VALID_SOUNDCLOUD_URLS = ["https://soundcloud.com/andreasedstr-m/rick-astley-never-gonna-give",
                             ]
    INVALID_SOUNDCLOUD_URLS = ["https://www.youtube.com/watch?v=dQw4w9W,b",
                               "https://www.soundcloud.com/watch?v=dQw4w9WgXcQ",
                               "https://soundcloud.com/andreasedstr-m/rick-astley-never-gonna-g",
                               "https://soundcloud.com/helterskelter-beatles-c"]
    AUDIO_CREATE_URL = reverse('audioCreate')

    def setUp(self):
        self.c = Client()

        relationship = RelationshipCategory(approved=True)
        relationship.save()

        adoptee = Adoptee(english_name='Madeline Jing-Mei',
                          pinyin_name='Jǐngměi',
                          chinese_name='景美')
        adoptee.save()

        prototypical_storyteller_kw_args = {'story_text': 'bs',
                                            'email': '*****@*****.**',
                                            'approved': True,
                                            'relationship_to_story': relationship,
                                            'related_adoptee': adoptee,
                                            }

        self.storyteller = StoryTeller(**prototypical_storyteller_kw_args)
        self.storyteller.save()

    def test_create_valid_video(self):
        for video_url in self.VALID_SOUNDCLOUD_URLS:
            post_json = '{{"english_caption": "a lovely walk in the park",' \
                        '  "chinese_caption": "景美景美景美景美景美景美景美",' \
                        '  "story_teller": {0.id},' \
                        '  "audio": "{1}"}}'.format(self.storyteller,
                                                    video_url)

            response = self.c.post(self.AUDIO_CREATE_URL,
                                   data=post_json,
                                   content_type='application/json')
            self.assertEqual(response.status_code, 201)
            queryset = Audio.objects.all()
            self.assertEqual(len(queryset), 1)
            self.assertJSONEqual(response.content.decode('utf-8'),
                                 '{{"id":{0.id}}}'.format(queryset[0]))
            queryset.delete()

    def test_create_invalid_video(self):
        for video_url in self.INVALID_SOUNDCLOUD_URLS:
            post_json = '{{"english_caption": "a lovely walk in the park",' \
                        '  "chinese_caption": "景美景美景美景美景美景美景美",' \
                        '  "story_teller": {0.id},' \
                        '  "video": "{1}"}}'.format(self.storyteller,
                                                    video_url)

            response = self.c.post(self.AUDIO_CREATE_URL,
                                   data=post_json,
                                   content_type='application/json')
            self.assertEqual(response.status_code, 400)
            queryset = Video.objects.all()
            self.assertEqual(len(queryset), 0)