Permalink
Browse files

updated testcases

  • Loading branch information...
1 parent 5ffe97b commit b2a8f395a8b6591c338772b5b86c6770ed0fe891 @shrenik shrenik committed Aug 13, 2012
View
2 TODO
@@ -4,7 +4,7 @@ TODO
- integrate with django-storage (http://django-storages.readthedocs.org/)
-- support more convertion
+- support more conversion
- use gstreamer
View
13 audiofield/admin.py
@@ -1,3 +1,16 @@
+#
+# 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-2012 Star2Billing S.L.
+#
+# The Initial Developer of the Original Code is
+# Arezqui Belaid <info@star2billing.com>
+#
+
from django.contrib import admin
from django.db.models import *
from audiofield.models import AudioFile
View
13 audiofield/fields.py
@@ -1,3 +1,16 @@
+#
+# 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-2012 Star2Billing S.L.
+#
+# The Initial Developer of the Original Code is
+# Arezqui Belaid <info@star2billing.com>
+#
+
from django.db.models.fields.files import FileField
from django.db.models import signals
from django.conf import settings
View
12 audiofield/forms.py
@@ -1,3 +1,15 @@
+#
+# 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-2012 Star2Billing S.L.
+#
+# The Initial Developer of the Original Code is
+# Arezqui Belaid <info@star2billing.com>
+#
from django import forms
from django.forms.fields import FileField
from django.forms import ModelForm
View
13 audiofield/middleware/threadlocals.py
@@ -1,3 +1,16 @@
+#
+# 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-2012 Star2Billing S.L.
+#
+# The Initial Developer of the Original Code is
+# Arezqui Belaid <info@star2billing.com>
+#
+
import threading
_thread_locals = threading.local()
View
13 audiofield/models.py
@@ -1,3 +1,16 @@
+#
+# 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-2012 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.db import models
from django.utils.translation import ugettext_lazy as _
View
1 audiofield/requirements.txt
@@ -1 +1,2 @@
django-uuidfield
+git+git://github.com/Star2Billing/switch2bill-common.git
View
13 audiofield/tasks.py
@@ -1,3 +1,16 @@
+#
+# 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-2012 Star2Billing S.L.
+#
+# The Initial Developer of the Original Code is
+# Arezqui Belaid <info@star2billing.com>
+#
+
from celery.task import Task
from models import *
import commands
View
24 audiofield/test_utils.py
@@ -1,24 +0,0 @@
-import unittest
-
-
-def build_test_suite_from(test_cases):
- """Returns a single or group of unittest test suite(s) that's ready to be
- run. The function expects a list of classes that are subclasses of
- TestCase.
-
- The function will search the module where each class resides and
- build a test suite from that class and all subclasses of it.
- """
- test_suites = []
- for test_case in test_cases:
- mod = __import__(test_case.__module__)
- components = test_case.__module__.split('.')
- for comp in components[1:]:
- mod = getattr(mod, comp)
- tests = []
- for item in mod.__dict__.values():
- if type(item) is type and issubclass(item, test_case):
- tests.append(item)
- test_suites.append(unittest.TestSuite(map(unittest.TestLoader().\
- loadTestsFromTestCase, tests)))
- return unittest.TestSuite(test_suites)
View
77 audiofield/tests.py
@@ -1,42 +1,26 @@
-from django.contrib.auth.models import User
-from django.test import TestCase, Client
-from django.http import HttpRequest
-from audiofield.test_utils import build_test_suite_from
-import base64
-import simplejson
-
-
-class BaseAuthenticatedClient(TestCase):
- """Common Authentication"""
+#
+# 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-2012 Star2Billing S.L.
+#
+# The Initial Developer of the Original Code is
+# Arezqui Belaid <info@star2billing.com>
+#
- def setUp(self):
- """To create admin user"""
- self.client = Client()
- self.user = \
- User.objects.create_user('admin', 'admin@world.com', 'admin')
- self.user.is_staff = True
- self.user.is_superuser = True
- self.user.is_active = True
- self.user.save()
- auth = '%s:%s' % ('admin', 'admin')
- auth = 'Basic %s' % base64.encodestring(auth)
- auth = auth.strip()
- self.extra = {
- 'HTTP_AUTHORIZATION': auth,
- }
+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_index(self):
- """Test Function to check Admin index page"""
- response = self.client.get('/admin/')
- self.failUnlessEqual(response.status_code, 200)
- response = self.client.login(username=self.user.username,
- password='admin')
- self.assertEqual(response, True)
-
def test_admin_audiofield(self):
"""Test Function to check Audiofield Admin pages"""
response = self.client.get('/admin/audiofield/')
@@ -46,10 +30,27 @@ def test_admin_audiofield(self):
self.failUnlessEqual(response.status_code, 200)
-test_cases = [
- AudiofieldAdminInterfaceTestCase,
-]
+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',
+ 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 suite():
- return build_test_suite_from(test_cases)
+ def teardown(self):
+ self.audiofile.delete()
View
13 audiofield/widgets.py
@@ -1,3 +1,16 @@
+#
+# 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-2012 Star2Billing S.L.
+#
+# The Initial Developer of the Original Code is
+# Arezqui Belaid <info@star2billing.com>
+#
+
from django.contrib.admin.widgets import AdminFileWidget
from django import forms
from django.utils.translation import ugettext_lazy as _
View
12 setup.py
@@ -1,3 +1,15 @@
+#
+# 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-2012 Star2Billing S.L.
+#
+# The Initial Developer of the Original Code is
+# Arezqui Belaid <info@star2billing.com>
+#
from setuptools import setup
import os
import sys

0 comments on commit b2a8f39

Please sign in to comment.