-
Couldn't load subscription status.
- Fork 79
Bringing back the green tick (i.e. pass the tests again) #1647
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c812fec
1b9c5ec
03d4571
bf13e4d
7797c72
4716480
2639998
e3ebea0
f191a16
6645258
f817558
0c5850f
6824b86
cb60f2d
4f1c9b1
4f05365
e730156
69d4a5e
03f87e6
fbd5b09
5ac0372
0919093
fec048b
60b9250
d4d685d
7791ba0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,6 @@ | ||
| from unittest import TestCase, main | ||
| from datetime import datetime | ||
|
|
||
| from future.utils import viewitems | ||
|
|
||
| from qiita_core.exceptions import IncompetentQiitaDeveloperError | ||
| from qiita_core.qiita_settings import qiita_config | ||
| from qiita_core.util import qiita_test_checker | ||
|
|
@@ -138,20 +136,20 @@ def setUp(self): | |
| "study_abstract": "Exploring how a high fat diet changes the " | ||
| "gut microbiome", | ||
| "emp_person_id": 2, | ||
| "principal_investigator_id": 3, | ||
| "lab_person_id": 1 | ||
| "principal_investigator": qdb.study.StudyPerson(3), | ||
| "lab_person": qdb.study.StudyPerson(1) | ||
| } | ||
|
|
||
| self.existingexp = { | ||
| 'mixs_compliant': True, | ||
| 'metadata_complete': True, | ||
| 'reprocess': False, | ||
| 'number_samples_promised': 27, | ||
| 'emp_person_id': qdb.study.StudyPerson(2), | ||
| 'emp_person_id': 2, | ||
| 'funding': None, | ||
| 'vamps_id': None, | ||
| 'first_contact': datetime(2014, 5, 19, 16, 10), | ||
| 'principal_investigator_id': qdb.study.StudyPerson(3), | ||
| 'principal_investigator': qdb.study.StudyPerson(3), | ||
| 'timeseries_type_id': 1, | ||
| 'study_abstract': | ||
| "This is a preliminary study to examine the " | ||
|
|
@@ -169,7 +167,7 @@ def setUp(self): | |
| 'study_alias': 'Cannabis Soils', | ||
| 'most_recent_contact': '2014-05-19 16:11', | ||
| 'most_recent_contact': datetime(2014, 5, 19, 16, 11), | ||
| 'lab_person_id': qdb.study.StudyPerson(1), | ||
| 'lab_person': qdb.study.StudyPerson(1), | ||
| 'number_samples_collected': 27} | ||
|
|
||
| def tearDown(self): | ||
|
|
@@ -361,15 +359,16 @@ def test_create_study_min_data(self): | |
| 'reprocess': False, | ||
| 'number_samples_promised': 28, 'emp_person_id': 2, | ||
| 'funding': None, 'vamps_id': None, | ||
| 'principal_investigator_id': 3, | ||
| 'principal_investigator': qdb.study.StudyPerson(3), | ||
| 'timeseries_type_id': 1, | ||
| 'study_abstract': 'Exploring how a high fat diet changes the ' | ||
| 'gut microbiome', | ||
| 'spatial_series': None, | ||
| 'study_description': 'Microbiome of people who eat nothing but' | ||
| ' fried chicken', | ||
| 'study_alias': 'FCM', | ||
| 'most_recent_contact': None, 'lab_person_id': 1, | ||
| 'most_recent_contact': None, | ||
| 'lab_person': qdb.study.StudyPerson(1), | ||
| 'number_samples_collected': 25} | ||
| self.assertEqual(obs_info, exp) | ||
| # Check the timestamp separately, since it is set by the database | ||
|
|
@@ -431,14 +430,16 @@ def test_create_study_all_data(self): | |
| 'number_samples_promised': 28, 'emp_person_id': 2, | ||
| 'funding': 'FundAgency', 'vamps_id': 'MBE_1111111', | ||
| 'first_contact': datetime(2014, 10, 24, 12, 47), | ||
| 'principal_investigator_id': 3, 'timeseries_type_id': 1, | ||
| 'principal_investigator': qdb.study.StudyPerson(3), | ||
| 'timeseries_type_id': 1, | ||
| 'study_abstract': 'Exploring how a high fat diet changes the ' | ||
| 'gut microbiome', | ||
| 'spatial_series': True, | ||
| 'study_description': 'Microbiome of people who eat nothing ' | ||
| 'but fried chicken', | ||
| 'study_alias': 'FCM', | ||
| 'most_recent_contact': None, 'lab_person_id': 1, | ||
| 'most_recent_contact': None, | ||
| 'lab_person': qdb.study.StudyPerson(1), | ||
| 'number_samples_collected': 25} | ||
| self.assertEqual(obs.info, exp) | ||
| self.assertEqual(obs.efo, [1]) | ||
|
|
@@ -584,12 +585,6 @@ def test_ebi_submission_status_setter(self): | |
| with self.assertRaises(ValueError): | ||
| new.ebi_submission_status = "unknown" | ||
|
|
||
| def test_retrieve_info(self): | ||
| for key, val in viewitems(self.existingexp): | ||
| if isinstance(val, qdb.base.QiitaObject): | ||
| self.existingexp[key] = val.id | ||
| self.assertEqual(self.study.info, self.existingexp) | ||
|
|
||
| def test_set_info(self): | ||
| """Set info in a study""" | ||
| newinfo = { | ||
|
|
@@ -611,8 +606,9 @@ def test_set_info(self): | |
| self.infoexp["spatial_series"] = None | ||
| self.infoexp["most_recent_contact"] = None | ||
| self.infoexp["reprocess"] = False | ||
| self.infoexp["lab_person_id"] = 2 | ||
| self.infoexp["first_contact"] = datetime(2014, 6, 11) | ||
| self.infoexp["lab_person"] = qdb.study.StudyPerson(2) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why this two step process instead of just changing the key to lab_person on line 594? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that line 594 and this are not the same variable. |
||
| del self.infoexp["lab_person_id"] | ||
|
|
||
| self.assertEqual(new.info, self.infoexp) | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,21 +11,24 @@ | |
| from datetime import datetime | ||
|
|
||
| import pandas as pd | ||
| import numpy.testing as npt | ||
|
|
||
| from qiita_core.qiita_settings import qiita_config | ||
| from qiita_core.util import qiita_test_checker | ||
| from qiita_db.artifact import Artifact | ||
| from qiita_db.metadata_template.prep_template import PrepTemplate | ||
| from qiita_db.study import Study | ||
| from qiita_db.util import get_count, get_mountpoint | ||
| from qiita_db.exceptions import QiitaDBUnknownIDError | ||
| from qiita_db.exceptions import QiitaDBUnknownIDError, QiitaDBWarning | ||
| from qiita_pet.handlers.api_proxy.artifact import ( | ||
| artifact_get_req, artifact_status_put_req, artifact_graph_get_req, | ||
| artifact_delete_req, artifact_types_get_req, artifact_post_req) | ||
|
|
||
|
|
||
| @qiita_test_checker() | ||
| class TestArtifactAPI(TestCase): | ||
| database = True | ||
|
|
||
| def setUp(self): | ||
| uploads_path = get_mountpoint('uploads')[0][1] | ||
| # Create prep test file to point at | ||
|
|
@@ -97,8 +100,9 @@ def test_artifact_get_req(self): | |
| def test_artifact_post_req(self): | ||
| # Create new prep template to attach artifact to | ||
| new_prep_id = get_count('qiita.prep_template') + 1 | ||
| PrepTemplate.create(pd.DataFrame( | ||
| {'new_col': {'1.SKD6.640190': 1}}), Study(1), '16S') | ||
| npt.assert_warns( | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should also test the warning mesage is correct. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not correct, we are not interested in the warning message thrown here. the only reason why this is wrapped in the npt.assert_warns is because we don't want the warning message to show up on the test suite. |
||
| QiitaDBWarning, PrepTemplate.create, | ||
| pd.DataFrame({'new_col': {'1.SKD6.640190': 1}}), Study(1), '16S') | ||
|
|
||
| new_artifact_id = get_count('qiita.artifact') + 1 | ||
| obs = artifact_post_req( | ||
|
|
@@ -115,8 +119,9 @@ def test_artifact_post_req(self): | |
| def test_artifact_post_req_bad_file(self): | ||
| # Create new prep template to attach artifact to | ||
| new_prep_id = get_count('qiita.prep_template') + 1 | ||
| PrepTemplate.create(pd.DataFrame( | ||
| {'new_col': {'1.SKD6.640190': 1}}), Study(1), '16S') | ||
| npt.assert_warns( | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here |
||
| QiitaDBWarning, PrepTemplate.create, | ||
| pd.DataFrame({'new_col': {'1.SKD6.640190': 1}}), Study(1), '16S') | ||
|
|
||
| obs = artifact_post_req( | ||
| 'test@foo.bar', {'raw_forward_seqs': ['NOEXIST']}, | ||
|
|
@@ -170,9 +175,10 @@ def test_artifact_graph_get_req_descendants(self): | |
| 'node_labels': [(1, 'Raw data 1 - FASTQ'), | ||
| (3, 'Demultiplexed 2 - Demultiplexed'), | ||
| (2, 'Demultiplexed 1 - Demultiplexed'), | ||
| (4, 'BIOM - BIOM')], | ||
| 'edge_list': [(1, 3), (1, 2), (2, 4)]} | ||
| self.assertEqual(obs, exp) | ||
| (4, 'BIOM - BIOM'), | ||
| (5, 'BIOM - BIOM')], | ||
| 'edge_list': [(1, 3), (1, 2), (2, 5), (2, 4)]} | ||
| self.assertItemsEqual(obs, exp) | ||
|
|
||
| def test_artifact_graph_get_req_no_access(self): | ||
| obs = artifact_graph_get_req(1, 'ancestors', 'demo@microbio.me') | ||
|
|
@@ -191,7 +197,10 @@ def test_artifact_types_get_req(self): | |
| ['FASTQ', None], | ||
| ['SFF', None], | ||
| ['per_sample_FASTQ', None]]} | ||
| self.assertEqual(obs, exp) | ||
|
|
||
| self.assertEqual(obs['message'], exp['message']) | ||
| self.assertEqual(obs['status'], exp['status']) | ||
| self.assertItemsEqual(obs['types'], exp['types']) | ||
|
|
||
| def test_artifact_graph_get_req_bad_direction(self): | ||
| obs = artifact_graph_get_req(1, 'WRONG', 'test@foo.bar') | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,13 +12,15 @@ | |
| from random import choice | ||
|
|
||
| import pandas as pd | ||
| import numpy.testing as npt | ||
|
|
||
| from qiita_core.qiita_settings import qiita_config | ||
| from qiita_core.util import qiita_test_checker | ||
| from qiita_db.metadata_template.prep_template import PrepTemplate | ||
| from qiita_db.ontology import Ontology | ||
| from qiita_db.study import Study | ||
| from qiita_db.util import get_count | ||
| from qiita_db.exceptions import QiitaDBWarning | ||
| from qiita_pet.handlers.api_proxy.prep_template import ( | ||
| prep_template_summary_get_req, prep_template_post_req, | ||
| prep_template_put_req, prep_template_delete_req, prep_template_get_req, | ||
|
|
@@ -36,8 +38,8 @@ def setUp(self): | |
| with open(self.update_fp, 'w') as f: | ||
| f.write("""sample_name\tnew_col\n1.SKD6.640190\tnew_value\n""") | ||
|
|
||
| def tear_down(self): | ||
| remove(self.update_fp) | ||
| def tear_down(self): | ||
| remove(self.update_fp) | ||
|
|
||
| fp = join(qiita_config.base_data_dir, 'uploads', '1', | ||
| 'uploaded_file.txt') | ||
|
|
@@ -187,7 +189,11 @@ def test_prep_template_post_req(self): | |
| 'LinkerPrimerSequence, BarcodeSequence', | ||
| 'file': 'update.txt', | ||
| 'id': new_id} | ||
| self.assertEqual(obs, exp) | ||
| self.assertEqual(obs['status'], exp['status']) | ||
| self.assertItemsEqual(obs['message'].split('\n'), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why the split? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you pay attention to the code that generates this string, it is a result of joining the strings stored in a set. Since it is in a set, it is unordered, so we cannot ensure the order of the strings here. By doing the split and assertItemsEqual I can compare that the contents are the same. |
||
| exp['message'].split('\n')) | ||
| self.assertEqual(obs['file'], exp['file']) | ||
| self.assertEqual(obs['id'], exp['id']) | ||
|
|
||
| # Make sure new prep template added | ||
| prep = PrepTemplate(new_id) | ||
|
|
@@ -232,7 +238,10 @@ def test_prep_template_put_req_warning(self): | |
| 'differences between the data stored in the DB and ' | ||
| 'the new data provided', | ||
| 'file': 'update.txt'} | ||
| self.assertEqual(obs, exp) | ||
| self.assertEqual(obs['status'], exp['status']) | ||
| self.assertItemsEqual(obs['message'].split('\n'), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same question here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same answer |
||
| exp['message'].split('\n')) | ||
| self.assertEqual(obs['file'], exp['file']) | ||
|
|
||
| def test_prep_put_req_inv_type(self): | ||
| randstr = ''.join([choice(ascii_letters) for x in range(30)]) | ||
|
|
@@ -270,7 +279,8 @@ def test_prep_template_put_req_no_exists(self): | |
| def test_prep_template_delete_req(self): | ||
| template = pd.read_csv(self.update_fp, sep='\t', index_col=0) | ||
| new_id = get_count('qiita.prep_template') + 1 | ||
| PrepTemplate.create(template, Study(1), '16S') | ||
| npt.assert_warns(QiitaDBWarning, PrepTemplate.create, | ||
| template, Study(1), '16S') | ||
| obs = prep_template_delete_req(new_id, 'test@foo.bar') | ||
| exp = {'status': 'success', | ||
| 'message': ''} | ||
|
|
@@ -315,17 +325,15 @@ def test_prep_template_filepaths_get_req_no_access(self): | |
|
|
||
| def test_prep_template_graph_get_req(self): | ||
| obs = prep_template_graph_get_req(1, 'test@foo.bar') | ||
| exp = {'edge_list': [(1, 3), (1, 2), (2, 4)], | ||
| exp = {'edge_list': [(1, 3), (1, 2), (2, 4), (2, 5)], | ||
| 'node_labels': [(1, 'Raw data 1 - FASTQ'), | ||
| (2, 'Demultiplexed 1 - Demultiplexed'), | ||
| (3, 'Demultiplexed 2 - Demultiplexed'), | ||
| (4, 'BIOM - BIOM')], | ||
| (4, 'BIOM - BIOM'), | ||
| (5, 'BIOM - BIOM')], | ||
| 'status': 'success', | ||
| 'message': ''} | ||
|
|
||
| self.assertItemsEqual(obs.keys(), exp.keys()) | ||
| self.assertItemsEqual(obs['edge_list'], exp['edge_list']) | ||
| self.assertItemsEqual(obs['node_labels'], exp['node_labels']) | ||
| self.assertItemsEqual(obs, exp) | ||
|
|
||
| def test_prep_template_graph_get_req_no_access(self): | ||
| obs = prep_template_graph_get_req(1, 'demo@microbio.me') | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not part of tests, but this should be renamed to emp_person since it's no longer the ID.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's incorrect - note how it is actually the id, the ones that are no longer the id are the principal_investigator and the lab_person
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Went is this still the id but the rest are not? We should be consistent.
On Feb 27, 2016 14:17, "Jose Navas" notifications@github.com wrote:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@antgonza @ElDeveloper @mortonjt
emp_personis not used anywhere in the code and I think we should drop it as that is something that we will be keeping track in Jira, not Qiita. Should we spend time fixing that or just agree that we are going to drop it?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added an issue to discuss that: #1668