-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_gitmoji.py
More file actions
36 lines (26 loc) · 834 Bytes
/
test_gitmoji.py
File metadata and controls
36 lines (26 loc) · 834 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
33
34
35
36
from dataclasses import FrozenInstanceError, fields
import pytest
from gitmojis.model import Gitmoji
@pytest.fixture
def gitmoji_json():
return {
"emoji": "🐛",
"entity": "🐛",
"code": ":bug:",
"description": "Fix a bug.",
"name": "bug",
"semver": "patch",
}
@pytest.fixture
def gitmoji(gitmoji_json):
return Gitmoji(**gitmoji_json)
def test_gitmoji_init_populates_fields_from_kwargs(gitmoji_json, gitmoji):
for key, value in gitmoji_json.items():
assert getattr(gitmoji, key) == value
@pytest.mark.parametrize(
"field_name",
[field.name for field in fields(Gitmoji)],
)
def test_gitmoji_is_immutable(gitmoji, field_name):
with pytest.raises(FrozenInstanceError):
setattr(gitmoji, field_name, getattr(gitmoji, field_name))