summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorOlivier Gayot <olivier.gayot@sigexec.com>2021-12-26 17:11:37 +0100
committerOlivier Gayot <olivier.gayot@sigexec.com>2021-12-26 18:28:21 +0100
commitd592880c4bc4c581d8847d96ff73bc319ca1fac2 (patch)
treeac4996aa4d81ef55e68b209d4c541c206f1efe61 /tests
parent794292740c30bfea48dc23eb62fb6aa531bfdca7 (diff)
Make cards be part of the Python package data
We now load the cards using pkg_resources. This is way better in many aspects: * we can install the package using pip without having issues loading cards * we don't need to chdir to / before running swiftstoryd * we don't need to rely on data_files which is deprecated. Signed-off-by: Olivier Gayot <olivier.gayot@sigexec.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/test_cards.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/tests/test_cards.py b/tests/test_cards.py
index 73f42a0..605984b 100644
--- a/tests/test_cards.py
+++ b/tests/test_cards.py
@@ -13,13 +13,13 @@ class TestCards(unittest.TestCase):
])
black_cards = json.dumps(["Black Card 1", "Black Card 2"])
- with patch("swiftstory.cards.open", mock_open(read_data=white_cards)):
+ with patch("swiftstory.cards.pkg_resources.resource_stream", mock_open(read_data=white_cards)):
self.assertIn("White Card 2", Cards.get_white_cards("en"))
- with patch("swiftstory.cards.open", mock_open(read_data=black_cards)):
+ with patch("swiftstory.cards.pkg_resources.resource_stream", mock_open(read_data=black_cards)):
self.assertIn("Black Card 1", Cards.get_black_cards("en"))
def test_get_cards_unknown_language(self):
- with patch("swiftstory.cards.open", side_effect=FileNotFoundError):
+ with patch("swiftstory.cards.pkg_resources.resource_stream", side_effect=FileNotFoundError):
with self.assertRaises(FileNotFoundError):
Cards.get_white_cards("zz")
with self.assertRaises(FileNotFoundError):