-
Notifications
You must be signed in to change notification settings - Fork 51
/
tests.py
59 lines (46 loc) · 1.81 KB
/
tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#
# django-audiofield License
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
#
# Copyright (C) 2011-2014 Star2Billing S.L.
#
# The Initial Developer of the Original Code is
# Arezqui Belaid <info@star2billing.com>
#
from django.contrib.auth.models import User
from django.test import TestCase
from common.utils import BaseAuthenticatedClient
from audiofield.models import AudioFile
from audiofield.forms import CustomerAudioFileForm
class AudiofieldAdminInterfaceTestCase(BaseAuthenticatedClient):
"""Test cases for Audiofield Admin Interface."""
def test_admin_audiofile_list(self):
"""Test Function to check admin audio file list"""
response = self.client.get('/admin/audiofield/audiofile/')
self.failUnlessEqual(response.status_code, 200)
def test_admin_audiofile_add(self):
"""Test Function to check admin audio file add"""
response = self.client.get('/admin/audiofield/audiofile/add/')
self.failUnlessEqual(response.status_code, 200)
class AudioFileModel(TestCase):
"""Test AudioFile model"""
fixtures = ['auth_user.json']
def setUp(self):
self.user = User.objects.get(username='admin')
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()