Skip to content

Commit 16299fc

Browse files
committed
add apalike tests for type
1 parent 641da96 commit 16299fc

11 files changed

Lines changed: 287 additions & 0 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The name. The title [Data set].
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import os
2+
from functools import lru_cache
3+
4+
import pytest
5+
from cffconvert import Citation
6+
from cffconvert.lib.cff_1_2_x.apalike import ApalikeObject
7+
8+
from tests.lib.contracts.apalike import Contract
9+
10+
11+
@lru_cache
12+
def apalike_object():
13+
fixture = os.path.join(os.path.dirname(__file__), "CITATION.cff")
14+
with open(fixture, "rt", encoding="utf-8") as f:
15+
cffstr = f.read()
16+
citation = Citation(cffstr)
17+
return ApalikeObject(citation.cffobj, initialize_empty=True)
18+
19+
20+
@pytest.mark.lib
21+
@pytest.mark.apalike
22+
class TestApalikeObject(Contract):
23+
24+
def test_as_string(self):
25+
actual_apalike = apalike_object().add_all().as_string()
26+
fixture = os.path.join(os.path.dirname(__file__), "apalike.txt")
27+
with open(fixture, "rt", encoding="utf-8") as f:
28+
expected_apalike = f.read()
29+
assert actual_apalike == expected_apalike
30+
31+
def test_author(self):
32+
assert apalike_object().add_author().author == "The name."
33+
34+
def test_check_cffobj(self):
35+
apalike_object().check_cffobj()
36+
# doesn't need an assert
37+
38+
def test_doi(self):
39+
assert apalike_object().add_doi().doi is None
40+
41+
def test_title(self):
42+
assert apalike_object().add_title().title == "The title [Data set]."
43+
44+
def test_url(self):
45+
assert apalike_object().add_url().url is None
46+
47+
def test_year(self):
48+
assert apalike_object().add_year().year is None
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The name. The title.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import os
2+
from functools import lru_cache
3+
4+
import pytest
5+
from cffconvert import Citation
6+
from cffconvert.lib.cff_1_2_x.apalike import ApalikeObject
7+
8+
from tests.lib.contracts.apalike import Contract
9+
10+
11+
@lru_cache
12+
def apalike_object():
13+
fixture = os.path.join(os.path.dirname(__file__), "CITATION.cff")
14+
with open(fixture, "rt", encoding="utf-8") as f:
15+
cffstr = f.read()
16+
citation = Citation(cffstr)
17+
return ApalikeObject(citation.cffobj, initialize_empty=True)
18+
19+
20+
@pytest.mark.lib
21+
@pytest.mark.apalike
22+
class TestApalikeObject(Contract):
23+
24+
def test_as_string(self):
25+
actual_apalike = apalike_object().add_all().as_string()
26+
fixture = os.path.join(os.path.dirname(__file__), "apalike.txt")
27+
with open(fixture, "rt", encoding="utf-8") as f:
28+
expected_apalike = f.read()
29+
assert actual_apalike == expected_apalike
30+
31+
def test_author(self):
32+
assert apalike_object().add_author().author == "The name."
33+
34+
def test_check_cffobj(self):
35+
apalike_object().check_cffobj()
36+
# doesn't need an assert
37+
38+
def test_doi(self):
39+
assert apalike_object().add_doi().doi is None
40+
41+
def test_title(self):
42+
assert apalike_object().add_title().title == "The title."
43+
44+
def test_url(self):
45+
assert apalike_object().add_url().url is None
46+
47+
def test_year(self):
48+
assert apalike_object().add_year().year is None
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The name. The title [Computer software].
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import os
2+
from functools import lru_cache
3+
4+
import pytest
5+
from cffconvert import Citation
6+
from cffconvert.lib.cff_1_2_x.apalike import ApalikeObject
7+
8+
from tests.lib.contracts.apalike import Contract
9+
10+
11+
@lru_cache
12+
def apalike_object():
13+
fixture = os.path.join(os.path.dirname(__file__), "CITATION.cff")
14+
with open(fixture, "rt", encoding="utf-8") as f:
15+
cffstr = f.read()
16+
citation = Citation(cffstr)
17+
return ApalikeObject(citation.cffobj, initialize_empty=True)
18+
19+
20+
@pytest.mark.lib
21+
@pytest.mark.apalike
22+
class TestApalikeObject(Contract):
23+
24+
def test_as_string(self):
25+
actual_apalike = apalike_object().add_all().as_string()
26+
fixture = os.path.join(os.path.dirname(__file__), "apalike.txt")
27+
with open(fixture, "rt", encoding="utf-8") as f:
28+
expected_apalike = f.read()
29+
assert actual_apalike == expected_apalike
30+
31+
def test_author(self):
32+
assert apalike_object().add_author().author == "The name."
33+
34+
def test_check_cffobj(self):
35+
apalike_object().check_cffobj()
36+
# doesn't need an assert
37+
38+
def test_doi(self):
39+
assert apalike_object().add_doi().doi is None
40+
41+
def test_title(self):
42+
assert apalike_object().add_title().title == "The title [Computer software]."
43+
44+
def test_url(self):
45+
assert apalike_object().add_url().url is None
46+
47+
def test_year(self):
48+
assert apalike_object().add_year().year is None
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import os
2+
from functools import lru_cache
3+
import pytest
4+
from cffconvert import Citation
5+
from cffconvert.lib.cff_1_3_x.apalike import ApalikeObject
6+
from tests.lib.contracts.apalike import Contract
7+
8+
9+
@lru_cache
10+
def apalike_object():
11+
fixture = os.path.join(os.path.dirname(__file__), "CITATION.cff")
12+
with open(fixture, "rt", encoding="utf-8") as f:
13+
cffstr = f.read()
14+
citation = Citation(cffstr)
15+
return ApalikeObject(citation.cffobj, initialize_empty=True)
16+
17+
18+
@pytest.mark.lib
19+
@pytest.mark.apalike
20+
class TestApalikeObject(Contract):
21+
22+
def test_as_string(self):
23+
actual_apalike = apalike_object().add_all().as_string()
24+
fixture = os.path.join(os.path.dirname(__file__), "apalike.txt")
25+
with open(fixture, "rt", encoding="utf-8") as f:
26+
expected_apalike = f.read()
27+
assert actual_apalike == expected_apalike
28+
29+
def test_author(self):
30+
assert apalike_object().add_author().author == "The name."
31+
32+
def test_doi(self):
33+
assert apalike_object().add_doi().doi is None
34+
35+
def test_check_cffobj(self):
36+
apalike_object().check_cffobj()
37+
# doesn't need an assert
38+
39+
def test_title(self):
40+
assert apalike_object().add_title().title == "The title [Data set]."
41+
42+
def test_url(self):
43+
assert apalike_object().add_url().url is None
44+
45+
def test_year(self):
46+
assert apalike_object().add_year().year is None
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The name. The title.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import os
2+
from functools import lru_cache
3+
import pytest
4+
from cffconvert import Citation
5+
from cffconvert.lib.cff_1_3_x.apalike import ApalikeObject
6+
from tests.lib.contracts.apalike import Contract
7+
8+
9+
@lru_cache
10+
def apalike_object():
11+
fixture = os.path.join(os.path.dirname(__file__), "CITATION.cff")
12+
with open(fixture, "rt", encoding="utf-8") as f:
13+
cffstr = f.read()
14+
citation = Citation(cffstr)
15+
return ApalikeObject(citation.cffobj, initialize_empty=True)
16+
17+
18+
@pytest.mark.lib
19+
@pytest.mark.apalike
20+
class TestApalikeObject(Contract):
21+
22+
def test_as_string(self):
23+
actual_apalike = apalike_object().add_all().as_string()
24+
fixture = os.path.join(os.path.dirname(__file__), "apalike.txt")
25+
with open(fixture, "rt", encoding="utf-8") as f:
26+
expected_apalike = f.read()
27+
assert actual_apalike == expected_apalike
28+
29+
def test_author(self):
30+
assert apalike_object().add_author().author == "The name."
31+
32+
def test_check_cffobj(self):
33+
apalike_object().check_cffobj()
34+
# doesn't need an assert
35+
36+
def test_doi(self):
37+
assert apalike_object().add_doi().doi is None
38+
39+
def test_title(self):
40+
assert apalike_object().add_title().title == "The title."
41+
42+
def test_url(self):
43+
assert apalike_object().add_url().url is None
44+
45+
def test_year(self):
46+
assert apalike_object().add_year().year is None
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The name. The title [Computer software].

0 commit comments

Comments
 (0)