Skip to content

Commit

Permalink
Merge pull request #17 from ODM2/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
sreeder authored May 12, 2017
2 parents 1fafbab + db0fe60 commit c779d2b
Show file tree
Hide file tree
Showing 81 changed files with 1,337 additions and 393,088 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,5 @@ script:
- py.test

# - py.test yodatool/tests
# - py.test DataLoader/tests
# - py.test dataloader/tests

43 changes: 29 additions & 14 deletions tests/test_converter/test_input/test_excel.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,44 @@

import openpyxl

from yodatools.converter.Inputs.ExcelInput import ExcelInput

from yodatools.converter.Inputs.excelInput import ExcelInput
from odm2api.ODM2.models import People, SamplingFeatures

class ExcelTest(unittest.TestCase):

def setUp(self):
self.before_each_do()

def before_each_do(self):
curr_folder = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
file_path = os.path.join(curr_folder, 'test_files', 'YODA_TimeSeriesSpecimen_RB_2014-15_pub.xlsx')
self.curr_folder = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))

self.excel = ExcelInput()


def test_parse_specimen(self):
# D:\DEV\YODA - Tools\tests\test_files\test_ts_specimen_output.yaml
file_path = os.path.join(self.curr_folder, 'test_files', 'YODA_TimeSeriesSpecimen_RB_2014-15_pub.xlsx')
# file_path = os.path.join(curr_folder, 'test_files', 'test_ts_specimen_output.yaml')

if not does_file_exit(file_path):
print file_path + " does not exist"
assert False
self.excel.parse(file_path)
session = self.excel.sendODM2Session()

self.excel = ExcelInput(file_path)
assert session != None
assert len(session.query(People).all()) > 0
assert len(session.query(SamplingFeatures).all()) > 0
session.close()

def test_excel_parsing(self):
self.assertTrue(self.excel.parse())

# def test_parse_ts(self):
# file_path = os.path.join(self.curr_folder, 'test_files', 'YODA_v0.3.3_TS_climate(wHeaders).xlsm')
# # file_path = os.path.join(curr_folder, 'test_files', 'test_ts_output.yaml')
# self.excel.parse(file_path)
#
# session = self.excel.sendODM2Session()
#
# assert session != None
#
# assert len(session.query(People).all()) > 0
# assert len(session.query(SamplingFeatures).all()) > 0
# session.close()

def does_file_exit(file_path):
if os.path.isfile(file_path):
return True
return False
25 changes: 14 additions & 11 deletions tests/test_converter/test_input/test_yamlInput.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,11 @@ class TestYaml:
def setup(self):
self.yi = yamlInput()

def test_parse_ts(self):
file_path = os.path.join(curr_folder, 'test_files', 'test_ts.yaml')
self.yi.parse(file_path)

session = self.yi.sendODM2Session()

assert session != None
from odm2api.ODM2.models import People, SamplingFeatures
assert len(session.query(People).all()) > 0
assert len(session.query(SamplingFeatures).all()) > 0
session.close()

def test_parse_specimen(self):
# D:\DEV\YODA - Tools\tests\test_files\test_ts_specimen_output.yaml
file_path = os.path.join(curr_folder, 'test_files', 'test_specimen_ts.yaml')
# file_path = os.path.join(curr_folder, 'test_files', 'test_ts_specimen_output.yaml')

self.yi.parse(file_path)
session = self.yi.sendODM2Session()
Expand All @@ -32,6 +23,18 @@ def test_parse_specimen(self):
assert len(session.query(SamplingFeatures).all()) > 0
session.close()

# def test_parse_ts(self):
# file_path = os.path.join(curr_folder, 'test_files', 'test_ts.yaml')
# # file_path = os.path.join(curr_folder, 'test_files', 'test_ts_output.yaml')
# self.yi.parse(file_path)
#
# session = self.yi.sendODM2Session()
#
# assert session != None
# from odm2api.ODM2.models import People, SamplingFeatures
# assert len(session.query(People).all()) > 0
# assert len(session.query(SamplingFeatures).all()) > 0
# session.close()



28 changes: 28 additions & 0 deletions tests/test_converter/test_output/test_dbOutput.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import os

from tests.test_util import build_ts_session, build_ts_specimen_session
from yodatools.converter.Outputs.dbOutput import dbOutput
from odm2api import ODMconnection


curr_folder = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))

# curr_folder = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
# file_path = os.path.join(curr_folder, 'test_files', 'YODA_TimeSeriesSpecimen_RB_2014-15_pub.xlsx')
class TestDb:
def setup(self):

# self.connection_string = 'mysql+pymysql://ODM:odm@localhost/odm2'
self.connection_string = 'sqlite://'
self.do = dbOutput(self.connection_string)



def test_create_specimen(self):
session = build_ts_specimen_session()
self.do.save(session, self.connection_string)


def test_create_ts(self):
session = build_ts_session()
self.do.save(session, self.connection_string)
11 changes: 4 additions & 7 deletions tests/test_converter/test_output/test_yamlOutput.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,12 @@ class TestYaml:
def setup(self):
self.yo = yamlOutput()


def test_create_ts(self):
session = build_ts_session()
file_path = os.path.join(curr_folder,'test_files', 'test_ts_output.yaml' )
self.yo.save(session, file_path)

def test_create_specimen(self):
session = build_ts_specimen_session()
file_path = file_path = os.path.join(curr_folder, 'test_files', 'test_ts_specimen_output.yaml' )
self.yo.save(session, file_path)


def test_create_ts(self):
session = build_ts_session()
file_path = os.path.join(curr_folder, 'test_files', 'test_ts_output.yaml')
self.yo.save(session, file_path)
Binary file modified tests/test_files/ODM2_ts.sqlite
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit c779d2b

Please sign in to comment.