Beispiel #1
0
 def setUp(self):
     file = open(MULTI_AGENCY_FIXTURE, 'r')
     self.counts = ImportCounters()
     save_records_to_database(read_records_from_file(file), self.counts)
     self.all_locations = Location.objects.all()
     self.all_organizations = Organization.objects.all()
     self.all_taxonomy_terms = TaxonomyTerm.objects.all()
Beispiel #2
0
    def test_save_organizations_catches_exceptions(self):
        save_records_to_database(
            read_records_from_file(open(INVALID_AGENCIES_FIXTURE, 'r')),
            ImportCounters())
        organizations = Organization.objects.all()
        organization_ids = list(map(lambda x: x.id, organizations))

        self.assertEqual(len(organization_ids), 2)
        self.assertIn('SECOND_VALID_AGENCY', organization_ids)
        self.assertIn('FIRST_VALID_AGENCY', organization_ids)
    def handle(self, *args, **options):
        path = options['file']
        records = read_records_from_file(path)
        counts = save_records_to_database(records)

        message_template = ('Successfully imported {0} organization(s), '
                            '{1} location(s), {2} service(s), '
                            '{3} taxonomy term(s), and {4} address(es)')
        status_message = message_template.format(counts.organization_count,
                                                 counts.location_count,
                                                 counts.service_count,
                                                 counts.taxonomy_term_count,
                                                 counts.address_count)
        self.stdout.write(self.style.SUCCESS(status_message))
Beispiel #4
0
 def setUp(self):
     file = open(MULTI_AGENCY_FIXTURE, 'r')
     save_records_to_database(read_records_from_file(file),
                              ImportCounters())
     self.all_taxonomy_terms = TaxonomyTerm.objects.all()
     self.all_services = Service.objects.all()
Beispiel #5
0
 def setUp(self):
     save_records_to_database(
         read_records_from_file(open(ONE_AGENCY_FIXTURE, 'r')),
         ImportCounters())
     organizations = Organization.objects.all()
     self.organization = organizations[0]
Beispiel #6
0
 def setUp(self):
     file = open(ONE_AGENCY_FIXTURE, 'r')
     records = read_records_from_file(file)
     save_records_to_database(records, ImportCounters())
     all_records_from_database = Location.objects.all()
     self.location = all_records_from_database[0]
Beispiel #7
0
 def setUp(self):
     file = open(ONE_AGENCY_FIXTURE, 'r')
     records = read_records_from_file(file)
     save_records_to_database(records, ImportCounters())
     self.addresses = Address.objects.all()
Beispiel #8
0
 def testTwoServicesCanBeRelatedToOneLocation(self):
     file = open(SHARED_SERVICE_FIXTURE, 'r')
     save_records_to_database(read_records_from_file(file),
                              ImportCounters())
     self.assertEqual(
         Service.objects.filter(locations__id='9493390').count(), 2)
 def setUp(self):
     file = open(MULTI_AGENCY_FIXTURE, 'r')
     self.return_value = save_records_to_database(read_records_from_file(file))
     self.all_locations = Location.objects.all()
     self.all_organizations = Organization.objects.all()
     self.all_taxonomy_terms = TaxonomyTerm.objects.all()