def test_getCollectionList(self): """ Tests if all collections exist """ dao = PaperDAO() allcollectionlist = dao.getCollectionList() self.assertEquals(1, len(list(allcollectionlist)))
def test_getPublicationList(self): """ Tests for publications """ dao = PaperDAO() allpublicationlist = dao.getPublicationList() self.assertEquals(1, len(list(allpublicationlist)))
def test_getFilteredPaperObjectsForTitle(self): """ Tests for all search Objects with name """ dao = PaperDAO() allSearchObjects = dao.getAllFilteredSearchObjects(paperTitle='photo') self.assertEquals(1, len(list(allSearchObjects)))
def test_getAllFilteredSearchObjects(self): """ Tests for all search Objects """ dao = PaperDAO() allSearchObjects = dao.getAllFilteredSearchObjects() self.assertEquals(1, len(list(allSearchObjects)))
def test_getFilteredPaperObjectsForTags(self): """ Tests for all search Objects with tags """ dao = PaperDAO() allSearchObjects = dao.getAllFilteredSearchObjects(tags=['DFT']) self.assertEquals(1, len(list(allSearchObjects)))
def test_getAllPapers(self): """ Tests for all papers """ dao = PaperDAO() allpapers = dao.getAllPapers() self.assertTrue(list(allpapers))
def test_getFilteredPaperObjectsForAuthors(self): """ Tests for all search Objects with authors """ dao = PaperDAO() allSearchObjects = dao.getAllFilteredSearchObjects(authorsList=[]) self.assertEquals(1, len(list(allSearchObjects)))
def test_getFilteredPaperObjectsForTags(self): """ Tests for all search Objects with name """ dao = PaperDAO() allSearchObjects = dao.getAllFilteredSearchObjects(tags=['photo']) self.assertTrue(list(allSearchObjects))
def test_getAllPapers(self): """ Tests for all papers """ dao = PaperDAO() allpapers = dao.getAllPapers() self.assertEquals(1, len(list(allpapers)))
def test_insertDOI(self): """ Tests for insertion of DOI """ dao = PaperDAO() allSearchObjects = dao.getAllFilteredSearchObjects(tags=['DFT']) paper = dao.insertDOI(allSearchObjects[0]['_Search__id'], '123') self.assertEquals(1, paper)
def test_getFilteredPaperObjectsForDOI(self): """ Tests for all search Objects with doi """ dao = PaperDAO() allSearchObjects = dao.getAllFilteredSearchObjects( doi='10.1021/jacs.6b00225') self.assertEquals(1, len(list(allSearchObjects)))
def test_getFilteredPaperObjectsForPublication(self): """ Tests for all search Objects with name """ dao = PaperDAO() allSearchObjects = dao.getAllFilteredSearchObjects( publicationList=['Journal of the American Chemical Society']) self.assertEquals(1, len(list(allSearchObjects)))
def test_getFilteredPaperObjectsForCollections(self): """ Tests for all search Objects with collections """ dao = PaperDAO() allSearchObjects = dao.getAllFilteredSearchObjects( collectionList=['MICCOM']) self.assertEquals(1, len(list(allSearchObjects)))
def test_getFilteredPaperObjectsForAuthors(self): """ Tests for all search Objects with name """ dao = PaperDAO() allSearchObjects = dao.getAllFilteredSearchObjects( authorsList=['marco']) self.assertTrue(list(allSearchObjects))
def test_getFilteredPaperObjectsForCollections(self): """ Tests for all search Objects with name """ dao = PaperDAO() allSearchObjects = dao.getAllFilteredSearchObjects( collectionList=['miccom']) self.assertTrue(list(allSearchObjects))
def test_getPaperDetails(self): """ Tests Paper details given paper id """ dao = PaperDAO() allSearchObjects = dao.getAllFilteredSearchObjects(tags=['DFT']) paperDetails = dao.getPaperDetails(allSearchObjects[0]['_Search__id']) self.assertEquals( allSearchObjects[0]['_Search__id'], paperDetails['id'])
def test_getWorkflowDetails(self): """ Tests workflow details given paper id """ dao = PaperDAO() allSearchObjects = dao.getAllFilteredSearchObjects(tags=['DFT']) workflowdetails = dao.getWorkflowDetails( allSearchObjects[0]['_Search__id']) self.assertEquals( workflowdetails['paperTitle'], allSearchObjects[0]['_Search__title'])
def test_insertIntoPapers(self): """ Insert Tests for all search Objects """ dao = PaperDAO() __location__ = os.path.realpath( os.path.join(os.getcwd(), os.path.dirname(__file__))) with open(os.path.join(__location__, 'data.json')) as f: paperdata = json.load(f) paperid = dao.insertIntoPapers(paperdata) self.assertIsNone(paperid)
def test_getWorkflowForChartDetails(self): """ Tests workflow details given chart id and paper id :return: """ dao = PaperDAO() allSearchObjects = dao.getAllFilteredSearchObjects(tags=['DFT']) paperDetails = dao.getPaperDetails(allSearchObjects[0]['_Search__id']) chartid = paperDetails['charts'][0].id workflowchartdetails = dao.getWorkflowForChartDetails( paperDetails['id'], chartid) self.assertEquals( workflowchartdetails['paperTitle'], allSearchObjects[0]['_Search__title'])
def verify(self, id): ''' Verify the user's and return the id of the new published paper Parameters ----------- id: string The id associated to the metadata Return ------ id, string, if no error html error code, if error ''' try: with open("{}{}.json".format(self.dir_prefix, id), 'r') as f: paper = json.load(f) id = PaperDAO().insertIntoPapers(paper) if not id: return {"msg": "Paper Already Exists in the database (Same title or doi)", "code": 400} return id except FileNotFoundError as e: print(e, file=stderr) return {"msg": "Incorrect verify link, this paper is not present in the wait queue", "code": 400} except Exception as e: print(e, file=stderr) return {"msg": "Internal Server Error", "code": 500}