diff --git a/mapusaurus/censusdata/management/commands/load_summary_one.py b/mapusaurus/censusdata/management/commands/load_summary_one.py index 393d000a..bd3e41b2 100644 --- a/mapusaurus/censusdata/management/commands/load_summary_one.py +++ b/mapusaurus/censusdata/management/commands/load_summary_one.py @@ -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] diff --git a/mapusaurus/censusdata/tests/test_loader.py b/mapusaurus/censusdata/tests/test_loader.py index 95ff5aaa..e80f1287 100644 --- a/mapusaurus/censusdata/tests/test_loader.py +++ b/mapusaurus/censusdata/tests/test_loader.py @@ -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'] @@ -38,13 +39,14 @@ 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")) @@ -52,12 +54,13 @@ def test_handle_errors_dict(self, hf3, hf4, hf5, errors): 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"))