-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
If the config option
projects
is empty, do not omit any entries. (#8)
- Loading branch information
Showing
4 changed files
with
45 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,8 @@ | |
import gtimelog2tick | ||
|
||
|
||
def test_parse_timelog(): | ||
def test_gtimelog2tick__parse_timelog__1(): | ||
"""It omits entries which do not match the requested projects.""" | ||
entries = [ | ||
gtimelog2tick.Entry(datetime.datetime(2014, 3, 31, 14, 48), | ||
datetime.datetime(2014, 3, 31, 17, 10), | ||
|
@@ -46,6 +47,33 @@ def test_parse_timelog(): | |
] | ||
|
||
|
||
def test_gtimelog2tick__parse_timelog__2(): | ||
"""It omits no entries if requested projects is empty.""" | ||
entries = [ | ||
gtimelog2tick.Entry(datetime.datetime(2014, 3, 31, 14, 48), | ||
datetime.datetime(2014, 3, 31, 17, 10), | ||
'proj2: maint: work'), | ||
gtimelog2tick.Entry(datetime.datetime(2014, 3, 31, 17, 48), | ||
datetime.datetime(2014, 3, 31, 18, 10), | ||
'proj3: dev: other'), | ||
] | ||
config = { | ||
'requested_projects': [], | ||
'tick_projects': [ | ||
gtimelog2tick.Project('proj2', 42, [ | ||
gtimelog2tick.Task('maintenance', 1), | ||
]), | ||
gtimelog2tick.Project('proj3', 43, [ | ||
gtimelog2tick.Task('development', 5), | ||
]) | ||
] | ||
} | ||
assert list(gtimelog2tick.parse_timelog(config, entries)) == [ | ||
gtimelog2tick.WorkLog(entries[0], 'work', 'proj2: maintenance', 1), | ||
gtimelog2tick.WorkLog(entries[-1], 'other', 'proj3: development', 5), | ||
] | ||
|
||
|
||
class Route: | ||
|
||
def __init__(self, handler, params=None): | ||
|
@@ -413,7 +441,7 @@ def test_no_args(env, mocker): | |
] | ||
|
||
|
||
def test_gtimelog2tick__parse_timelog__1(env, mocker): | ||
def test_gtimelog2tick__parse_timelog__3(env, mocker): | ||
"""It raises a DataError for an entry with negative time.""" | ||
mocker.patch('gtimelog2tick.get_now', | ||
return_value=datetime.datetime(2023, 12, 7).astimezone()) | ||
|
@@ -430,7 +458,7 @@ def test_gtimelog2tick__parse_timelog__1(env, mocker): | |
err.match(r'Negative hours: WorkLog\(.*') | ||
|
||
|
||
def test_gtimelog2tick__parse_timelog__2(env, mocker): | ||
def test_gtimelog2tick__parse_timelog__4(env, mocker): | ||
"""It it ignores entries with zero minutes duration.""" | ||
mocker.patch('gtimelog2tick.get_now', | ||
return_value=datetime.datetime(2023, 12, 7).astimezone()) | ||
|
@@ -734,22 +762,6 @@ def test_gtimelog2tick__read_config__7(tmpdir): | |
' gtimelog2tick.email setting.') | ||
|
||
|
||
def test_gtimelog2tick__read_config__8(tmpdir): | ||
"""It renders an exception if projects is missing.""" | ||
path = pathlib.Path(tmpdir) / 'config.ini' | ||
path.write_text(textwrap.dedent("""\ | ||
[gtimelog] | ||
[gtimelog2tick] | ||
subscription_id = 123 | ||
token = <TOKEN> | ||
user_id = 456 | ||
email = [email protected]""")) | ||
with pytest.raises(gtimelog2tick.ConfigurationError) as err: | ||
gtimelog2tick.read_config(path) | ||
assert err.match('The list of projects is not specified, set them via the' | ||
' gtimelog2tick.projects setting.') | ||
|
||
|
||
def test_gtimelog2tick__read_config__9(tmpdir): | ||
"""It renders an exception if timelog file does not exist.""" | ||
path = pathlib.Path(tmpdir) / 'config.ini' | ||
|
@@ -758,8 +770,7 @@ def test_gtimelog2tick__read_config__9(tmpdir): | |
subscription_id = 123 | ||
token = <TOKEN> | ||
user_id = 456 | ||
email = [email protected] | ||
projects = FOO BAR""")) | ||
email = [email protected]""")) | ||
with pytest.raises(gtimelog2tick.ConfigurationError) as err: | ||
gtimelog2tick.read_config(path) | ||
assert err.match('Timelog file .*/timelog.txt does not exist.') | ||
|
@@ -773,8 +784,7 @@ def test_gtimelog2tick__read_config__10(tmpdir): | |
subscription_id = 123 | ||
token = <TOKEN> | ||
user_id = 456 | ||
email = [email protected] | ||
projects = FOO BAR""")) | ||
email = [email protected]""")) | ||
(pathlib.Path(tmpdir) / 'timelog.txt').touch() | ||
ticklog = pathlib.Path(tmpdir) / 'ticklog.txt' | ||
ticklog.touch() | ||
|