def test_add_portal(self): Portal.create("NEWPORTAL", "SOMEDESC") obs = self.conn_handler.execute_fetchall( "SELECT * FROM qiita.portal_type") exp = [[1, 'QIITA', 'QIITA portal. Access to all data stored ' 'in database.'], [2, 'EMP', 'EMP portal'], [4, 'NEWPORTAL', 'SOMEDESC']] self.assertItemsEqual(obs, exp) obs = self.conn_handler.execute_fetchall( "SELECT * FROM qiita.analysis_portal") exp = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 2], [8, 2], [9, 2], [10, 2], [11, 4], [12, 4], [13, 4], [14, 4]] self.assertItemsEqual(obs, exp) with self.assertRaises(QiitaDBDuplicateError): Portal.create("EMP", "DOESNTMATTERFORDESC")
def test_remove_portal(self): Portal.create("NEWPORTAL", "SOMEDESC") # Select some samples on a default analysis qiita_config.portal = "NEWPORTAL" a = Analysis(User("*****@*****.**").default_analysis) a.add_samples({1: ['1.SKB8.640193', '1.SKD5.640186']}) Portal.delete("NEWPORTAL") obs = self.conn_handler.execute_fetchall( "SELECT * FROM qiita.portal_type") exp = [[1, 'QIITA', 'QIITA portal. Access to all data stored ' 'in database.'], [2, 'EMP', 'EMP portal']] self.assertItemsEqual(obs, exp) obs = self.conn_handler.execute_fetchall( "SELECT * FROM qiita.analysis_portal") exp = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 2], [8, 2], [9, 2], [10, 2]] self.assertItemsEqual(obs, exp) with self.assertRaises(QiitaDBLookupError): Portal.delete("NOEXISTPORTAL") with self.assertRaises(QiitaDBError): Portal.delete("QIITA") Portal.create("NEWPORTAL2", "SOMEDESC") # Add analysis to this new portal and make sure error raised qiita_config.portal = "NEWPORTAL2" Analysis.create(User("*****@*****.**"), "newportal analysis", "desc") qiita_config.portal = "QIITA" with self.assertRaises(QiitaDBError): Portal.delete("NEWPORTAL2") # Add study to this new portal and make sure error raised info = { "timeseries_type_id": 1, "metadata_complete": True, "mixs_compliant": True, "number_samples_collected": 25, "number_samples_promised": 28, "study_alias": "FCM", "study_description": "Microbiome of people who eat nothing but " "fried chicken", "study_abstract": "Exploring how a high fat diet changes the " "gut microbiome", "emp_person_id": StudyPerson(2), "principal_investigator_id": StudyPerson(3), "lab_person_id": StudyPerson(1) } Portal.create("NEWPORTAL3", "SOMEDESC") qiita_config.portal = "NEWPORTAL3" Study.create(User('*****@*****.**'), "Fried chicken microbiome", [1], info) qiita_config.portal = "QIITA" with self.assertRaises(QiitaDBError): Portal.delete("NEWPORTAL3")