Skip to content

Commit

Permalink
updated testcases
Browse files Browse the repository at this point in the history
  • Loading branch information
shrenik committed Aug 13, 2012
1 parent 5ffe97b commit b2a8f39
Show file tree
Hide file tree
Showing 12 changed files with 143 additions and 63 deletions.
2 changes: 1 addition & 1 deletion TODO
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ TODO

- integrate with django-storage (http://django-storages.readthedocs.org/)

- support more convertion
- support more conversion

- use gstreamer

Expand Down
13 changes: 13 additions & 0 deletions audiofield/admin.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
13 changes: 13 additions & 0 deletions audiofield/fields.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
12 changes: 12 additions & 0 deletions audiofield/forms.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
13 changes: 13 additions & 0 deletions audiofield/middleware/threadlocals.py
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
13 changes: 13 additions & 0 deletions audiofield/models.py
Original file line number Diff line number Diff line change
@@ -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 _
Expand Down
1 change: 1 addition & 0 deletions audiofield/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
django-uuidfield
git+git://github.com/Star2Billing/switch2bill-common.git
13 changes: 13 additions & 0 deletions audiofield/tasks.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
24 changes: 0 additions & 24 deletions audiofield/test_utils.py

This file was deleted.

77 changes: 39 additions & 38 deletions audiofield/tests.py
Original file line number Diff line number Diff line change
@@ -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/')
Expand All @@ -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()
13 changes: 13 additions & 0 deletions audiofield/widgets.py
Original file line number Diff line number Diff line change
@@ -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 _
Expand Down
12 changes: 12 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit b2a8f39

Please sign in to comment.