Skip to content

Commit

Permalink
--amend
Browse files Browse the repository at this point in the history
  • Loading branch information
higs4281 committed Dec 16, 2017
1 parent 7e343a1 commit f871196
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 26 deletions.
28 changes: 7 additions & 21 deletions countylimits/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from django.core.management import call_command
from django.core.management.base import CommandError
from django.test import Client
from django.core.urlresolvers import reverse
from django.utils.six import StringIO

from countylimits.models import County, CountyLimit, State
Expand Down Expand Up @@ -287,7 +286,6 @@ def setUp(self):
county=County.objects.get(county_name='Accomack County'))

url = '/oah-api/county/'
reverse_url = reverse('county_limits')

def test_county_limits_by_state__no_args(self):
""" ... when state is blank """
Expand All @@ -308,26 +306,14 @@ def test_county_limit_by_state__invalid_arg(self):

def test_county_limit_by_state__valid_arg(self):
""" ... when state has a valid arg """
self.AL.save()
self.VA.save()
self.DC.save()
response_01 = client.get(self.url, {'state': '01'})
print("url is {}".format(self.url))
print("reverse_url is {}".format(self.reverse_url))
print("request status text is {}".format(response_01.status_text))
print("request path is {}".format(response_01.wsgi_request.path))
print("request container is {}\n\n".format(response_01._container))
print("\n\nAlabama is {}".format(self.AL))
print("Virginia is {}".format(self.VA))
print("DC is {}".format(self.DC))
print("Accomack is {}".format(self.VACO))
# self.assertEqual(response_01.status_code, 200)
# self.assertEqual('Autauga County',
# response_01.data['data'][0]['county'])
# response_AL = client.get(self.url, {'state': 'AL'})
# self.assertTrue(response_01.data['data'] == response_AL.data['data'])
# response_DC = client.get(self.url, {'state': 'DC'})
# self.assertEqual(len(response_DC.data['data']), 1)
self.assertEqual(response_01.status_code, 200)
self.assertEqual('Autauga County',
response_01.data['data'][0]['county'])
response_AL = client.get(self.url, {'state': 'AL'})
self.assertTrue(response_01.data['data'] == response_AL.data['data'])
response_DC = client.get(self.url, {'state': 'DC'})
self.assertEqual(len(response_DC.data['data']), 1)
response_VA = client.get(self.url, {'state': 'VA'})
self.assertEqual(len(response_VA.data['data']), 1)
self.assertEqual('Accomack County',
Expand Down
18 changes: 13 additions & 5 deletions countylimits/views.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
from __future__ import unicode_literals

from rest_framework import status
from rest_framework.decorators import api_view
from rest_framework.response import Response

from countylimits.models import CountyLimit, State
from countylimits.models import CountyLimit

SAFE_STATE_LIST = ( # states can be specified by abbreviation or FIPS code
list(State.objects.values_list('state_abbr', flat=True)) +
list(State.objects.values_list('state_fips', flat=True))
)
SAFE_STATE_LIST = [ # A static whitelist of abbreviations and FIPS codes
'AL', 'AK', 'AZ', 'AR', 'CA', 'CO', 'CT', 'DE', 'DC', 'FL', 'GA', 'HI', 'ID',
'IL', 'IN', 'IA', 'KS', 'KY', 'LA', 'ME', 'MD', 'MA', 'MI', 'MN', 'MS', 'MO',
'MT', 'NE', 'NV', 'NH', 'NJ', 'NM', 'NY', 'NC', 'ND', 'OH', 'OK', 'OR', 'PA',
'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VT', 'VA', 'WA', 'WV', 'WI', 'WY', 'AS',
'GU', 'MP', 'PR', 'VI', '01', '02', '04', '05', '06', '08', '09', '10', '11',
'12', '13', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25',
'26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37', '38',
'39', '40', '41', '42', '44', '45', '46', '47', '48', '49', '50', '51', '53',
'54', '55', '56', '60', '66', '69', '72', '78']


@api_view(['GET'])
Expand Down

0 comments on commit f871196

Please sign in to comment.