-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix a discovered bug too.
- Loading branch information
Showing
3 changed files
with
67 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import os | ||
import sys | ||
|
||
import pytest | ||
|
||
from yaml2ics import event_from_yaml, main | ||
|
||
basedir = os.path.abspath(os.path.join(os.path.dirname(__file__))) | ||
example_calendar = os.path.join(basedir, "../example/test_calendar.yaml") | ||
|
||
|
||
def test_cli(monkeypatch): | ||
with monkeypatch.context() as m: | ||
m.setattr(sys, "argv", ["yaml2ics.py", example_calendar]) | ||
main() | ||
|
||
with monkeypatch.context() as m: | ||
m.setattr(sys, "argv", ["yaml2ics.py"]) | ||
|
||
with pytest.raises(RuntimeError) as e: | ||
main() | ||
assert "Usage:" in str(e) | ||
|
||
with monkeypatch.context() as m: | ||
m.setattr(sys, "argv", ["yaml2ics.py", "syzygy.yaml"]) | ||
|
||
with pytest.raises(RuntimeError) as e: | ||
main() | ||
assert "is not a file" in str(e) | ||
|
||
|
||
def test_errors(): | ||
with pytest.raises(RuntimeError) as e: | ||
event_from_yaml({"repeat": {"interval": {}}}) | ||
assert "interval must specify" in str(e) | ||
|
||
with pytest.raises(RuntimeError) as e: | ||
event_from_yaml({"ics": "123"}) | ||
assert "Invalid custom ICS" in str(e) | ||
|
||
with pytest.raises(RuntimeError) as e: | ||
event_from_yaml({"repeat": {"interval": {"weeks": 1}}}) | ||
assert "must specify end date for repeating events" in str(e) | ||
|
||
with pytest.raises(RuntimeError) as e: | ||
event_from_yaml({"repeat": {"interval": {"epochs": 4}}}) | ||
assert "expected interval to be specified in seconds, minutes" in str(e) |
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