mirror of
https://github.com/etnguyen03/tjdests.git
synced 2025-04-21 02:00:16 -04:00
feat(destinations): add international school import
This commit is contained in:
parent
317a8e0a21
commit
f2e65f0d1a
|
@ -21,6 +21,17 @@ class Command(BaseCommand):
|
|||
reader = csv.DictReader(file)
|
||||
|
||||
for line in reader:
|
||||
# International colleges are treated specially because
|
||||
# they do not have CEEB codes.
|
||||
if line["CEEB"] == "INTL":
|
||||
result = College.objects.update_or_create(
|
||||
ceeb_code=line["CEEB"],
|
||||
name=line["College Name"],
|
||||
defaults={
|
||||
"location": f"{line['City']}, {line['State']}",
|
||||
},
|
||||
)
|
||||
else:
|
||||
result = College.objects.update_or_create(
|
||||
ceeb_code=line["CEEB"],
|
||||
defaults={
|
||||
|
|
|
@ -285,7 +285,8 @@ class DestinationsTest(TJDestsTestCase):
|
|||
file_contents = (
|
||||
"CEEB,College Name,City,State\n"
|
||||
"1234,Test University,Alexandria,VA\n"
|
||||
"1235,University of Test,Arlington,VA"
|
||||
"1235,University of Test,Arlington,VA\n"
|
||||
"INTL,University of Abroad,ExampleCity,RANDOMCOUNTRY"
|
||||
)
|
||||
with patch(
|
||||
"tjdests.apps.destinations.management.commands.import_ceeb.open",
|
||||
|
@ -307,8 +308,19 @@ class DestinationsTest(TJDestsTestCase):
|
|||
ceeb_code="1235", name="University of Test", location="Arlington, VA"
|
||||
).count(),
|
||||
)
|
||||
self.assertEqual(1, College.objects.filter(ceeb_code="INTL", name="University of Abroad", location="ExampleCity, RANDOMCOUNTRY").count())
|
||||
|
||||
# Doing it again should have no duplicates
|
||||
# But let's add a few more...
|
||||
|
||||
file_contents = (
|
||||
"CEEB,College Name,City,State\n"
|
||||
"1234,Test University,Alexandria,VA\n"
|
||||
"1235,University of Test,Arlington,VA\n"
|
||||
"INTL,University of Abroad,ExampleCity,RANDOMCOUNTRY\n"
|
||||
"INTL,University of Abroad in CityTwo,CityTwo,RANDOMCOUNTRY\n"
|
||||
)
|
||||
|
||||
with patch(
|
||||
"tjdests.apps.destinations.management.commands.import_ceeb.open",
|
||||
mock_open(read_data=file_contents),
|
||||
|
@ -329,3 +341,5 @@ class DestinationsTest(TJDestsTestCase):
|
|||
ceeb_code="1235", name="University of Test", location="Arlington, VA"
|
||||
).count(),
|
||||
)
|
||||
self.assertEqual(1, College.objects.filter(ceeb_code="INTL", name="University of Abroad", location="ExampleCity, RANDOMCOUNTRY").count())
|
||||
self.assertEqual(1, College.objects.filter(ceeb_code="INTL", name="University of Abroad in CityTwo", location="CityTwo, RANDOMCOUNTRY").count())
|
||||
|
|
Loading…
Reference in New Issue
Block a user