def test_method_stops_tracking_last_activity_properly_when_there_are_more_than_one_activities_in_db(
         self, test_activity,
         test_user_with_multiple_activities_on_multiple_days):
     ActivityManager.stop_tracking_last_activity()
     assert ActivityGateway.fetch_last_activity_started(
     )._id == test_activity._id
     assert ActivityGateway.fetch_last_activity_started().ended
예제 #2
0
def cli(activity):
    """
    Track how much time you spend on different activities throughout the day!
    ACTIVITY is the type of activity you want to start tracking. Examples: working, reading, studying.
    To see a report, use the "timereport" command.
    """

    if activity in RESERVED_ARGUMENTS:
        if activity.lower() == STOP_TRACKING_TIME_ARGUMENT:
            try:
                last_activity = ActivityGateway.fetch_last_activity_started()
                ActivityManager.stop_tracking_last_activity()
                click.echo('Stopped tracking {}'.format(last_activity.category))
            except IndexError:
                click.echo('I was not tracking any activity!')

    else:
        a = ActivityManager.start_tracking_new_activity(activity)
        click.echo('Started tracking "%s".' % a.category)
        click.echo(
            "So far, you've spent {} on {} today!".format(
                format_seconds_returnbed_by_report(
                    TimeSpentInCategoryReport.generate_for_this_category_of_activity(activity, 0)[activity]
                ),
                activity
            )
        )
 def test_method_stops_tracking_last_activity_properly_when_theres_only_one_in_db(
         self, test_activity):
     ActivityManager.stop_tracking_last_activity()
     assert ActivityGateway.fetch_last_activity_started(
     )._id == test_activity._id
     assert ActivityGateway.fetch_last_activity_started().ended