def test_activity_updated_is_persisted(self, test_activity): a = ActivityGateway.fetch_activity(test_activity) assert a.ended is False test_activity.end() ActivityGateway.update_activity_in_db(test_activity) a = ActivityGateway.fetch_activity(test_activity) assert a.ended is True
def test_after_activity_ends_its_status_changes_and_end_time_is_recorded( self, test_activity): test_activity.end() ActivityGateway.update_activity_in_db(test_activity) assert test_activity.ended_at is not None assert test_activity.status != test_activity.STARTED assert ActivityGateway.fetch_activity( test_activity).status == test_activity.ENDED
def test_track_new_activity_when_another_one_is_already_being_tracked( self, test_activity): assert len(ActivityGateway.activities()) == 1 assert test_activity.ended is False runner = CliRunner() result = runner.invoke(cli, ['working']) assert result.exit_code == 0 assert result.output.count('\n') == 2 _assert_in_output( result.output, ['Started', 'tracking', 'working', 'So far', 'spent', 'today']) assert ActivityGateway.fetch_activity(test_activity).ended is True assert len(ActivityGateway.activities()) == 2
def test_new_ativity_to_track_is_same_category_of_the_last_activity_being_tracked( self, test_activity): assert len(ActivityGateway.activities()) == 1 assert test_activity.ended is False runner = CliRunner() result = runner.invoke(cli, [test_activity.category]) assert result.exit_code == 0 assert result.output.count('\n') == 2 _assert_in_output(result.output, [ 'Started', 'tracking', test_activity.category, 'So far', 'spent', 'today' ]) assert ActivityGateway.fetch_activity(test_activity).ended is True assert len(ActivityGateway.activities()) == 2
def test_starting_to_track_new_activity_automatically_stops_tracking_the_last_one( self, test_activity): assert not test_activity.ended ActivityManager.start_tracking_new_activity('break') assert ActivityGateway.fetch_activity(test_activity).ended
def test_activity_is_removed_from_db(self, test_activity): assert ActivityGateway.fetch_activity(test_activity) is not None ActivityGateway.remove_activity_from_db(test_activity) with pytest.raises(RecordNotFoundError): ActivityGateway.fetch_activity(test_activity)
def test_exception_thrown_when_no_activity_found_in_db_with_that_id( self, test_db): a = ActivityManager.start_new_activity('test_activity') with pytest.raises(RecordNotFoundError): ActivityGateway.fetch_activity(a)
def test_correct_activity_is_found(self, test_activity, test_db): activity = ActivityGateway.fetch_activity(test_activity) assert activity._id == test_activity._id