Skip to content

Commit 0d406d1

Browse files
committed
Add tests for None cases in Scientific extension
1 parent 2bf268c commit 0d406d1

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

tests/extensions/test_scientific.py

+29-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
"""Tests for pystac.tests.extensions.scientific."""
22

33
import datetime
4+
from pystac.link import Link
45
from pystac.collection import Summaries
56
import unittest
67
from typing import List, Optional
78

89
import pystac
910
from pystac.extensions import scientific
10-
from pystac.extensions.scientific import ScientificExtension, ScientificRelType
11+
from pystac.extensions.scientific import (
12+
Publication,
13+
ScientificExtension,
14+
ScientificRelType,
15+
remove_link,
16+
)
1117

1218
URL_TEMPLATE = "http://example.com/catalog/%s.json"
1319

@@ -41,6 +47,28 @@ def make_item() -> pystac.Item:
4147
return item
4248

4349

50+
class TestRemoveLinks(unittest.TestCase):
51+
def test_remove_none_doi(self) -> None:
52+
"""Calling remove_link with doi = None should have no effect."""
53+
link = Link(
54+
rel=ScientificRelType.CITE_AS,
55+
target="https://some-domain.com/some/paper.pdf",
56+
)
57+
links = [link]
58+
59+
remove_link(links, doi=None)
60+
61+
self.assertEqual(len(links), 1)
62+
self.assertIn(link, links)
63+
64+
65+
class TestPublication(unittest.TestCase):
66+
def test_get_link_returns_none_if_no_doi(self) -> None:
67+
pub = Publication(None, CITATION)
68+
69+
self.assertIsNone(pub.get_link())
70+
71+
4472
class ItemScientificExtensionTest(unittest.TestCase):
4573
def setUp(self) -> None:
4674
super().setUp()

0 commit comments

Comments
 (0)