@@ -205,27 +205,60 @@ def test_single_publication(self) -> None:
205205 assert pubs [0 ].url is not None
206206 assert "pubmed" in pubs [0 ].url
207207
208- def test_publication_doi (self ) -> None :
208+ def test_publication_edoi (self ) -> None :
209+ """DbType が eDOI の場合、doi.org の URL を生成する。"""
209210 project = _make_project ()
210211 project ["Project" ]["ProjectDescr" ]["Publication" ] = {
211- "id" : "10.1234/test " ,
212- "DbType" : "DOI " ,
212+ "id" : "10.1271/bbb.60419 " ,
213+ "DbType" : "eDOI " ,
213214 }
214215 pubs = parse_publication (project )
215216 assert len (pubs ) == 1
216- assert pubs [0 ].url is not None
217- assert "doi.org" in pubs [0 ].url
217+ assert pubs [0 ].url == "https://doi.org/10.1271/bbb.60419"
218218
219- def test_publication_edoi (self ) -> None :
220- """DbType が eDOI の場合、doi.org の URL を生成する 。"""
219+ def test_publication_epmc_with_prefix (self ) -> None :
220+ """DbType が ePMC で PMC プレフィックス付き ID の場合 。"""
221221 project = _make_project ()
222222 project ["Project" ]["ProjectDescr" ]["Publication" ] = {
223- "id" : "10.1271/bbb.60419 " ,
224- "DbType" : "eDOI " ,
223+ "id" : "PMC3564981 " ,
224+ "DbType" : "ePMC " ,
225225 }
226226 pubs = parse_publication (project )
227227 assert len (pubs ) == 1
228- assert pubs [0 ].url == "https://doi.org/10.1271/bbb.60419"
228+ assert pubs [0 ].url == "https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3564981/"
229+
230+ def test_publication_epmc_numeric (self ) -> None :
231+ """DbType が ePMC で数字のみの ID の場合、PMC プレフィックスを付与する。"""
232+ project = _make_project ()
233+ project ["Project" ]["ProjectDescr" ]["Publication" ] = {
234+ "id" : "3594186" ,
235+ "DbType" : "ePMC" ,
236+ }
237+ pubs = parse_publication (project )
238+ assert len (pubs ) == 1
239+ assert pubs [0 ].url == "https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3594186/"
240+
241+ def test_publication_epmc_doi_format (self ) -> None :
242+ """DbType が ePMC だが ID が DOI 形式の場合、DOI としてリンクする。"""
243+ project = _make_project ()
244+ project ["Project" ]["ProjectDescr" ]["Publication" ] = {
245+ "id" : "10.1007/s10531-014-0684-8" ,
246+ "DbType" : "ePMC" ,
247+ }
248+ pubs = parse_publication (project )
249+ assert len (pubs ) == 1
250+ assert pubs [0 ].url == "https://doi.org/10.1007/s10531-014-0684-8"
251+
252+ def test_publication_not_available (self ) -> None :
253+ """DbType が eNotAvailable の場合、url は None。"""
254+ project = _make_project ()
255+ project ["Project" ]["ProjectDescr" ]["Publication" ] = {
256+ "id" : "unpublished" ,
257+ "DbType" : "eNotAvailable" ,
258+ }
259+ pubs = parse_publication (project )
260+ assert len (pubs ) == 1
261+ assert pubs [0 ].url is None
229262
230263 def test_publication_numeric_dbtype (self ) -> None :
231264 """DbType が数字の場合、ePubmed として扱う。"""
0 commit comments