-
Notifications
You must be signed in to change notification settings - Fork 80
Fix _almost_ all qiita db tests #1099
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
Merged
squirrelo
merged 8 commits into
qiita-spots:relax-md-req
from
josenavas:fix-qiita-db-tests
Apr 28, 2015
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
fbdf463
Fixing test_setup.py
josenavas ff4aae6
Fixing util.py
josenavas f7e62bd
Fixing data.py
josenavas 10d9a0e
Fixing search.py
josenavas e65a41d
Merge branch 'fix-metadata-obj' into fix-qiita-db-tests
josenavas 3d4d7dd
Merge branch 'fix-metadata-obj' into fix-qiita-db-tests
josenavas 0829f95
Merge branch 'relax-md-req' of https://github.com/biocore/qiita into …
josenavas d777469
Addressing comments from @ElDeveloper and @squirrelo
josenavas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -212,62 +212,6 @@ def get_data_types(key='data_type'): | |
return dict(con.execute_fetchall(sql)) | ||
|
||
|
||
def get_required_sample_info_status(key='status'): | ||
"""Gets the list of possible required sample info status | ||
|
||
Parameters | ||
---------- | ||
key : {'status', 'required_sample_info_status_id'}, optional | ||
Defaults to 'status'. Determines the format of the returned dict. | ||
|
||
Returns | ||
------- | ||
dict | ||
- If `key` is "status", dict is of the form | ||
{status: required_sample_info_status_id} | ||
- If `key` is "required_sample_info_status_id", dict is of the form | ||
{required_sample_info_status_id: status} | ||
""" | ||
con = SQLConnectionHandler() | ||
if key == 'status': | ||
cols = 'status, required_sample_info_status_id' | ||
elif key == 'required_sample_info_status_id': | ||
cols = 'required_sample_info_status_id, status' | ||
else: | ||
raise QiitaDBColumnError("Unknown key. Pass either 'status' or " | ||
"'required_sample_info_status_id'") | ||
sql = 'select {} from qiita.required_sample_info_status'.format(cols) | ||
return dict(con.execute_fetchall(sql)) | ||
|
||
|
||
def get_emp_status(key='emp_status'): | ||
"""Gets the list of possible emp statuses | ||
|
||
Parameters | ||
---------- | ||
key : {'emp_status', 'emp_status_id'}, optional | ||
Defaults to 'status'. Determines the format of the returned dict. | ||
|
||
Returns | ||
------- | ||
dict | ||
- If `key` is "emp_status", dict is of the form | ||
{emp_status: emp_status_id} | ||
- If `key` is "emp_status_id", dict is of the form | ||
{emp_status_id: emp_status} | ||
""" | ||
con = SQLConnectionHandler() | ||
if key == 'emp_status': | ||
cols = 'emp_status, emp_status_id' | ||
elif key == 'emp_status_id': | ||
cols = 'emp_status_id, emp_status' | ||
else: | ||
raise QiitaDBColumnError("Unknown key. Pass either 'emp_status' or " | ||
"'emp_status_id'") | ||
sql = 'select {} from qiita.emp_status'.format(cols) | ||
return dict(con.execute_fetchall(sql)) | ||
|
||
|
||
def create_rand_string(length, punct=True): | ||
"""Returns a string of random ascii characters | ||
|
||
|
@@ -1007,10 +951,27 @@ def get_processed_params_tables(): | |
|
||
|
||
def get_lat_longs(): | ||
"""Retrieve the latitude and longitude of all the samples in the DB | ||
|
||
Returns | ||
------- | ||
list of [float, float] | ||
The latitude and longitude for each sample in the database | ||
""" | ||
conn = SQLConnectionHandler() | ||
sql = """select latitude, longitude | ||
from qiita.required_sample_info""" | ||
return conn.execute_fetchall(sql) | ||
sql = """SELECT DISTINCT table_name | ||
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. Minor and non-blocking, but would you mind adding a docstring in this function? 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. Done |
||
FROM information_schema.columns | ||
WHERE SUBSTR(table_name, 1, 7) = 'sample_' | ||
AND table_schema = 'qiita' | ||
AND column_name IN ('latitude', 'longitude');""" | ||
tables_gen = (t[0] for t in conn.execute_fetchall(sql)) | ||
|
||
sql = "SELECT latitude, longitude FROM qiita.{0}" | ||
result = [] | ||
for table in tables_gen: | ||
result.extend(conn.execute_fetchall(sql.format(table))) | ||
|
||
return result | ||
|
||
|
||
def get_environmental_packages(conn_handler=None): | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
There's no need to have
lower('host_subject_id')
is there?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.
i.e. there's no need to call lower on that string.
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 is actually built programmatically, and lowers everything it gets so that search is case-insensitive.