Skip to content

Commit

Permalink
change -m/--message to -n/--note
Browse files Browse the repository at this point in the history
-m and -M are currently used by some commands.  -n and -N aren't.  This diverges from the git -m/--message naming we were copying, but that doesn't bother me too much.  The parameter behaves slightly different in watson, so it might even be better that we don't reuse a commonly used parameter name in another tool, as not to cause confusion
  • Loading branch information
prat0088 committed Jan 13, 2020
1 parent 3a08968 commit d80f4db
Show file tree
Hide file tree
Showing 7 changed files with 133 additions and 133 deletions.
6 changes: 3 additions & 3 deletions docs/user-guide/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -690,13 +690,13 @@ specified time must be after the begin of the to be ended frame and must
not be in the future.

You can optionally pass a log message to be saved with the frame via
the ``-m/--message`` option.
the ``-n/--note`` option.

Example:

$ watson stop --at 13:37
Stopping project apollo11, started an hour ago and stopped 30 minutes ago. (id: e9ccd52) # noqa: E501
$ watson stop -m "Done some thinking"
$ watson stop -n "Done some thinking"
Stopping project apollo11, started a minute ago. (id: e7ccd52)
Log message: Done some thinking

Expand All @@ -705,7 +705,7 @@ Example:
Flag | Help
-----|-----
`--at TIME` | Stop frame at this time. Must be in (YYYY-MM-DDT)?HH:MM(:SS)? format.
`-m, --message TEXT` | Save given log message with the project frame.
`-n, --note TEXT` | Save given log message with the project frame.
`--help` | Show this message and exit.

## `sync`
Expand Down
4 changes: 2 additions & 2 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def test_frames_to_csv(watson):
result = frames_to_csv(watson.frames)

read_csv = list(csv.reader(StringIO(result)))
header = ['id', 'start', 'stop', 'project', 'tags', 'message']
header = ['id', 'start', 'stop', 'project', 'tags', 'note']
assert len(read_csv) == 2
assert read_csv[0] == header
assert read_csv[1][3] == 'foo'
Expand All @@ -302,7 +302,7 @@ def test_frames_to_json(watson):

result = json.loads(frames_to_json(watson.frames))

keys = {'id', 'start', 'stop', 'project', 'tags', 'message'}
keys = {'id', 'start', 'stop', 'project', 'tags', 'note'}
assert len(result) == 1
assert set(result[0].keys()) == keys
assert result[0]['project'] == 'foo'
Expand Down
76 changes: 38 additions & 38 deletions tests/test_watson.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ def test_frames_without_tags(mocker, watson):
assert watson.frames[0].tags == []


def test_frames_with_message(mocker, watson):
"""Test loading frames with messages."""
def test_frames_with_note(mocker, watson):
"""Test loading frames with notes."""
content = json.dumps([
[3601, 3610, 'foo', 'abcdefg', ['A', 'B', 'C'], 3650,
"My hovercraft is full of eels"]
Expand All @@ -165,11 +165,11 @@ def test_frames_with_message(mocker, watson):
assert frame.start == arrow.get(3601)
assert frame.stop == arrow.get(3610)
assert frame.tags == ['A', 'B', 'C']
assert frame.message == "My hovercraft is full of eels"
assert frame.note == "My hovercraft is full of eels"


def test_frames_without_message(mocker, watson):
"""Test loading frames without messages."""
def test_frames_without_note(mocker, watson):
"""Test loading frames without notes."""
content = json.dumps([
[3601, 3610, 'foo', 'abcdefg'],
[3611, 3620, 'foo', 'hijklmn', ['A', 'B', 'C']],
Expand All @@ -184,18 +184,18 @@ def test_frames_without_message(mocker, watson):
assert frame.start == arrow.get(3601)
assert frame.stop == arrow.get(3610)
assert frame.tags == []
assert frame.message is None
assert frame.note is None

frame = watson.frames['hijklmn']
assert frame.id == 'hijklmn'
assert frame.tags == ['A', 'B', 'C']
assert frame.message is None
assert frame.note is None

frame = watson.frames['opqrstu']
assert frame.id == 'opqrstu'
assert frame.tags == ['A', 'B', 'C']
assert frame.updated_at == arrow.get(3630)
assert frame.message is None
assert frame.note is None


def test_frames_with_empty_file(mocker, watson):
Expand Down Expand Up @@ -350,8 +350,8 @@ def test_stop_started_project_without_tags(watson):
assert watson.frames[0].tags == []


def test_stop_started_project_without_message(watson):
"""Test stopping watson without adding a message."""
def test_stop_started_project_without_note(watson):
"""Test stopping watson without adding a note."""
watson.start('foo')
watson.stop()

Expand All @@ -360,11 +360,11 @@ def test_stop_started_project_without_message(watson):
assert len(watson.frames) == 1
frame = watson.frames[0]
assert frame.project == 'foo'
assert frame.message is None
assert frame.note is None


def test_stop_started_project_with_message(watson):
"""Test stopping watson when adding a message."""
def test_stop_started_project_with_note(watson):
"""Test stopping watson when adding a note."""
watson.start('foo')
watson.stop(None, "My hovercraft is full of eels")

Expand All @@ -373,7 +373,7 @@ def test_stop_started_project_with_message(watson):
assert len(watson.frames) == 1
frame = watson.frames[0]
assert frame.project == 'foo'
assert frame.message == "My hovercraft is full of eels"
assert frame.note == "My hovercraft is full of eels"


def test_stop_no_project(watson):
Expand Down Expand Up @@ -463,7 +463,7 @@ def test_save_empty_current(config_dir, mocker, json_mock):
assert json_mock.call_count == 1
result = json_mock.call_args[0][0]
assert result == {'project': 'foo', 'start': 4000,
'tags': [], 'message': None}
'tags': [], 'note': None}

watson.current = {}
watson.save()
Expand Down Expand Up @@ -823,12 +823,12 @@ def test_report(watson):
assert 'time' in report['projects'][0]['tags'][0]
assert report['projects'][0]['tags'][1]['name'] == 'B'
assert 'time' in report['projects'][0]['tags'][1]
assert len(report['projects'][0]['messages']) == 0
assert len(report['projects'][0]['tags'][0]['messages']) == 0
assert len(report['projects'][0]['tags'][1]['messages']) == 0
assert len(report['projects'][0]['notes']) == 0
assert len(report['projects'][0]['tags'][0]['notes']) == 0
assert len(report['projects'][0]['tags'][1]['notes']) == 0

watson.start('bar', tags=['C'])
watson.stop(message='bar message')
watson.stop(note='bar note')

report = watson.report(arrow.now(), arrow.now())
assert len(report['projects']) == 2
Expand All @@ -837,12 +837,12 @@ def test_report(watson):
assert len(report['projects'][0]['tags']) == 1
assert report['projects'][0]['tags'][0]['name'] == 'C'

assert len(report['projects'][1]['messages']) == 0
assert len(report['projects'][1]['tags'][0]['messages']) == 0
assert len(report['projects'][1]['tags'][1]['messages']) == 0
assert len(report['projects'][0]['messages']) == 0
assert len(report['projects'][0]['tags'][0]['messages']) == 1
assert report['projects'][0]['tags'][0]['messages'][0] == 'bar message'
assert len(report['projects'][1]['notes']) == 0
assert len(report['projects'][1]['tags'][0]['notes']) == 0
assert len(report['projects'][1]['tags'][1]['notes']) == 0
assert len(report['projects'][0]['notes']) == 0
assert len(report['projects'][0]['tags'][0]['notes']) == 1
assert report['projects'][0]['tags'][0]['notes'][0] == 'bar note'

report = watson.report(
arrow.now(), arrow.now(), projects=['foo'], tags=['B']
Expand All @@ -853,36 +853,36 @@ def test_report(watson):
assert report['projects'][0]['tags'][0]['name'] == 'B'

watson.start('baz', tags=['D'])
watson.stop(message='baz message')
watson.stop(note='baz note')

watson.start('foo')
watson.stop(message='foo no tags')
watson.stop(note='foo no tags')

watson.start('foo', tags=['A'])
watson.stop(message='foo one tag A')
watson.stop(note='foo one tag A')

report = watson.report(arrow.now(), arrow.now(), projects=["foo"])

assert len(report['projects']) == 1
assert len(report['projects'][0]['messages']) == 1
# A project-level message because this frame has no tags
assert report['projects'][0]['messages'][0] == 'foo no tags'
assert len(report['projects'][0]['notes']) == 1
# A project-level note because this frame has no tags
assert report['projects'][0]['notes'][0] == 'foo no tags'
assert len(report['projects'][0]['tags']) == 2
assert report['projects'][0]['tags'][0]['name'] == 'A'
assert report['projects'][0]['tags'][1]['name'] == 'B'
assert len(report['projects'][0]['tags'][0]['messages']) == 1
assert len(report['projects'][0]['tags'][1]['messages']) == 0
# A tag-level message because this frame has tags
assert report['projects'][0]['tags'][0]['messages'][0] == 'foo one tag A'
assert len(report['projects'][0]['tags'][0]['notes']) == 1
assert len(report['projects'][0]['tags'][1]['notes']) == 0
# A tag-level note because this frame has tags
assert report['projects'][0]['tags'][0]['notes'][0] == 'foo one tag A'

report = watson.report(arrow.now(), arrow.now(), ignore_projects=["bar"])
assert len(report['projects']) == 2

report = watson.report(arrow.now(), arrow.now(), tags=["A"])
assert len(report['projects']) == 1
assert len(report['projects'][0]['messages']) == 0
assert len(report['projects'][0]['tags'][0]['messages']) == 1
assert report['projects'][0]['tags'][0]['messages'][0] == 'foo one tag A'
assert len(report['projects'][0]['notes']) == 0
assert len(report['projects'][0]['tags'][0]['notes']) == 1
assert report['projects'][0]['tags'][0]['notes'][0] == 'foo one tag A'

report = watson.report(arrow.now(), arrow.now(), ignore_tags=["D"])
assert len(report['projects']) == 2
Expand Down
Loading

0 comments on commit d80f4db

Please sign in to comment.