def test_user_has_activities_on_different_days_but_only_1_today(
         self, test_user_with_multiple_activities_on_multiple_days,
         test_activity, test_db):
     todays_activities = ActivityGateway.activities_today_in_this_category(
         test_activity.category)
     assert len(todays_activities) == 1
     assert test_activity._id == todays_activities[0]._id
    def test_user_has_more_than_one_activity_today_but_only_one_is_what_we_want_and_more_activities_on_other_days(
            self, test_user_with_multiple_activities_on_multiple_days, test_db,
            test_activity):
        test_working_activity = ActivityManager.start_new_activity('working')
        ActivityGateway.add_new_activity_to_db(test_working_activity)

        todays_activities = ActivityGateway.activities_today_in_this_category(
            'working')
        assert len(todays_activities) == 1
        assert test_working_activity._id == todays_activities[0]._id
Example #3
0
    def generate_for_this_category_of_activity(cls, category: str,
                                               days: int) -> Dict[str, int]:
        total_activity_length = 0

        if days == 0:
            for activity in ActivityGateway.activities_today_in_this_category(
                    category):
                total_activity_length += activity.length
        else:
            for activity in ActivityGateway.activities_in_last_n_days_in_this_category(
                    days, category):
                total_activity_length += activity.length

        return {category: total_activity_length}
 def test_one_activity_returned_when_only_one_started_today(
         self, test_db, test_activity):
     todays_activities = ActivityGateway.activities_today_in_this_category(
         test_activity.category)
     assert len(todays_activities) == 1
     assert test_activity._id == todays_activities[0]._id
 def test_no_activities_returned_when_nothing_started_today(self, test_db):
     assert len(
         ActivityGateway.activities_today_in_this_category('working')) == 0