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
SYNPY-714 #548
Merged
Merged
SYNPY-714 #548
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
|
@@ -736,18 +736,39 @@ def test_RowSetTable_len(): | |
def test_build_table__with_pandas_DataFrame(): | ||
df = pd.DataFrame(dict(a=[1, 2, 3], b=["c", "d", "e"])) | ||
table = build_table("test", "syn123", df) | ||
assert len(table)==3 | ||
for i, row in enumerate(table): | ||
assert row[0]==(i+1) | ||
assert row[1]==["c", "d", "e"][i] | ||
assert len(table)==3 | ||
|
||
headers = [ | ||
{'name': 'a', 'columnType': 'INTEGER'}, | ||
{'name': 'b', 'columnType': 'STRING'} | ||
] | ||
assert_equals(headers, table.headers) | ||
|
||
def test_build_table__with_non_pandas_DataFrame(): | ||
assert_raises(ValueError, build_table, "test", "syn123", []) | ||
def test_build_table__with_csv(): | ||
string_io = StringIOContextManager('a,b\n' | ||
'1,c\n' | ||
'2,d\n' | ||
'3,e') | ||
with patch.object(synapseclient.table, "as_table_columns", | ||
return_value = [Column(name = "a", columnType = "INTEGER"), | ||
Column(name = "b", columnType = "STRING")]),\ | ||
patch.object(io, "open", return_value = string_io): | ||
table = build_table("test", "syn123", "some_file_name") | ||
assert len(table) == 3 | ||
for col, row in enumerate(table): | ||
assert row[0] == (col + 1) | ||
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. use |
||
assert row[1] == ["c", "d", "e"][col] | ||
headers = [ | ||
{'name': 'a', 'columnType': 'INTEGER'}, | ||
{'name': 'b', 'columnType': 'STRING'} | ||
] | ||
assert_equals(headers, table.headers) | ||
|
||
def test_build_table__with_dict(): | ||
assert_raises(ValueError, build_table, "test", "syn123", dict(a=[1, 2, 3], b=["c", "d", "e"])) | ||
|
||
|
||
class TestTableQueryResult(): | ||
|
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.
Per @zimingd, we should refactor the name of SelectColumn to something else that represents what the class is: type information for each column of the CSV file. SelectColumn used to be used for only for CSVs retrieved from synapse; in that case, SelectColumn represented the types of columns that were in the SQL SELECT clause (including aggregates).