Skip to content

Commit

Permalink
Fix assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
zrthxn committed May 19, 2021
1 parent 9eeb8eb commit 549bd3f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion subscribers/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ class Subscriber(models.Model):
)

def __str__(self):
return f"{self.email} {f'#{self.phone_number}' if self.phone_number is not None else ''}"
s = []
if self.email: s.append(str(self.email))
if self.phone_number: s.append(str(self.phone_number))

return " ".join(s)

@staticmethod
def _filter_centers(centers, age_limit):
Expand Down
4 changes: 4 additions & 0 deletions subscribers/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ def setUp(self):
self.subscriber2 = Subscriber.objects.create(
phone_number="9999999999", district_id=1
)
self.subscriber3 = Subscriber.objects.create(
email="[email protected]", phone_number="9999999999", pincode=222222, district_id=2
)

self.test_centers = [
{
Expand Down Expand Up @@ -149,6 +152,7 @@ def setUp(self):
def test_str_method(self):
self.assertEqual(str(self.subscriber1), "[email protected]")
self.assertEqual(str(self.subscriber2), "+919999999999")
self.assertEqual(str(self.subscriber3), "[email protected] +919999999999")

def test_filter_centers(self):
filter_18 = Subscriber._filter_centers(self.parsed_test_centers, 18)
Expand Down

0 comments on commit 549bd3f

Please sign in to comment.