Skip to content

Commit cc71fc2

Browse files
committed
chore: simplify methods tests
1 parent 4ec2f16 commit cc71fc2

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

tests/test_cmi_methods.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,40 @@
11
import pytest
22

3-
import csv2cmi
3+
from csv2cmi import CMI
44

55

66
def test_create_date_valid():
7-
assert csv2cmi.CMI.create_date("2016-04-01").attrib["when"] == "2016-04-01"
8-
assert csv2cmi.CMI.create_date("1673-05").attrib["when"] == "1673-05"
9-
assert csv2cmi.CMI.create_date("[..1760-12-03]").attrib["notAfter"] == "1760-12-03"
10-
assert csv2cmi.CMI.create_date("[1760-12..]").attrib["notBefore"] == "1760-12"
11-
assert csv2cmi.CMI.create_date("1979-10-12/").attrib["from"] == "1979-10-12"
12-
assert csv2cmi.CMI.create_date("/1985-04-12").attrib["to"] == "1985-04-12"
13-
assert csv2cmi.CMI.create_date("{-0400,-0390,-0370}") is not None
7+
assert CMI.create_date("2016-04-01").attrib["when"] == "2016-04-01"
8+
assert CMI.create_date("1673-05").attrib["when"] == "1673-05"
9+
assert CMI.create_date("[..1760-12-03]").attrib["notAfter"] == "1760-12-03"
10+
assert CMI.create_date("[1760-12..]").attrib["notBefore"] == "1760-12"
11+
assert CMI.create_date("1979-10-12/").attrib["from"] == "1979-10-12"
12+
assert CMI.create_date("/1985-04-12").attrib["to"] == "1985-04-12"
13+
assert CMI.create_date("{-0400,-0390,-0370}") is not None
1414

1515

1616
def test_create_date_invalid():
1717
with pytest.raises(ValueError):
18-
csv2cmi.CMI.create_date("not-a-date")
18+
CMI.create_date("not-a-date")
1919

2020

2121
def test_create_place_name():
22-
tei_placename = csv2cmi.CMI.create_place_name("Berlin")
22+
tei_placename = CMI.create_place_name("Berlin")
2323
assert tei_placename.tag == "placeName"
2424
assert tei_placename.text == "Berlin"
2525

2626

2727
def test_create_place_name_with_uri():
28-
tei_placename = csv2cmi.CMI.create_place_name("Mokhdān", "https://www.geonames.org/123456")
28+
tei_placename = CMI.create_place_name("Mokhdān", "https://www.geonames.org/123456")
2929
assert tei_placename.tag == "placeName"
3030
assert tei_placename.attrib["ref"] == "https://www.geonames.org/123456"
3131
assert tei_placename.text == "Mokhdān"
3232

3333

3434
def test_generate_id_and_uuid():
35-
id1 = csv2cmi.CMI.generate_id("test")
36-
id2 = csv2cmi.CMI.generate_id("test")
35+
id1 = CMI.generate_id("test")
36+
id2 = CMI.generate_id("test")
3737
assert id1 != id2
38-
cmi = csv2cmi.CMI()
39-
uuid1 = cmi.generate_uuid()
40-
uuid2 = cmi.generate_uuid()
38+
uuid1 = CMI.generate_uuid()
39+
uuid2 = CMI.generate_uuid()
4140
assert uuid1 != uuid2

0 commit comments

Comments
 (0)