Skip to content

Commit

Permalink
Merge branch 'master' into all-projects
Browse files Browse the repository at this point in the history
  • Loading branch information
icemac authored Dec 11, 2023
2 parents c4ee386 + 08c1c83 commit e321079
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 21 deletions.
8 changes: 2 additions & 6 deletions gtimelog2tick.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,14 @@ def read_config(config_file: pathlib.Path) -> dict:
f"Section [gtimelog2tick] is not present in {config_file} config"
" file.")

if not config.has_section('gtimelog'):
raise ConfigurationError(
f"Section [gtimelog] is not present in {config_file} config file.")

subscription_id = config['gtimelog2tick'].get('subscription_id')
token = config['gtimelog2tick'].get('token')
user_id = config['gtimelog2tick'].get('user_id')
email = config['gtimelog2tick'].get('email')
timelog = config['gtimelog2tick'].get('timelog')
ticklog = config['gtimelog2tick'].get('ticklog')
requested_projects = config['gtimelog2tick'].get('projects', '')
midnight = config['gtimelog'].get('virtual_midnight', '06:00')
requested_projects = config.get('gtimelog2tick', 'projects', fallback='')
midnight = config.get('gtimelog', 'virtual_midnight', fallback='06:00')

if not subscription_id:
raise ConfigurationError(
Expand Down
15 changes: 0 additions & 15 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -712,20 +712,10 @@ def test_gtimelog2tick__read_config__2(tmpdir):
assert err.match(r'Section \[gtimelog2tick\] is not present')


def test_gtimelog2tick__read_config__3(tmpdir):
"""It renders an exception if the section gtimelog does not exist."""
path = pathlib.Path(tmpdir) / 'config.ini'
path.write_text('[gtimelog2tick]')
with pytest.raises(gtimelog2tick.ConfigurationError) as err:
gtimelog2tick.read_config(path)
assert err.match(r'Section \[gtimelog\] is not present')


def test_gtimelog2tick__read_config__4(tmpdir):
"""It renders an exception if subscription_id is missing."""
path = pathlib.Path(tmpdir) / 'config.ini'
path.write_text(textwrap.dedent("""\
[gtimelog]
[gtimelog2tick]"""))
with pytest.raises(gtimelog2tick.ConfigurationError) as err:
gtimelog2tick.read_config(path)
Expand All @@ -737,7 +727,6 @@ def test_gtimelog2tick__read_config__5(tmpdir):
"""It renders an exception if token is missing."""
path = pathlib.Path(tmpdir) / 'config.ini'
path.write_text(textwrap.dedent("""\
[gtimelog]
[gtimelog2tick]
subscription_id = 123"""))
with pytest.raises(gtimelog2tick.ConfigurationError) as err:
Expand All @@ -750,7 +739,6 @@ def test_gtimelog2tick__read_config__6(tmpdir):
"""It renders an exception if user_id is missing."""
path = pathlib.Path(tmpdir) / 'config.ini'
path.write_text(textwrap.dedent("""\
[gtimelog]
[gtimelog2tick]
subscription_id = 123
token = <TOKEN>"""))
Expand All @@ -764,7 +752,6 @@ def test_gtimelog2tick__read_config__7(tmpdir):
"""It renders an exception if email is missing."""
path = pathlib.Path(tmpdir) / 'config.ini'
path.write_text(textwrap.dedent("""\
[gtimelog]
[gtimelog2tick]
subscription_id = 123
token = <TOKEN>
Expand All @@ -779,7 +766,6 @@ def test_gtimelog2tick__read_config__9(tmpdir):
"""It renders an exception if timelog file does not exist."""
path = pathlib.Path(tmpdir) / 'config.ini'
path.write_text(textwrap.dedent("""\
[gtimelog]
[gtimelog2tick]
subscription_id = 123
token = <TOKEN>
Expand All @@ -794,7 +780,6 @@ def test_gtimelog2tick__read_config__10(tmpdir):
"""It renders an exception if ticklog file ist nor writeable."""
path = pathlib.Path(tmpdir) / 'config.ini'
path.write_text(textwrap.dedent("""\
[gtimelog]
[gtimelog2tick]
subscription_id = 123
token = <TOKEN>
Expand Down

0 comments on commit e321079

Please sign in to comment.