Skip to content

Commit

Permalink
Adding test to validate return values from the monthly_activity method.
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastian-code committed Jul 10, 2017
1 parent 9f09b4c commit af7b560
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bootcamp/activities/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Meta:
verbose_name_plural = 'Activities'

@staticmethod
def montly_activity(user):
def monthly_activity(user):
"""Static method to retrieve monthly statistical information about the
user activity.
@requires: user - Instance from the User Django model.
Expand Down
19 changes: 19 additions & 0 deletions bootcamp/activities/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,25 @@ def test_activity_daily_statistic(self):
Activity.objects.all().count()), '["{}"]'.format(
activity_one.date.date())))

def test_activity_monthly_statistic(self):
activity_one = Activity.objects.create(
user=self.user,
activity_type='L'
)
activity_two = Activity.objects.create(
user=self.user,
activity_type='L'
)
activity_three = Activity.objects.create(
user=self.user,
activity_type='L'
)
self.assertTrue(isinstance(activity_one, Activity))
self.assertTrue(isinstance(activity_two, Activity))
self.assertTrue(isinstance(activity_three, Activity))
self.assertEqual(Activity.monthly_activity(self.user)[0],
'[{}]'.format(Activity.objects.all().count()))

def test_register_like_notification(self):
notification = Notification.objects.create(
from_user=self.user,
Expand Down

0 comments on commit af7b560

Please sign in to comment.