Exemple #1
0
    def test_createzipcode(self):
        ZipcodeCityState.objects.all().delete()
        zipcode_utils.create_zipcode('20852', 'Rockville', 'MD')

        results = ZipcodeCityState.objects.filter(state='MD')
        self.assertEqual(1, len(results))

        self.assertEqual(results[0].zip_code, 20852)
        self.assertEqual(results[0].city, 'Rockville')
        self.assertEqual(results[0].state, 'MD')
Exemple #2
0
    def test_createzipcode(self):
        ZipcodeCityState.objects.all().delete()
        zipcode_utils.create_zipcode('20852', 'Rockville', 'MD')

        results = ZipcodeCityState.objects.filter(state='MD')
        self.assertEqual(1, len(results))

        self.assertEqual(results[0].zip_code, 20852)
        self.assertEqual(results[0].city, 'Rockville')
        self.assertEqual(results[0].state, 'MD')
    def handle(self, *args, **options):
        transmittal_filename = args[0]

        agencies = Agency.objects.get_all_by_code()

        with open(transmittal_filename) as institutioncsv:
            transmittal_reader = csv.reader(institutioncsv, delimiter='\t')
            institutions = []
            for inst_line in transmittal_reader:
                zip_code = inst_line[8]
                state = inst_line[7]
                city = inst_line[6]
                zipcode_city = create_zipcode(zip_code, city, state)

                agency = agencies[int(inst_line[2])]

                inst = Institution(
                    year=inst_line[0],
                    ffiec_id=inst_line[1],
                    agency=agency,
                    tax_id=inst_line[3],
                    name=inst_line[4],
                    mailing_address=inst_line[5],
                    zip_code=zipcode_city,
                )

                institutions.append(inst)
            Institution.objects.bulk_create(institutions)
    def handle(self, *args, **options):
        transmittal_filename = args[0]

        agencies = Agency.objects.get_all_by_code()

        with open(transmittal_filename) as institutioncsv:
            transmittal_reader = csv.reader(institutioncsv, delimiter='\t')
            institutions = []
            for inst_line in transmittal_reader:
                zip_code = inst_line[8]
                state = inst_line[7]
                city = inst_line[6]
                zipcode_city = create_zipcode(zip_code, city, state)

                agency = agencies[int(inst_line[2])]

                inst = Institution(
                    year=inst_line[0],
                    ffiec_id=inst_line[1],
                    agency=agency,
                    tax_id=inst_line[3],
                    name=inst_line[4],
                    mailing_address=inst_line[5],
                    zip_code=zipcode_city,
                    assets=int(inst_line[17]),
                )

                institutions.append(inst)
            Institution.objects.bulk_create(institutions)
Exemple #5
0
 def test_duplicate_entries(self):
     """ We insert a duplicate entry, and check that it wasn't in fact
     duplicated. """
     zipcode_utils.create_zipcode('20852', 'Rockville', 'MD')
     results = ZipcodeCityState.objects.filter(state='MD')
     self.assertEqual(1, len(results))
Exemple #6
0
 def test_duplicate_entries(self):
     """ We insert a duplicate entry, and check that it wasn't in fact
     duplicated. """
     zipcode_utils.create_zipcode('20852', 'Rockville', 'MD')
     results = ZipcodeCityState.objects.filter(state='MD')
     self.assertEqual(1, len(results))