Skip to content

Commit

Permalink
Fix test and remove debugging statements
Browse files Browse the repository at this point in the history
  • Loading branch information
amymok committed Jan 3, 2018
1 parent 49a31dc commit 6ec8e15
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
3 changes: 0 additions & 3 deletions mapusaurus/censusdata/management/commands/load_summary_one.py
Expand Up @@ -31,11 +31,8 @@ def handle(self, *args, **options):
if line[8:11] == '140': # Aggregated by Census Tract
recordnum = line[18:25]
censustract = line[27:32] + line[54:60]
print "censustract", censustract
censustract = errors.in_2010.get(censustract, censustract)
print "censustract after in 2010", censustract
censustract = errors.change_specific_year(censustract, year)
print "censustract after spec year", censustract
if censustract is not None:
geoids_by_record[recordnum] = year + censustract
state = line[27:29]
Expand Down
11 changes: 7 additions & 4 deletions mapusaurus/censusdata/tests/test_loader.py
Expand Up @@ -8,6 +8,7 @@
from censusdata import models
from censusdata.management.commands.load_summary_one import Command

import geo.errors

class LoadSummaryDataTest(TestCase):
fixtures = ['mock_geo']
Expand Down Expand Up @@ -38,26 +39,28 @@ def test_handle(self, hf3, hf4, hf5):
self.assertEqual(positional_args[3]['0007159'], year+'11001000100')
self.assertEqual(positional_args[3]['0007211'], year+'11001000902')

@patch('censusdata.management.commands.load_summary_one.errors')
@patch.object(Command, 'handle_filefive')
@patch.object(Command, 'handle_filefour')
@patch.object(Command, 'handle_filethree')
def test_handle_errors_dict(self, hf3, hf4, hf5, errors):
def test_handle_errors_dict(self, hf3, hf4, hf5):
year = '2001'
errors.in_2010 = {'11001000100': '22002000200', '11001000902': None}
old_geo_errors = geo.errors.in_2010
geo.errors.in_2010 = {'11001000100': '22002000200', '11001000902': None}

# Create Mock GEO file
shutil.copyfile(os.path.join("censusdata", "tests", "mock_geo.txt"),
os.path.join(self.tempdir, "ZZgeo2010.sf1"))

command = Command()
command.handle(os.path.join(self.tempdir, 'ZZgeo2010.sf1'), year)
positional_args = hf4.call_args[0]
print "positional_args", positional_args
# The None causes us to skip 11001000902
self.assertEqual(len(positional_args[2]), 2)
# This entry was converted
self.assertEqual(positional_args[3]['0007159'], year+'22002000200')

geo.errors.in_2010 = old_geo_errors

def test_handle_filethree(self):
shutil.copyfile(os.path.join("censusdata", "tests", "mock_file3.txt"),
os.path.join(self.tempdir, "ZZ000032010.sf1"))
Expand Down

0 comments on commit 6ec8e15

Please sign in to comment.