summaryrefslogtreecommitdiffstats
path: root/src/parser_unittest.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/parser_unittest.py')
-rw-r--r--src/parser_unittest.py72
1 files changed, 0 insertions, 72 deletions
diff --git a/src/parser_unittest.py b/src/parser_unittest.py
deleted file mode 100644
index 8d0d600..0000000
--- a/src/parser_unittest.py
+++ /dev/null
@@ -1,72 +0,0 @@
-import pytest
-import parser
-from pathlib import Path
-
-# Happy path
-def test_validFile(tmp_path):
- file_contents = """
-
-FRONT
-
-
-Foo
-
-Bar
-
-BACK
-
-
-Fizz
-
-Buzz
-
-
-
-FRONT
-
-Another card
-
-BACK
-
-Another back
-
-
- """
- expected = {
- ("Foo\n\nBar", "Fizz\n\nBuzz"),
- ("Another card", "Another back")
- }
-
- path = tmp_path / "valid_file.fcard"
- with open(path, "w") as f:
- f.write(file_contents)
-
- cards = parser.parseFile(path)
-
- assert expected == set(cards.values())
-
-# Edge cases
-def test_emptyFile(tmp_path):
- path = tmp_path / "empty.fcard"
- with open(path, "w") as f:
- f.write("")
-
- cards = parser.parseFile(path)
- assert cards == {}
-
-def checkException(tmp_path, file_contents):
- path = tmp_path / "invalid_file.fcard"
- with open(path, "w") as f:
- f.write(file_contents)
-
- with pytest.raises(Exception):
- cards = parser.parseFile(path)
-
-def test_doesNotStartWithFront(tmp_path):
- checkException(tmp_path, "BACK\noops")
-
-def test_frontTwiceInARow(tmp_path):
- checkException(tmp_path, "FRONT\noops\nFRONT\nbad")
-
-def test_doesNotEndWithBack(tmp_path):
- checkException(tmp_path, "FRONT\ntest\nBACK\ntest\nFRONT\noops")