diff --git a/qiita_core/tests/test_configuration_manager.py b/qiita_core/tests/test_configuration_manager.py index 2aa71c36e..a81608645 100644 --- a/qiita_core/tests/test_configuration_manager.py +++ b/qiita_core/tests/test_configuration_manager.py @@ -201,6 +201,7 @@ def test_get_portal(self): obs._get_portal(self.conf) self.assertEqual(obs.portal_dir, "/gold_portal") + CONF = """ # ------------------------------ Main settings -------------------------------- [main] diff --git a/qiita_core/tests/test_util.py b/qiita_core/tests/test_util.py index 351e72c06..2b3fbdc27 100644 --- a/qiita_core/tests/test_util.py +++ b/qiita_core/tests/test_util.py @@ -64,5 +64,6 @@ def test_get_qiita_version(self): # testing just the version self.assertEqual(exp_version, qdb.__version__) + if __name__ == '__main__': main() diff --git a/qiita_db/exceptions.py b/qiita_db/exceptions.py index eea058c86..2b06c702a 100644 --- a/qiita_db/exceptions.py +++ b/qiita_db/exceptions.py @@ -111,4 +111,5 @@ class QiitaDBWarning(UserWarning): """Warning specific for the QiitaDB domain""" pass + warnings.simplefilter('always', QiitaDBWarning) diff --git a/qiita_db/handlers/tests/test_artifact.py b/qiita_db/handlers/tests/test_artifact.py index ce88c7155..dd64464c9 100644 --- a/qiita_db/handlers/tests/test_artifact.py +++ b/qiita_db/handlers/tests/test_artifact.py @@ -213,5 +213,6 @@ def test_post(self): data=data) self.assertEqual(obs.code, 200) + if __name__ == '__main__': main() diff --git a/qiita_db/handlers/tests/test_core.py b/qiita_db/handlers/tests/test_core.py index a0471de20..63be60a2f 100644 --- a/qiita_db/handlers/tests/test_core.py +++ b/qiita_db/handlers/tests/test_core.py @@ -20,5 +20,6 @@ def test_post(self): self.assertEqual(obs.code, 200) self.assertFalse(qdb.user.User.exists('new_user@test.foo')) + if __name__ == '__main__': main() diff --git a/qiita_db/handlers/tests/test_oauth2.py b/qiita_db/handlers/tests/test_oauth2.py index be5b7c117..2c4bd8f3d 100644 --- a/qiita_db/handlers/tests/test_oauth2.py +++ b/qiita_db/handlers/tests/test_oauth2.py @@ -294,5 +294,6 @@ def test_authenticate_password_missing_info(self): 'error_description': 'Oauth2 error: missing user information'} self.assertEqual(obs_body, exp) + if __name__ == "__main__": main() diff --git a/qiita_db/handlers/tests/test_plugin.py b/qiita_db/handlers/tests/test_plugin.py index 457104739..036a58f32 100644 --- a/qiita_db/handlers/tests/test_plugin.py +++ b/qiita_db/handlers/tests/test_plugin.py @@ -197,5 +197,6 @@ def test_post(self): data={}) self.assertEqual(obs.code, 200) + if __name__ == '__main__': main() diff --git a/qiita_db/handlers/tests/test_processing_job.py b/qiita_db/handlers/tests/test_processing_job.py index 0a25612e2..c89d5cc26 100644 --- a/qiita_db/handlers/tests/test_processing_job.py +++ b/qiita_db/handlers/tests/test_processing_job.py @@ -274,5 +274,6 @@ def test_post_processing_job_status(self): self.assertEqual(qdb.processing_job.ProcessingJob(job_id).status, 'running') + if __name__ == '__main__': main() diff --git a/qiita_db/handlers/tests/test_reference.py b/qiita_db/handlers/tests/test_reference.py index 107ea7842..6403de40f 100644 --- a/qiita_db/handlers/tests/test_reference.py +++ b/qiita_db/handlers/tests/test_reference.py @@ -51,5 +51,6 @@ def test_get(self): exp = {'name': 'Greengenes', 'version': '13_8', 'files': fps} self.assertEqual(loads(obs.body), exp) + if __name__ == '__main__': main() diff --git a/qiita_db/meta_util.py b/qiita_db/meta_util.py index a7fc55025..f99c0d17b 100644 --- a/qiita_db/meta_util.py +++ b/qiita_db/meta_util.py @@ -162,7 +162,7 @@ def update_redis_stats(): STUDY = qdb.study.Study studies = {'public': STUDY.get_by_status('public'), 'private': STUDY.get_by_status('private'), - 'sanbox': STUDY.get_by_status('sandbox')} + 'sandbox': STUDY.get_by_status('sandbox')} number_studies = {k: len(v) for k, v in viewitems(studies)} number_of_samples = {} @@ -192,7 +192,8 @@ def update_redis_stats(): lat_longs = get_lat_longs() - num_studies_ebi = len(ebi_samples_prep) + num_studies_ebi = len([k for k, v in viewitems(ebi_samples_prep) + if v >= 1]) number_samples_ebi_prep = sum([v for _, v in viewitems(ebi_samples_prep)]) # generating file size stats diff --git a/qiita_db/metadata_template/constants.py b/qiita_db/metadata_template/constants.py index fb7a4cdb0..b88f71235 100644 --- a/qiita_db/metadata_template/constants.py +++ b/qiita_db/metadata_template/constants.py @@ -89,4 +89,5 @@ def _col_iterator(): for cols in viewkeys(restriction.columns): yield cols + CONTROLLED_COLS = set(col for col in _col_iterator()) diff --git a/qiita_db/sql_connection.py b/qiita_db/sql_connection.py index 1223c5b88..1c1588ddf 100644 --- a/qiita_db/sql_connection.py +++ b/qiita_db/sql_connection.py @@ -934,5 +934,6 @@ def add_post_rollback_func(self, func, *args, **kwargs): """ self._post_rollback_funcs.append((func, args, kwargs)) + # Singleton pattern, create the transaction for the entire system TRN = Transaction() diff --git a/qiita_db/support_files/patches/python_patches/51.py b/qiita_db/support_files/patches/python_patches/51.py index 3169dd79c..a8d3eeeb0 100644 --- a/qiita_db/support_files/patches/python_patches/51.py +++ b/qiita_db/support_files/patches/python_patches/51.py @@ -45,17 +45,20 @@ def transform_date(value): } # loop over the old formats to see which one is it - date = None - for i, fmt in enumerate(formats): - try: - date = datetime.strptime(value, fmt) - break - except ValueError: - pass - if date is not None: - value = date.strftime(formats[fmt]) + if value is not None: + date = None + for i, fmt in enumerate(formats): + try: + date = datetime.strptime(value, fmt) + break + except ValueError: + pass + if date is not None: + value = date.strftime(formats[fmt]) + return value + if cols_sample: with TRN: # a few notes: just getting the preps with duplicated values; ignoring diff --git a/qiita_db/test/test_base.py b/qiita_db/test/test_base.py index b22002bc5..e141533bd 100644 --- a/qiita_db/test/test_base.py +++ b/qiita_db/test/test_base.py @@ -138,5 +138,6 @@ def test_check_status_unknown_status_list(self): with self.assertRaises(ValueError): self.tester.check_status(["foo", "bar"], exclude=True) + if __name__ == '__main__': main() diff --git a/qiita_db/test/test_commands.py b/qiita_db/test/test_commands.py index 0b4f0da5c..edf6f04f5 100644 --- a/qiita_db/test/test_commands.py +++ b/qiita_db/test/test_commands.py @@ -582,5 +582,6 @@ def test_complete_error(self): max_barcode_errors\t1.5 """ + if __name__ == "__main__": main() diff --git a/qiita_db/test/test_logger.py b/qiita_db/test/test_logger.py index ea9d04050..95764e71d 100644 --- a/qiita_db/test/test_logger.py +++ b/qiita_db/test/test_logger.py @@ -67,5 +67,6 @@ def test_clear_info(self): log_entry.clear_info() self.assertEqual(log_entry.info, []) + if __name__ == '__main__': main() diff --git a/qiita_db/test/test_meta_util.py b/qiita_db/test/test_meta_util.py index 1bc8c4231..c7fd8cf71 100644 --- a/qiita_db/test/test_meta_util.py +++ b/qiita_db/test/test_meta_util.py @@ -184,9 +184,9 @@ def test_update_redis_stats(self): portal = qiita_config.portal vals = [ - ('number_studies', {'sanbox': '0', 'public': '0', + ('number_studies', {'sandbox': '0', 'public': '0', 'private': '1'}, r_client.hgetall), - ('number_of_samples', {'sanbox': '0', 'public': '0', + ('number_of_samples', {'sandbox': '0', 'public': '0', 'private': '27'}, r_client.hgetall), ('num_users', '4', r_client.get), ('lat_longs', EXP_LAT_LONG, r_client.get), @@ -217,5 +217,6 @@ def test_update_redis_stats(self): ' [0.291867635913, 68.5945325743], [85.4121476399, 15.6526750776],' ' [68.0991287718, 34.8360987059]]') + if __name__ == '__main__': main() diff --git a/qiita_db/test/test_reference.py b/qiita_db/test/test_reference.py index e7cf286c1..91661945f 100644 --- a/qiita_db/test/test_reference.py +++ b/qiita_db/test/test_reference.py @@ -88,5 +88,6 @@ def test_tree_fp_empty(self): ref = qdb.reference.Reference(2) self.assertEqual(ref.tree_fp, '') + if __name__ == '__main__': main() diff --git a/qiita_db/test/test_software.py b/qiita_db/test/test_software.py index 0b1ea84c7..de3e1dd66 100644 --- a/qiita_db/test/test_software.py +++ b/qiita_db/test/test_software.py @@ -924,5 +924,6 @@ def test_graph(self): CLIENT_SECRET = %s """ + if __name__ == '__main__': main() diff --git a/qiita_db/test/test_sql_connection.py b/qiita_db/test/test_sql_connection.py index 9ae12847b..4cdf2647b 100644 --- a/qiita_db/test/test_sql_connection.py +++ b/qiita_db/test/test_sql_connection.py @@ -660,5 +660,6 @@ def test_index(self): self.assertEqual(qdb.sql_connection.TRN.index, 0) + if __name__ == "__main__": main() diff --git a/qiita_db/test/test_user.py b/qiita_db/test/test_user.py index f15d70459..0df6ccd11 100644 --- a/qiita_db/test/test_user.py +++ b/qiita_db/test/test_user.py @@ -473,5 +473,6 @@ def test_jobs_defaults(self): # no jobs self.assertEqual(qdb.user.User('admin@foo.bar').jobs(), []) + if __name__ == "__main__": main() diff --git a/qiita_pet/handlers/api_proxy/tests/test_artifact.py b/qiita_pet/handlers/api_proxy/tests/test_artifact.py index badcd9f06..fa819c96b 100644 --- a/qiita_pet/handlers/api_proxy/tests/test_artifact.py +++ b/qiita_pet/handlers/api_proxy/tests/test_artifact.py @@ -510,5 +510,6 @@ def test_artifact_status_put_req_unknown_status(self): 'message': 'Unknown visiblity value: BADSTAT'} self.assertEqual(obs, exp) + if __name__ == "__main__": main() diff --git a/qiita_pet/handlers/api_proxy/tests/test_ontology.py b/qiita_pet/handlers/api_proxy/tests/test_ontology.py index b45d1ca2f..839fd90f2 100644 --- a/qiita_pet/handlers/api_proxy/tests/test_ontology.py +++ b/qiita_pet/handlers/api_proxy/tests/test_ontology.py @@ -35,5 +35,6 @@ def test_ontology_patch_handler_errors(self): 'message': 'Ontology "ONTOLOGY" does not exist'} self.assertEqual(obs, exp) + if __name__ == '__main__': main() diff --git a/qiita_pet/handlers/api_proxy/tests/test_prep_template.py b/qiita_pet/handlers/api_proxy/tests/test_prep_template.py index dd9cc1272..fa43db045 100644 --- a/qiita_pet/handlers/api_proxy/tests/test_prep_template.py +++ b/qiita_pet/handlers/api_proxy/tests/test_prep_template.py @@ -544,5 +544,6 @@ def test_prep_template_delete_req_no_prep(self): 'message': 'Prep template 3100 does not exist'} self.assertEqual(obs, exp) + if __name__ == '__main__': main() diff --git a/qiita_pet/handlers/api_proxy/tests/test_processing.py b/qiita_pet/handlers/api_proxy/tests/test_processing.py index 357cfffcc..f8c38b47f 100644 --- a/qiita_pet/handlers/api_proxy/tests/test_processing.py +++ b/qiita_pet/handlers/api_proxy/tests/test_processing.py @@ -174,5 +174,6 @@ def test_workflow_handler_patch_req_error(self): 'message': 'Incorrect path parameter'} self.assertEqual(obs, exp) + if __name__ == '__main__': main() diff --git a/qiita_pet/handlers/study_handlers/tests/test_artifact.py b/qiita_pet/handlers/study_handlers/tests/test_artifact.py index 608ec4900..304dc2844 100644 --- a/qiita_pet/handlers/study_handlers/tests/test_artifact.py +++ b/qiita_pet/handlers/study_handlers/tests/test_artifact.py @@ -168,5 +168,6 @@ def test_post_admin(self): self.assertEqual(Artifact(3).visibility, 'sandbox') + if __name__ == "__main__": main() diff --git a/qiita_pet/handlers/study_handlers/tests/test_base.py b/qiita_pet/handlers/study_handlers/tests/test_base.py index 93187ee4a..33168bbf4 100644 --- a/qiita_pet/handlers/study_handlers/tests/test_base.py +++ b/qiita_pet/handlers/study_handlers/tests/test_base.py @@ -58,5 +58,6 @@ def test_get(self): self.assertEqual(response.code, 200) self.assertNotEqual(response.body, "") + if __name__ == "__main__": main() diff --git a/qiita_pet/handlers/study_handlers/tests/test_ebi_handlers.py b/qiita_pet/handlers/study_handlers/tests/test_ebi_handlers.py index 3bddbbdf6..b29f1ca13 100644 --- a/qiita_pet/handlers/study_handlers/tests/test_ebi_handlers.py +++ b/qiita_pet/handlers/study_handlers/tests/test_ebi_handlers.py @@ -53,5 +53,6 @@ def test_get_no_exist(self): response = self.get('/ebi_submission/100') self.assertEqual(response.code, 404) + if __name__ == "__main__": main() diff --git a/qiita_pet/handlers/study_handlers/tests/test_edit_handlers.py b/qiita_pet/handlers/study_handlers/tests/test_edit_handlers.py index 0caa9d345..8e68b8bfc 100644 --- a/qiita_pet/handlers/study_handlers/tests/test_edit_handlers.py +++ b/qiita_pet/handlers/study_handlers/tests/test_edit_handlers.py @@ -154,5 +154,6 @@ def test_get(self): # make sure responds properly self.assertEqual(response.body, 'False') + if __name__ == "__main__": main() diff --git a/qiita_pet/handlers/study_handlers/tests/test_listing_handlers.py b/qiita_pet/handlers/study_handlers/tests/test_listing_handlers.py index 06d871621..33fa2cbdc 100644 --- a/qiita_pet/handlers/study_handlers/tests/test_listing_handlers.py +++ b/qiita_pet/handlers/study_handlers/tests/test_listing_handlers.py @@ -355,5 +355,6 @@ def test_get_emp_portal(self): self.assertEqual(response.code, 200) self.assertEqual(loads(response.body), self.empty) + if __name__ == "__main__": main() diff --git a/qiita_pet/handlers/study_handlers/tests/test_prep_template.py b/qiita_pet/handlers/study_handlers/tests/test_prep_template.py index 74f71687c..31cb99ca2 100644 --- a/qiita_pet/handlers/study_handlers/tests/test_prep_template.py +++ b/qiita_pet/handlers/study_handlers/tests/test_prep_template.py @@ -72,5 +72,6 @@ def test_get_files_not_allowed(self): {'type': 'BIOM', 'prep_file': 'uploaded_file.txt', 'study_id': 1}) self.assertEqual(response.code, 405) + if __name__ == "__main__": main() diff --git a/qiita_pet/handlers/study_handlers/tests/test_processing.py b/qiita_pet/handlers/study_handlers/tests/test_processing.py index a480fa1b5..1ef3597ef 100644 --- a/qiita_pet/handlers/study_handlers/tests/test_processing.py +++ b/qiita_pet/handlers/study_handlers/tests/test_processing.py @@ -24,5 +24,6 @@ class ListOptionsHandler(TestHandlerBase): # TODO: Missing tests pass + if __name__ == "__main__": main() diff --git a/qiita_pet/handlers/study_handlers/tests/test_sample_template.py b/qiita_pet/handlers/study_handlers/tests/test_sample_template.py index 7f3dd9822..a2d8527b4 100644 --- a/qiita_pet/handlers/study_handlers/tests/test_sample_template.py +++ b/qiita_pet/handlers/study_handlers/tests/test_sample_template.py @@ -121,5 +121,6 @@ def test_post_error(self): "message": "Category NOEXIST does not exist in sample template"} self.assertEqual(loads(res.body), exp) + if __name__ == "__main__": main() diff --git a/qiita_pet/handlers/study_handlers/tests/test_vamps_handlers.py b/qiita_pet/handlers/study_handlers/tests/test_vamps_handlers.py index 6b482ce66..e17ff5eeb 100644 --- a/qiita_pet/handlers/study_handlers/tests/test_vamps_handlers.py +++ b/qiita_pet/handlers/study_handlers/tests/test_vamps_handlers.py @@ -14,5 +14,6 @@ class VAMPSHandlerTests(TestHandlerBase): # TODO: Missing tests pass + if __name__ == "__main__": main() diff --git a/qiita_pet/portal.py b/qiita_pet/portal.py index 6eb949c41..3953964e3 100644 --- a/qiita_pet/portal.py +++ b/qiita_pet/portal.py @@ -84,4 +84,5 @@ def _get_study_list(self, config): """Get the configuration of the study_list section""" self.example_search = config.get('study_list', 'EXAMPLE_SEARCH') + portal_styling = PortalStyleManager() diff --git a/qiita_pet/test/test_base_handlers.py b/qiita_pet/test/test_base_handlers.py index b2a44f224..c08e44399 100644 --- a/qiita_pet/test/test_base_handlers.py +++ b/qiita_pet/test/test_base_handlers.py @@ -13,5 +13,6 @@ def test_get(self): response = self.get('/THISPAGENOEXIST') self.assertEqual(response.code, 404) + if __name__ == "__main__": main() diff --git a/qiita_pet/test/test_logger.py b/qiita_pet/test/test_logger.py index a68477feb..994fd5728 100644 --- a/qiita_pet/test/test_logger.py +++ b/qiita_pet/test/test_logger.py @@ -14,5 +14,6 @@ def test_post(self): response = self.post('/admin/error/', {'numrecords': 20}) self.assertEqual(response.code, 405) + if __name__ == "__main__": main() diff --git a/qiita_pet/test/test_ontology.py b/qiita_pet/test/test_ontology.py index 64eecf4a3..d74d8ad60 100644 --- a/qiita_pet/test/test_ontology.py +++ b/qiita_pet/test/test_ontology.py @@ -19,5 +19,6 @@ def test_patch(self): exp = {'status': 'success', 'message': ''} self.assertEqual(loads(response.body), exp) + if __name__ == '__main__': main() diff --git a/qiita_pet/test/test_prep_template.py b/qiita_pet/test/test_prep_template.py index 7b6f9a6c4..3dab40dde 100644 --- a/qiita_pet/test/test_prep_template.py +++ b/qiita_pet/test/test_prep_template.py @@ -74,5 +74,6 @@ def test_delete(self): "with it"} self.assertEqual(loads(response.body), exp) + if __name__ == '__main__': main() diff --git a/qiita_pet/test/test_upload.py b/qiita_pet/test/test_upload.py index 759932862..093dcf858 100644 --- a/qiita_pet/test/test_upload.py +++ b/qiita_pet/test/test_upload.py @@ -17,5 +17,6 @@ def test_get(self): response = self.get('/upload/') self.assertEqual(response.code, 400) + if __name__ == "__main__": main() diff --git a/qiita_pet/test/test_user_handlers.py b/qiita_pet/test/test_user_handlers.py index 65b056dc1..16a247feb 100644 --- a/qiita_pet/test/test_user_handlers.py +++ b/qiita_pet/test/test_user_handlers.py @@ -59,5 +59,6 @@ def test_get(self): response = self.get('/user/jobs/') self.assertEqual(response.code, 200) + if __name__ == "__main__": main() diff --git a/qiita_ware/context.py b/qiita_ware/context.py index 4f2ba3809..0d51f517b 100644 --- a/qiita_ware/context.py +++ b/qiita_ware/context.py @@ -269,6 +269,7 @@ def _submit(ctx, channel, f, *args, **kwargs): ctx.submit_async(_redis_wrap, f, redis_deets, *args, **kwargs) return uuid + # likely want this in qiita_ware.__init__ context = Dispatch() submit = partial(_submit, context) diff --git a/qiita_ware/executor.py b/qiita_ware/executor.py index 5a360de67..e2e5bf80d 100644 --- a/qiita_ware/executor.py +++ b/qiita_ware/executor.py @@ -97,4 +97,5 @@ def _submit(ctx, user, parameters): ctx.submit_async(_redis_wrap, execute, redis_deets, job.id) return job.id + plugin_submit = partial(_submit, context) diff --git a/qiita_ware/test/test_dispatchable.py b/qiita_ware/test/test_dispatchable.py index 4352a0915..7a3eeb377 100644 --- a/qiita_ware/test/test_dispatchable.py +++ b/qiita_ware/test/test_dispatchable.py @@ -181,5 +181,6 @@ def test_delete_sample_or_column(self): '"samples" and "columns"'} self.assertEqual(obs, exp) + if __name__ == '__main__': main() diff --git a/qiita_ware/test/test_ebi.py b/qiita_ware/test/test_ebi.py index 2a260b4f5..3f6d643a4 100644 --- a/qiita_ware/test/test_ebi.py +++ b/qiita_ware/test/test_ebi.py @@ -1584,5 +1584,6 @@ def test_parse_EBI_reply(self): """ + if __name__ == "__main__": main() diff --git a/qiita_ware/test/test_util.py b/qiita_ware/test/test_util.py index 7c8857eed..9437a9aa5 100644 --- a/qiita_ware/test/test_util.py +++ b/qiita_ware/test/test_util.py @@ -182,6 +182,7 @@ def test_hdf5IO_open(self): os.remove(name) + # comment indicates the expected random value sequences = [ ('a_1', 'AATTGGCC-a1'), # 2, 3624216819017203053 diff --git a/scripts/qiita-env b/scripts/qiita-env index 2de58eb5d..d545a094f 100755 --- a/scripts/qiita-env +++ b/scripts/qiita-env @@ -175,5 +175,6 @@ def rem_portal(portal): except qdb.exceptions.QiitaDBLookupError: raise click.BadParameter("Portal name does not exist!") + if __name__ == '__main__': env() diff --git a/scripts/qiita-private b/scripts/qiita-private index 698caf845..40c6bf414 100755 --- a/scripts/qiita-private +++ b/scripts/qiita-private @@ -23,5 +23,6 @@ def qiita_private(): def complete_job(job_id, payload): qdb.commands.complete_job_cmd(job_id, payload) + if __name__ == '__main__': qiita_private() diff --git a/scripts/qiita-test-install b/scripts/qiita-test-install index e570e33a0..ff284aa7f 100755 --- a/scripts/qiita-test-install +++ b/scripts/qiita-test-install @@ -271,6 +271,7 @@ class QiitaConfig(TestCase): ('.'.join(map(str, version)), str_acceptable_min_version, str_acceptable_max_version)) + system_info_header = """ System information ==================