-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added unit test framework * added unit test framework * file rename * variable name update * pep8 compliance * pep8 compliance
- Loading branch information
1 parent
5948b1c
commit 5515f3a
Showing
7 changed files
with
110 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
favoriteColor,name | ||
blue,phil | ||
green,tom |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
id,mexico,serbia,favoriteMeat,favoriteFruit | ||
1,quien,ко,bacon,orange | ||
2,que,Шта,bacon,banana | ||
3,donde,где,, |
Empty file.
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 |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import pytest | ||
import sys | ||
import logging | ||
import pandas | ||
import synapseclient | ||
|
||
|
||
SAMPLE_FILE = "../sampleFile.csv" | ||
SAMPLE_META = "../sampleMeta.csv" | ||
|
||
|
||
@pytest.fixture(scope='session') | ||
def syn(): | ||
syn = synapseclient.login() | ||
return syn | ||
|
||
|
||
@pytest.fixture(scope='session') | ||
def sampleEntities(): | ||
data = pandas.read_csv(SAMPLE_FILE, header=0, index_col=None) | ||
meta = pandas.read_csv(SAMPLE_META, header=0, index_col=None) | ||
return {'data': data, 'meta': meta} | ||
|
||
|
||
@pytest.fixture(scope='session') | ||
def entities(syn, sampleEntities): | ||
import uuid # random project name | ||
project = synapseclient.Project(str(uuid.uuid4())) | ||
project = syn.store(project) | ||
# store sample files | ||
_file = synapseclient.File(path=SAMPLE_FILE, name='file1.csv', | ||
parent=project) | ||
_file = syn.store(_file) | ||
_file2 = synapseclient.File(path=SAMPLE_FILE, name='file2.csv', | ||
parent=project) | ||
_file2 = syn.store(_file2) | ||
_file3 = synapseclient.File(path=SAMPLE_FILE, name='file3.csv.gz', | ||
parent=project) | ||
_file3 = syn.store(_file3) | ||
# store a sample metadata file | ||
meta = synapseclient.File(path=SAMPLE_META, name='meta', parent=project) | ||
meta = syn.store(meta) | ||
# store a sample table (same values as sample file) | ||
df = sampleEntities['data'] | ||
cols = synapseclient.as_table_columns(df) | ||
schema = synapseclient.Schema(name="table", columns=cols, | ||
parent=project) | ||
schema = syn.store(schema) | ||
table = syn.store(synapseclient.Table(schema, df)) | ||
# store a sample file view | ||
entity_view = synapseclient.EntityViewSchema( | ||
name='entity_view', | ||
parent=project, | ||
scopes=[project]) | ||
entity_view = syn.store(entity_view) | ||
ents = {'files': [_file, _file2, _file3], | ||
'meta': meta, | ||
'schema': schema, | ||
'entity_view': entity_view} | ||
yield ents | ||
syn.delete(project) |
Empty file.
Empty file.
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import annotator | ||
import pandas | ||
|
||
|
||
def test_setUp(syn, sampleEntities, entities): | ||
""" Set up working environment on Synapse, | ||
passes if set-up is successful | ||
""" | ||
assert True | ||
|
||
|
||
def test_synread_csv(syn, sampleEntities, entities): | ||
df = annotator.utils.synread(syn, entities['files'][0].id, sortCols=False) | ||
pandas.testing.assert_frame_equal(df, sampleEntities['data'], | ||
check_like=True) | ||
|
||
|
||
def test_synread_table(syn, sampleEntities, entities): | ||
df = annotator.utils.synread(syn, entities['schema'].id, sortCols=False) | ||
pandas.testing.assert_frame_equal( | ||
df.reset_index(drop=True), | ||
sampleEntities['data'], | ||
check_like=True) | ||
|
||
|
||
def test_synread_entity_view(syn, sampleEntities, entities): | ||
df = annotator.utils.synread( | ||
syn, | ||
entities['entity_view'].id, | ||
sortCols=False) | ||
assert isinstance(df, pandas.DataFrame) | ||
|
||
|
||
def test_synread_list_csv(syn, sampleEntities, entities): | ||
listOfDataFrames = annotator.utils.synread( | ||
syn, | ||
[f['id'] for f in entities['files']], | ||
sortCols=False) | ||
pandas.testing.assert_frame_equal( | ||
listOfDataFrames[0], | ||
sampleEntities['data'], | ||
check_like=True) |