diff --git a/scipost_django/commentaries/tests/test_views.py b/scipost_django/commentaries/tests/test_views.py index 0f095812d102d501e87eca845b97550a6f333986..8c6084a7606adae1c3611d7856e08e19fa3ae9b3 100644 --- a/scipost_django/commentaries/tests/test_views.py +++ b/scipost_django/commentaries/tests/test_views.py @@ -31,6 +31,7 @@ class PrefillUsingDOITest(TestCase): def test_submit_valid_physrev_doi(self): post_data = {"doi": self.physrev_doi} request = RequestFactory().post(self.target, post_data) + request.session = {} request.user = UserFactory() response = prefill_using_DOI(request) diff --git a/scipost_django/scipost/tests/test_services.py b/scipost_django/scipost/tests/test_services.py index 138dbf68f008466d246ea4822eaa2ab8821ae7c2..38259224c61905e0772295cb6eb089b8a335e4a3 100644 --- a/scipost_django/scipost/tests/test_services.py +++ b/scipost_django/scipost/tests/test_services.py @@ -8,10 +8,14 @@ from django.test import TestCase from ..services import ArxivCaller, DOICaller -from submissions.models import Submission +from submissions.factories import PreprintServerFactory class ArxivCallerTest(TestCase): + def setUp(self) -> None: + # Create the arXiv preprint server + PreprintServerFactory.arxiv() + def test_identifier_new_style(self): caller = ArxivCaller("1612.07611v1") self.assertTrue(caller.is_valid) @@ -21,8 +25,10 @@ class ArxivCallerTest(TestCase): "abstract": "The Berezinskii-Kosterlitz-Thouless (BKT) transitions of the six-state clock\nmodel on the square lattice are investigated by means of the corner-transfer\nmatrix renormalization group method. The classical analogue of the entanglement\nentropy $S( L, T )$ is calculated for $L$ by $L$ square system up to $L = 129$,\nas a function of temperature $T$. The entropy has a peak at $T = T^{*}_{~}( L\n)$, where the temperature depends on both $L$ and boundary conditions. Applying\nthe finite-size scaling to $T^{*}_{~}( L )$ and assuming the presence of BKT\ntransitions, the transition temperature is estimated to be $T_1^{~} = 0.70$ and\n$T_2^{~} = 0.88$. The obtained results agree with previous analyses. It should\nbe noted that no thermodynamic function is used in this study.", "pub_abstract": "The Berezinskii-Kosterlitz-Thouless (BKT) transitions of the six-state clock\nmodel on the square lattice are investigated by means of the corner-transfer\nmatrix renormalization group method. The classical analogue of the entanglement\nentropy $S( L, T )$ is calculated for $L$ by $L$ square system up to $L = 129$,\nas a function of temperature $T$. The entropy has a peak at $T = T^{*}_{~}( L\n)$, where the temperature depends on both $L$ and boundary conditions. Applying\nthe finite-size scaling to $T^{*}_{~}( L )$ and assuming the presence of BKT\ntransitions, the transition temperature is estimated to be $T_1^{~} = 0.70$ and\n$T_2^{~} = 0.88$. The obtained results agree with previous analyses. It should\nbe noted that no thermodynamic function is used in this study.", "title": "Phase transition of the six-state clock model observed from the\n entanglement entropy", + "preprint_link": "https://arxiv.org/abs/1612.07611v1", "pub_date": datetime.date(2016, 12, 22), } + del caller.data["preprint_server"] # Remove server key before comparison self.assertDictEqual(caller.data, correct_data) def test_identifier_old_style(self): @@ -35,7 +41,9 @@ class ArxivCallerTest(TestCase): "abstract": "A kind of least action principle is introduced for the discrete time\nevolution of one-dimensional quantum lattice models. Based on this principle,\nwe obtain an optimal condition for the matrix product states on succeeding time\nslices generated by the real-time density matrix renormalization group method.\nThis optimization can also be applied to classical simulations of quantum\ncircuits. We discuss the time reversal symmetry in the fully optimized MPS.", "pub_abstract": "A kind of least action principle is introduced for the discrete time\nevolution of one-dimensional quantum lattice models. Based on this principle,\nwe obtain an optimal condition for the matrix product states on succeeding time\nslices generated by the real-time density matrix renormalization group method.\nThis optimization can also be applied to classical simulations of quantum\ncircuits. We discuss the time reversal symmetry in the fully optimized MPS.", "title": "Least Action Principle for the Real-Time Density Matrix Renormalization\n Group", + "preprint_link": "https://arxiv.org/abs/cond-mat/0612480v2", } + del caller.data["preprint_server"] # Remove server key before comparison self.assertDictEqual(caller.data, correct_data) def valid_but_nonexistent_identifier(self): @@ -46,6 +54,7 @@ class ArxivCallerTest(TestCase): class DOICallerTest(TestCase): def test_works_for_physrev_doi(self): caller = DOICaller("10.1103/PhysRevB.92.214427") + correct_data = { "title": "Quasi-soliton scattering in quantum spin chains", "pages": "214427", @@ -53,7 +62,11 @@ class DOICallerTest(TestCase): "pub_date": "2015-12-18", "volume": "92", "journal": "Physical Review B", + "abstract": "", # Doesn't seem to be available for this DOI } + # Remove crossref_data from caller.data for comparison + del caller.data["crossref_data"] + self.assertTrue(caller.is_valid) self.assertDictEqual(caller.data, correct_data) @@ -66,8 +79,18 @@ class DOICallerTest(TestCase): "title": "One-particle density matrix of trapped one-dimensional impenetrable bosons from conformal invariance", "pages": "012", "journal": "SciPost Physics", + "abstract": "<jats:p>The one-particle density matrix of the one-dimensional\n" + "Tonks-Girardeau gas with inhomogeneous density profile is calculated,\n" + "thanks to a recent observation that relates this system to a\n" + "two-dimensional conformal field theory in curved space. The result is\n" + "asymptotically exact in the limit of large particle density and small\n" + "density variation, and holds for arbitrary trapping potentials. In the\n" + "particular case of a harmonic trap, we recover a formula obtained by\n" + "Forrester et al. from a different method.</jats:p>", } self.assertTrue(caller.is_valid) + # Remove crossref_data from caller.data for comparison + del caller.data["crossref_data"] self.assertDictEqual(caller.data, correct_data) def test_valid_but_non_existent_doi(self):