def test_handle_filethree(self): shutil.copyfile(os.path.join("censusdata", "tests", "mock_file3.txt"), os.path.join(self.tempdir, "ZZ000032010.sf1")) command = Command() command.handle_filethree(os.path.join(self.tempdir, "ZZgeo2010.sf1"), '11', # State {'0007159': '11001000100', '0007211': '11001000902'}) model = models.Census2010RaceStats.objects.get(pk='11001000100') self.assertEqual(model.total_pop, 4890) self.assertEqual(model.hispanic, 296) self.assertEqual(model.non_hisp_white_only, 4202) self.assertEqual(model.non_hisp_black_only, 101) self.assertEqual(model.non_hisp_asian_only, 198) model.delete() model = models.Census2010RaceStats.objects.get(pk='11001000902') self.assertEqual(model.total_pop, 2092) self.assertEqual(model.hispanic, 107) self.assertEqual(model.non_hisp_white_only, 1776) self.assertEqual(model.non_hisp_black_only, 63) self.assertEqual(model.non_hisp_asian_only, 77) model.delete() self.assertEqual(len(models.Census2010RaceStats.objects.all()), 0)
def test_handle_filethree_no_delete(self): shutil.copyfile(os.path.join("censusdata", "tests", "mock_file3.txt"), os.path.join(self.tempdir, "ZZ000032010.sf1")) command = Command() command.handle_filethree( os.path.join(self.tempdir, "ZZgeo2010.sf1"), '2013', '11', # State { '0007159': '11001000100', '0007211': '11001000902' }) self.assertEqual(len(models.Census2010RaceStats.objects.all()), 2) models.Census2010RaceStats.objects.all()[0].delete() self.assertEqual(len(models.Census2010RaceStats.objects.all()), 1) # Importing again should do nothing command.handle_filethree( os.path.join(self.tempdir, "ZZgeo2010.sf1"), '2013', '11', # State { '0007159': '11001000100', '0007211': '11001000902' }) self.assertEqual(len(models.Census2010RaceStats.objects.all()), 1) models.Census2010RaceStats.objects.all().delete()
def test_handle_filethree_no_delete(self): shutil.copyfile(os.path.join("censusdata", "tests", "mock_file3.txt"), os.path.join(self.tempdir, "ZZ000032010.sf1")) command = Command() command.handle_filethree(os.path.join(self.tempdir, "ZZgeo2010.sf1"), '11', # State {'0007159': '11001000100', '0007211': '11001000902'}) self.assertEqual(len(models.Census2010RaceStats.objects.all()), 2) models.Census2010RaceStats.objects.all()[0].delete() self.assertEqual(len(models.Census2010RaceStats.objects.all()), 1) # Importing again should do nothing command.handle_filethree(os.path.join(self.tempdir, "ZZgeo2010.sf1"), '11', # State {'0007159': '11001000100', '0007211': '11001000902'}) self.assertEqual(len(models.Census2010RaceStats.objects.all()), 1) models.Census2010RaceStats.objects.all().delete()