Skip to content

Commit

Permalink
return for unfound School, and simplify field content test
Browse files Browse the repository at this point in the history
  • Loading branch information
higs4281 committed Apr 25, 2017
1 parent 3a427e6 commit f32b520
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions paying_for_college/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -755,12 +755,12 @@ def parsed_url(self):
def school(self):
"""Returns a school object, derived from a feedback url"""
if not self.url:
return ''
return None
row = self.parsed_url
if row and row.get('iped'):
return School.objects.get(pk=row['iped'])
else:
return ''
return None

@property
def unmet_cost(self):
Expand All @@ -772,7 +772,7 @@ def unmet_cost(self):
def total_fields(field_list):
total = 0
for field in field_list:
if field in url_data.keys() and url_data[field] != '':
if field in url_data.keys() and url_data.get(field, '') != '':
try:
total += int(url_data[field])
except ValueError:
Expand Down
4 changes: 2 additions & 2 deletions paying_for_college/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,9 @@ def test_feedback_school(self):
feedback = self.create_feedback()
self.assertEqual(feedback.school, school)
feedback.url = feedback.url.replace("iped=451796&", '')
self.assertEqual(feedback.school, '')
self.assertEqual(feedback.school, None)
feedback.url = ''
self.assertEqual(feedback.school, '')
self.assertEqual(feedback.school, None)

def test_feedback_unmet_cost(self):
feedback = self.create_feedback()
Expand Down

0 comments on commit f32b520

Please sign in to comment.