Skip to content

Commit

Permalink
Update testing to work with new example project.
Browse files Browse the repository at this point in the history
  • Loading branch information
dracos committed Apr 16, 2014
1 parent 619a2c4 commit a652ef5
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 27 deletions.
6 changes: 1 addition & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,9 @@ install:
- gem install --conservative --no-ri --no-rdoc zurb-foundation -v 4.3.2
- pip install $MODULES
- pip install -r requirements.txt
- sed -r
-e "s,(SAYIT_DB_USER:) 'sayit',\\1 'postgres',"
-e "s,(DJANGO_SECRET_KEY:) '',\\1 'secret',"
conf/general.yml-example > conf/general.yml

before_script:
- psql -c 'create database sayit;' -U postgres
- psql -c 'create database "sayit-example-project";' -U postgres
- ./manage.py syncdb --noinput --migrate
- ./manage.py collectstatic --noinput
- export DISPLAY=:99.0
Expand Down
3 changes: 1 addition & 2 deletions speeches/tests/audio_helper_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
from django.core.files import File
from django.utils import timezone

from instances.tests import InstanceTestCase

import speeches
from speeches.tests import InstanceTestCase
from speeches.utils import AudioHelper
from speeches.models import Recording, RecordingTimestamp, Speaker

Expand Down
29 changes: 27 additions & 2 deletions speeches/tests/helpers.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,35 @@
from datetime import datetime, date, time, timedelta

from django.test import TestCase
from django.test import TestCase, LiveServerTestCase
from django.test.utils import override_settings
from django.contrib.auth.models import User

from speeches.models import Section, Speech
from instances.models import Instance

@override_settings(
PASSWORD_HASHERS = ( 'django.contrib.auth.hashers.MD5PasswordHasher', ),
)
class InstanceTestCase(TestCase):
def setUp(self):
self.instance = Instance.objects.create(label='default')
user = User.objects.create_user(username='admin', email='admin@example.org', password='admin')
user.instances.add(self.instance)
self.client.login(username='admin', password='admin')

class InstanceLiveServerTestCase(LiveServerTestCase):
def setUp(self):
self.instance = Instance.objects.create(label='default')
user = User.objects.create_user(username='admin', email='admin@example.org', password='admin')
user.instances.add(self.instance)

self.selenium.get('%s%s' % (self.live_server_url, '/accounts/login/?next=/'))
username_input = self.selenium.find_element_by_name("username")
username_input.send_keys('admin')
password_input = self.selenium.find_element_by_name("password")
password_input.send_keys('admin')
self.selenium.find_element_by_xpath('//input[@value="Log in"]').click()


class ParentInstanceMismatchError(Exception):
pass
Expand Down Expand Up @@ -81,7 +106,7 @@ def create_sections( subsections, parent=None, instance=None):
t = (datetime.combine(date.today(), t) + timedelta(minutes=10)).time()


class CeateSectionsTests(TestCase):
class CreateSectionsTests(TestCase):
def test_parent_instance_mismatch(self):
foo_instance = Instance.objects.create(label="foo")
bar_instance = Instance.objects.create(label="bar")
Expand Down
2 changes: 1 addition & 1 deletion speeches/tests/populate_speakers_command_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.test.utils import override_settings

from popit.models import ApiInstance, Person
from instances.tests import InstanceTestCase
from speeches.tests import InstanceTestCase
from speeches.models import Speaker

class PopulateSpeakersCommandTests(InstanceTestCase):
Expand Down
3 changes: 1 addition & 2 deletions speeches/tests/recording_api_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
from django.utils import simplejson
from django.conf import settings

from instances.tests import InstanceTestCase

import speeches
from speeches.models import Speech, Speaker, Recording, RecordingTimestamp
from speeches.tests import InstanceTestCase

@override_settings(MEDIA_ROOT=tempfile.mkdtemp())
class RecordingAPITests(InstanceTestCase):
Expand Down
3 changes: 1 addition & 2 deletions speeches/tests/recording_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
from django.test.utils import override_settings
from django.conf import settings

from instances.tests import InstanceTestCase

import speeches
from speeches.models import Speech, Recording, Section
from speeches.tests import InstanceTestCase

logging.disable(logging.WARNING)

Expand Down
3 changes: 1 addition & 2 deletions speeches/tests/recording_timestamp_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
from django.utils import simplejson
from django.conf import settings

from instances.tests import InstanceTestCase

import speeches
from speeches.models import Speech, Speaker, Recording, RecordingTimestamp
from speeches.utils import AudioHelper
from speeches.tests import InstanceTestCase

import logging
logging.disable(logging.WARNING)
Expand Down
2 changes: 1 addition & 1 deletion speeches/tests/search_tests.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from django.core.management import call_command
from haystack.query import SearchQuerySet
from instances.tests import InstanceTestCase

from speeches.models import Speech, Speaker, Section
from speeches.tests import InstanceTestCase

class SearchTests(InstanceTestCase):
def test_search(self):
Expand Down
2 changes: 1 addition & 1 deletion speeches/tests/section_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from speeches.models import Section, Speech
from speeches.tests import create_sections
from instances.models import Instance
from instances.tests import InstanceTestCase
from speeches.tests import InstanceTestCase

class SectionModelTests(TestCase):

Expand Down
4 changes: 1 addition & 3 deletions speeches/tests/selenium_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait

from django.test import LiveServerTestCase
from django.test.utils import override_settings
from django.utils import unittest
from django.conf import settings

from instances.tests import InstanceLiveServerTestCase

import speeches
from speeches.models import Speaker, Speech
from speeches.tests import InstanceLiveServerTestCase

skip_selenium = not os.environ.get('SELENIUM_TESTS', False)

Expand Down
3 changes: 1 addition & 2 deletions speeches/tests/smoke_tests.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from instances.tests import InstanceTestCase

from speeches.tests import InstanceTestCase
from speeches.models import Speech, Speaker, Section

class SmokeTests(InstanceTestCase):
Expand Down
3 changes: 1 addition & 2 deletions speeches/tests/speaker_tests.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from instances.tests import InstanceTestCase

from speeches.tests import InstanceTestCase
from speeches.models import Speaker, Speech, Section
from popit.models import Person, ApiInstance

Expand Down
2 changes: 1 addition & 1 deletion speeches/tests/speech_api_tests.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.conf import settings
from django.utils import simplejson as json

from instances.tests import InstanceTestCase
from speeches.tests import InstanceTestCase
from speeches.models import Speech

class SpeechAPITests(InstanceTestCase):
Expand Down
2 changes: 1 addition & 1 deletion speeches/tests/speech_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from django.test.utils import override_settings
from django.conf import settings

from instances.tests import InstanceTestCase
from speeches.tests import InstanceTestCase

import speeches
from speeches.models import Speech, Speaker, Section
Expand Down

0 comments on commit a652ef5

Please sign in to comment.