-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_defaults.py
More file actions
32 lines (21 loc) · 884 Bytes
/
test_defaults.py
File metadata and controls
32 lines (21 loc) · 884 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import json
import pytest
from gitmojis import defaults
from gitmojis.model import Gitmoji
def test_gitmoji_api_path_file_is_json_decodable():
try:
with defaults.GITMOJI_API_PATH.open(encoding="UTF-8") as f:
json.load(f)
except json.JSONDecodeError:
pytest.fail()
def test_gitmoji_api_path_file_data_is_list_of_dicts():
with defaults.GITMOJI_API_PATH.open(encoding="UTF-8") as f:
gitmojis_json = json.load(f)
assert isinstance(gitmojis_json, list)
assert all(isinstance(gitmoji_json, dict) for gitmoji_json in gitmojis_json)
def test_gitmoji_api_path_file_data_can_create_gitmoji_objects():
with defaults.GITMOJI_API_PATH.open(encoding="UTF-8") as f:
gitmojis_json = json.load(f)
for gitmoji_json in gitmojis_json:
gitmoji = Gitmoji(**gitmoji_json)
assert isinstance(gitmoji, Gitmoji)