Skip to content
This repository has been archived by the owner on Apr 14, 2019. It is now read-only.

Commit

Permalink
Merge pull request #264 from caciviclab/bug/test-fixes
Browse files Browse the repository at this point in the history
Bug/test fixes
  • Loading branch information
tdooner authored Aug 20, 2016
2 parents ea8f378 + 20f42da commit b4465b2
Show file tree
Hide file tree
Showing 16 changed files with 363 additions and 145 deletions.
8 changes: 4 additions & 4 deletions ballot/tests/test_api_ballot.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
from rest_framework.test import APITestCase

from ballot.models import Ballot
from finance.tests.test_xformnetfilerawdata import WithForm460ADataTest
from finance.tests.utils import with_form460A_data


class BallotAPITest(WithForm460ADataTest, APITestCase):
@with_form460A_data
class BallotAPITest(APITestCase):

@classmethod
def setUpClass(cls):
WithForm460ADataTest.setUpClass()
APITestCase.setUpClass()
super(BallotAPITest, cls).setUpClass()
cls.ballot = Ballot.objects.all()[0]

def test_ballot(self):
Expand Down
17 changes: 5 additions & 12 deletions ballot/tests/test_api_office_election.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@

from rest_framework.test import APITestCase

from finance.tests.test_xformnetfilerawdata import WithForm460ADataTest
from finance.tests.utils import with_form460A_data
from ballot.models import Candidate, OfficeElection


class OfficeElectionAPITest(WithForm460ADataTest, APITestCase):

@classmethod
def setUpClass(cls):
WithForm460ADataTest.setUpClass()
APITestCase.setUpClass()
@with_form460A_data
class OfficeElectionAPITest(APITestCase):

def test_office_election_with_id(self):
office_election = OfficeElection.objects.all()[0]
Expand All @@ -32,11 +28,8 @@ def test_office_election_bad_id_404(self):
self.assertEqual(resp.status_code, 404)


class CandidateAPITest(WithForm460ADataTest, APITestCase):
@classmethod
def setUpClass(cls):
WithForm460ADataTest.setUpClass()
APITestCase.setUpClass()
@with_form460A_data
class CandidateAPITest(APITestCase):

def test_candidate_with_id(self):
candidate = Candidate.objects.all()[0]
Expand Down
10 changes: 3 additions & 7 deletions ballot/tests/test_api_referendum.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@

from rest_framework.test import APITestCase

from finance.tests.test_xformnetfilerawdata import WithForm460ADataTest
from finance.tests.utils import with_form460A_data
from ballot.models import Ballot, Referendum


class ReferendumAPITest(WithForm460ADataTest, APITestCase):

@classmethod
def setUpClass(cls):
WithForm460ADataTest.setUpClass()
APITestCase.setUpClass()
@with_form460A_data
class ReferendumAPITest(APITestCase):

def test_referendum_with_id(self):
# referendum = Referendum.objects.all()[0]
Expand Down
10 changes: 3 additions & 7 deletions ballot/tests/test_strings.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
from django.test import TestCase

from finance.tests.test_xformnetfilerawdata import WithForm460ADataTest
from finance.tests.utils import with_form460A_data
from ballot.models import (Ballot, BallotItem, BallotItemSelection,
Party)


class BallotStringTests(WithForm460ADataTest, TestCase):

@classmethod
def setUpClass(cls):
TestCase.setUpClass()
WithForm460ADataTest.setUpClass()
@with_form460A_data
class BallotStringTests(TestCase):

def test_strings(self):
"""
Expand Down
13 changes: 5 additions & 8 deletions disclosure/tests/test_api_disclosure_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,24 @@

from ballot.models import Ballot
from finance.models import IndependentMoney
from finance.tests.test_xformnetfilerawdata import WithForm460ADataTest
from finance.tests.utils import with_form460A_data
from locality.models import City


class LocationTests(WithForm460ADataTest, APITestCase):

@classmethod
def setUpClass(cls):
WithForm460ADataTest.setUpClass()
APITestCase.setUpClass()
@with_form460A_data
class LocationTests(APITestCase):

def test_disclosure_summary_contains_data(self):
# Get first city with non-None name
city = City.objects.get(name='Murrieta')
city = City.objects.get(name='San Diego')
ballot = Ballot.objects.filter(locality_id=city.id)[0]
supporting_url = reverse('locality_disclosure_summary',
kwargs={'ballot_id': ballot.id})
resp = self.client.get(supporting_url)
self.assertEqual(resp.status_code, 200, supporting_url)

data = resp.data
self.assertGreater(data['contribution_count'], 0)
self.assertEqual(data['contribution_count'],
IndependentMoney.objects.all().count())

Expand Down
3 changes: 0 additions & 3 deletions disclosure/tests/test_api_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@


class ApiDocsTests(APITestCase):
@classmethod
def setUpClass(cls):
APITestCase.setUpClass()

def test_docs(self):
self.client.get('/docs/') # smoke test
Expand Down
12 changes: 4 additions & 8 deletions disclosure/tests/test_api_search.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
from django.core.urlresolvers import reverse
from rest_framework.test import APITestCase

from finance.tests.test_xformnetfilerawdata import WithForm460ADataTest
from finance.tests.utils import with_form460A_data
from locality.models import City


class SearchTests(WithForm460ADataTest, APITestCase):

@classmethod
def setUpClass(cls):
WithForm460ADataTest.setUpClass()
APITestCase.setUpClass()
@with_form460A_data
class SearchTests(APITestCase):

def test_search_city_with_data(self):
# Get first city with non-None name
city = City.objects.get(name='Murrieta')
city = City.objects.get(name='Oakland')

search_url = '%s?q=%s' % (reverse('search'), city.name)
resp = self.client.get(search_url)
Expand Down
10 changes: 3 additions & 7 deletions disclosure/tests/test_api_supporting_opposing.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
from django.core.urlresolvers import reverse
from rest_framework.test import APITestCase

from finance.tests.test_xformnetfilerawdata import WithForm460ADataTest
from finance.tests.utils import with_form460A_data
from finance.models import Beneficiary


class OpposingTests(WithForm460ADataTest, APITestCase):

@classmethod
def setUpClass(cls):
WithForm460ADataTest.setUpClass(test_agency='COS', test_year='2015')
APITestCase.setUpClass()
@with_form460A_data(test_agency='COS', test_year='2015')
class OpposingTests(APITestCase):

def do_the_thing_for_candidates(self, support):
beneficiary = Beneficiary.objects.filter(
Expand Down
8 changes: 4 additions & 4 deletions disclosure/tests/test_photo_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
from django.test.utils import override_settings

from ballot.models import Candidate
from finance.tests.test_xformnetfilerawdata import WithForm460ADataTest
from finance.tests.utils import with_form460A_data


@with_form460A_data
@override_settings(MEDIA_ROOT=tempfile.mkdtemp(), DEBUG=True)
class ImageUploadTests(WithForm460ADataTest, StaticLiveServerTestCase):
class ImageUploadTests(StaticLiveServerTestCase):

@classmethod
def setUpClass(cls):
WithForm460ADataTest.setUpClass()
StaticLiveServerTestCase.setUpClass()
super(ImageUploadTests, cls).setUpClass()

cls.username = 'admin'
cls.passwd = 'admin'
Expand Down
Loading

0 comments on commit b4465b2

Please sign in to comment.