Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

updated testcases

  • Loading branch information...
commit b2a8f395a8b6591c338772b5b86c6770ed0fe891 1 parent 5ffe97b
Shrenik Patel authored August 13, 2012
2  TODO
@@ -4,7 +4,7 @@ TODO
4 4
 
5 5
 - integrate with django-storage (http://django-storages.readthedocs.org/)
6 6
 
7  
-- support more convertion
  7
+- support more conversion
8 8
 
9 9
 - use gstreamer 
10 10
 
13  audiofield/admin.py
... ...
@@ -1,3 +1,16 @@
  1
+#
  2
+# django-audiofield License
  3
+#
  4
+# This Source Code Form is subject to the terms of the Mozilla Public
  5
+# License, v. 2.0. If a copy of the MPL was not distributed with this file,
  6
+# You can obtain one at http://mozilla.org/MPL/2.0/.
  7
+#
  8
+# Copyright (C) 2011-2012 Star2Billing S.L.
  9
+#
  10
+# The Initial Developer of the Original Code is
  11
+# Arezqui Belaid <info@star2billing.com>
  12
+#
  13
+
1 14
 from django.contrib import admin
2 15
 from django.db.models import *
3 16
 from audiofield.models import AudioFile
13  audiofield/fields.py
... ...
@@ -1,3 +1,16 @@
  1
+#
  2
+# django-audiofield License
  3
+#
  4
+# This Source Code Form is subject to the terms of the Mozilla Public
  5
+# License, v. 2.0. If a copy of the MPL was not distributed with this file,
  6
+# You can obtain one at http://mozilla.org/MPL/2.0/.
  7
+#
  8
+# Copyright (C) 2011-2012 Star2Billing S.L.
  9
+#
  10
+# The Initial Developer of the Original Code is
  11
+# Arezqui Belaid <info@star2billing.com>
  12
+#
  13
+
1 14
 from django.db.models.fields.files import FileField
2 15
 from django.db.models import signals
3 16
 from django.conf import settings
12  audiofield/forms.py
... ...
@@ -1,3 +1,15 @@
  1
+#
  2
+# django-audiofield License
  3
+#
  4
+# This Source Code Form is subject to the terms of the Mozilla Public
  5
+# License, v. 2.0. If a copy of the MPL was not distributed with this file,
  6
+# You can obtain one at http://mozilla.org/MPL/2.0/.
  7
+#
  8
+# Copyright (C) 2011-2012 Star2Billing S.L.
  9
+#
  10
+# The Initial Developer of the Original Code is
  11
+# Arezqui Belaid <info@star2billing.com>
  12
+#
1 13
 from django import forms
2 14
 from django.forms.fields import FileField
3 15
 from django.forms import ModelForm
13  audiofield/middleware/threadlocals.py
... ...
@@ -1,3 +1,16 @@
  1
+#
  2
+# django-audiofield License
  3
+#
  4
+# This Source Code Form is subject to the terms of the Mozilla Public
  5
+# License, v. 2.0. If a copy of the MPL was not distributed with this file,
  6
+# You can obtain one at http://mozilla.org/MPL/2.0/.
  7
+#
  8
+# Copyright (C) 2011-2012 Star2Billing S.L.
  9
+#
  10
+# The Initial Developer of the Original Code is
  11
+# Arezqui Belaid <info@star2billing.com>
  12
+#
  13
+
1 14
 import threading
2 15
 
3 16
 _thread_locals = threading.local()
13  audiofield/models.py
... ...
@@ -1,3 +1,16 @@
  1
+#
  2
+# django-audiofield License
  3
+#
  4
+# This Source Code Form is subject to the terms of the Mozilla Public
  5
+# License, v. 2.0. If a copy of the MPL was not distributed with this file,
  6
+# You can obtain one at http://mozilla.org/MPL/2.0/.
  7
+#
  8
+# Copyright (C) 2011-2012 Star2Billing S.L.
  9
+#
  10
+# The Initial Developer of the Original Code is
  11
+# Arezqui Belaid <info@star2billing.com>
  12
+#
  13
+
1 14
 from django.contrib.auth.models import User
2 15
 from django.db import models
3 16
 from django.utils.translation import ugettext_lazy as _
1  audiofield/requirements.txt
... ...
@@ -1 +1,2 @@
1 1
 django-uuidfield
  2
+git+git://github.com/Star2Billing/switch2bill-common.git
13  audiofield/tasks.py
... ...
@@ -1,3 +1,16 @@
  1
+#
  2
+# django-audiofield License
  3
+#
  4
+# This Source Code Form is subject to the terms of the Mozilla Public
  5
+# License, v. 2.0. If a copy of the MPL was not distributed with this file,
  6
+# You can obtain one at http://mozilla.org/MPL/2.0/.
  7
+#
  8
+# Copyright (C) 2011-2012 Star2Billing S.L.
  9
+#
  10
+# The Initial Developer of the Original Code is
  11
+# Arezqui Belaid <info@star2billing.com>
  12
+#
  13
+
1 14
 from celery.task import Task
2 15
 from models import *
3 16
 import commands
24  audiofield/test_utils.py
... ...
@@ -1,24 +0,0 @@
1  
-import unittest
2  
-
3  
-
4  
-def build_test_suite_from(test_cases):
5  
-    """Returns a single or group of unittest test suite(s) that's ready to be
6  
-    run. The function expects a list of classes that are subclasses of
7  
-    TestCase.
8  
-
9  
-    The function will search the module where each class resides and
10  
-    build a test suite from that class and all subclasses of it.
11  
-    """
12  
-    test_suites = []
13  
-    for test_case in test_cases:
14  
-        mod = __import__(test_case.__module__)
15  
-        components = test_case.__module__.split('.')
16  
-        for comp in components[1:]:
17  
-            mod = getattr(mod, comp)
18  
-        tests = []
19  
-        for item in mod.__dict__.values():
20  
-            if type(item) is type and issubclass(item, test_case):
21  
-                tests.append(item)
22  
-        test_suites.append(unittest.TestSuite(map(unittest.TestLoader().\
23  
-        loadTestsFromTestCase, tests)))
24  
-    return unittest.TestSuite(test_suites)
77  audiofield/tests.py
... ...
@@ -1,42 +1,26 @@
1  
-from django.contrib.auth.models import User
2  
-from django.test import TestCase, Client
3  
-from django.http import HttpRequest
4  
-from audiofield.test_utils import build_test_suite_from
5  
-import base64
6  
-import simplejson
7  
-
8  
-
9  
-class BaseAuthenticatedClient(TestCase):
10  
-    """Common Authentication"""
  1
+#
  2
+# django-audiofield License
  3
+#
  4
+# This Source Code Form is subject to the terms of the Mozilla Public
  5
+# License, v. 2.0. If a copy of the MPL was not distributed with this file,
  6
+# You can obtain one at http://mozilla.org/MPL/2.0/.
  7
+#
  8
+# Copyright (C) 2011-2012 Star2Billing S.L.
  9
+#
  10
+# The Initial Developer of the Original Code is
  11
+# Arezqui Belaid <info@star2billing.com>
  12
+#
11 13
 
12  
-    def setUp(self):
13  
-        """To create admin user"""
14  
-        self.client = Client()
15  
-        self.user = \
16  
-        User.objects.create_user('admin', 'admin@world.com', 'admin')
17  
-        self.user.is_staff = True
18  
-        self.user.is_superuser = True
19  
-        self.user.is_active = True
20  
-        self.user.save()
21  
-        auth = '%s:%s' % ('admin', 'admin')
22  
-        auth = 'Basic %s' % base64.encodestring(auth)
23  
-        auth = auth.strip()
24  
-        self.extra = {
25  
-            'HTTP_AUTHORIZATION': auth,
26  
-        }
  14
+from django.contrib.auth.models import User
  15
+from django.test import TestCase
  16
+from common.utils import BaseAuthenticatedClient
  17
+from audiofield.models import AudioFile
  18
+from audiofield.forms import CustomerAudioFileForm
27 19
 
28 20
 
29 21
 class AudiofieldAdminInterfaceTestCase(BaseAuthenticatedClient):
30 22
     """Test cases for Audiofield Admin Interface."""
31 23
 
32  
-    def test_admin_index(self):
33  
-        """Test Function to check Admin index page"""
34  
-        response = self.client.get('/admin/')
35  
-        self.failUnlessEqual(response.status_code, 200)
36  
-        response = self.client.login(username=self.user.username,
37  
-                                     password='admin')
38  
-        self.assertEqual(response, True)
39  
-
40 24
     def test_admin_audiofield(self):
41 25
         """Test Function to check Audiofield Admin pages"""
42 26
         response = self.client.get('/admin/audiofield/')
@@ -46,10 +30,27 @@ def test_admin_audiofield(self):
46 30
         self.failUnlessEqual(response.status_code, 200)
47 31
 
48 32
 
49  
-test_cases = [
50  
-    AudiofieldAdminInterfaceTestCase,
51  
-]
  33
+class AudioFileModel(TestCase):
  34
+    """Test AudioFile model"""
  35
+
  36
+    fixtures = ['auth_user.json']
  37
+
  38
+    def setUp(self):
  39
+        self.user = User.objects.get(username='admin')
  40
+        self.audiofile = AudioFile(
  41
+            name='MyAudio',
  42
+            user=self.user,
  43
+        )
  44
+        self.audiofile.save()
  45
+
  46
+    def test_name(self):
  47
+        self.assertEqual(self.audiofile.name, "MyAudio")
  48
+
  49
+    def test_audio_form(self):
  50
+        form = CustomerAudioFileForm(instance=self.audiofile)
52 51
 
  52
+        self.assertTrue(isinstance(form.instance, AudioFile))
  53
+        self.assertEqual(form.instance.pk, self.audiofile.pk)
53 54
 
54  
-def suite():
55  
-    return build_test_suite_from(test_cases)
  55
+    def teardown(self):
  56
+        self.audiofile.delete()
13  audiofield/widgets.py
... ...
@@ -1,3 +1,16 @@
  1
+#
  2
+# django-audiofield License
  3
+#
  4
+# This Source Code Form is subject to the terms of the Mozilla Public
  5
+# License, v. 2.0. If a copy of the MPL was not distributed with this file,
  6
+# You can obtain one at http://mozilla.org/MPL/2.0/.
  7
+#
  8
+# Copyright (C) 2011-2012 Star2Billing S.L.
  9
+#
  10
+# The Initial Developer of the Original Code is
  11
+# Arezqui Belaid <info@star2billing.com>
  12
+#
  13
+
1 14
 from django.contrib.admin.widgets import AdminFileWidget
2 15
 from django import forms
3 16
 from django.utils.translation import ugettext_lazy as _
12  setup.py
... ...
@@ -1,3 +1,15 @@
  1
+#
  2
+# django-audiofield License
  3
+#
  4
+# This Source Code Form is subject to the terms of the Mozilla Public
  5
+# License, v. 2.0. If a copy of the MPL was not distributed with this file,
  6
+# You can obtain one at http://mozilla.org/MPL/2.0/.
  7
+#
  8
+# Copyright (C) 2011-2012 Star2Billing S.L.
  9
+#
  10
+# The Initial Developer of the Original Code is
  11
+# Arezqui Belaid <info@star2billing.com>
  12
+#
1 13
 from setuptools import setup
2 14
 import os
3 15
 import sys

0 notes on commit b2a8f39

Please sign in to comment.
Something went wrong with that request. Please try again.