Beispiel #1
0
class AudioFileModel(TestCase):
    """Test AudioFile model"""

    fixtures = ['auth_user.json']

    def setUp(self):
        self.user = User.objects.get(username='******')
        self.audiofile = AudioFile(
            name='MyAudio',
            tag='TAG01',
            user=self.user,
        )
        self.audiofile.save()

    def test_name(self):
        self.assertEqual(self.audiofile.name, "MyAudio")

    def test_audio_form(self):
        form = CustomerAudioFileForm(instance=self.audiofile)

        self.assertTrue(isinstance(form.instance, AudioFile))
        self.assertEqual(form.instance.pk, self.audiofile.pk)

    def teardown(self):
        self.audiofile.delete()
Beispiel #2
0
 def test_audiofile_view_del(self):
     self.user = User.objects.get(pk=1)
     obj = AudioFile(name='sample_audio', user=self.user)
     obj.save()
     request = self.factory.post('/audio/del/%s/' % str(obj.id), {},
                                 follow=True)
     request.user = self.user
     request.session = {}
     response = audio_del(request, obj.id)
     self.assertEqual(response.status_code, 302)
Beispiel #3
0
 def test_audiofile_view_del(self):
     self.user = User.objects.get(pk=1)
     obj = AudioFile(name='sample_audio', user=self.user)
     obj.save()
     request = self.factory.post('/audio/del/%s/' % str(obj.id), {},
         follow=True)
     request.user = self.user
     request.session = {}
     response = audio_del(request, obj.id)
     self.assertEqual(response.status_code, 302)
Beispiel #4
0
    def test_audiofile_view_change(self):
        """Test Function to check audio add/change"""
        self.user = User.objects.get(pk=1)
        obj = AudioFile(name='sample_audio', user=self.user)
        obj.save()
        request = self.factory.post('/audio/%s/' % str(obj.id),
            {'name': 'sample_audio'},
            follow=True)
        request.user = self.user
        request.session = {}
        response = audio_change(request, obj.id)
        self.assertEqual(response.status_code, 200)

        request = self.factory.post('/audio/%s/?delete=true' % str(obj.id),
            {}, follow=True)
        request.user = self.user
        request.session = {}
        response = audio_change(request, obj.id)
        self.assertEqual(response.status_code, 302)
Beispiel #5
0
    def test_audiofile_view_change(self):
        """Test Function to check audio add/change"""
        self.user = User.objects.get(pk=1)
        obj = AudioFile(name='sample_audio', user=self.user)
        obj.save()
        request = self.factory.post('/audio/%s/' % str(obj.id),
                                    {'name': 'sample_audio'},
                                    follow=True)
        request.user = self.user
        request.session = {}
        response = audio_change(request, obj.id)
        self.assertEqual(response.status_code, 200)

        request = self.factory.post('/audio/%s/' % str(obj.id),
                                    {'delete': 'true'},
                                    follow=True)
        request.user = self.user
        request.session = {}
        response = audio_change(request, obj.id)
        self.assertEqual(response.status_code, 302)
Beispiel #6
0
class AudioFileModel(TestCase):
    """Test AudioFile model"""

    fixtures = ['auth_user.json']

    def setUp(self):
        self.user = User.objects.get(username='******')
        self.audiofile = AudioFile(
            name='MyAudio',
            user=self.user,
        )
        self.audiofile.save()

    def test_name(self):
        self.assertEqual(self.audiofile.name, "MyAudio")

    def test_audio_form(self):
        form = CustomerAudioFileForm(instance=self.audiofile)

        self.assertTrue(isinstance(form.instance, AudioFile))
        self.assertEqual(form.instance.pk, self.audiofile.pk)

    def teardown(self):
        self.audiofile.delete()