Skip to content
Snippets Groups Projects
Commit cfca483b authored by jlaura's avatar jlaura Committed by Jason R Laura
Browse files

Tests and add icu dep.

parent d09c843d
No related branches found
No related tags found
No related merge requests found
......@@ -20,13 +20,13 @@ install:
# We do this conditionally because it saves us some downloading if the
# version is the same.
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then
if [ "$PYTHON_VERSION" == "2.7" ]; then
if [ "$PYTHON_VERSION" == 2.7 ]; then
wget https://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh;
else
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
fi
else
if ["$PYTHON_VERSION" == "2.7"]; then
if ["$PYTHON_VERSION" == 2.7]; then
curl -o miniconda.sh https://repo.continuum.io/miniconda/Miniconda-latest-MacOSX-x86_64.sh;
else
curl -o miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh;
......
......@@ -12,6 +12,7 @@ requirements:
- pvl
- protobuf 3.0.0b2
- gdal >=2
- icu
- h5py
- pandas
- sqlalchemy
......@@ -22,6 +23,7 @@ requirements:
- pvl
- protobuf 3.0.0b2
- gdal >=2
- icu
- h5py
- pandas
- sqlalchemy
......
AS15-M-0295_SML.png
AS15-M-0296_SML.png
AS15-M-0297_SML.png
AS15-M-0298_SML.png
AS15-M-0299_SML.png
AS15-M-0300_SML.png
\ No newline at end of file
import shutil
import tempfile
def create_dir(basedir=''):
"""
Create a unique, temporary directory in /tmp where processing will occur
Parameters
----------
basedir : str
The PATH to create the temporary directory in.
"""
return tempfile.mkdtemp(dir=basedir)
def delete_dir(dir):
"""
Delete a directory
Parameters
----------
dir : str
Remove a directory
"""
shutil.rmtree(dir)
def file_to_list(file):
with open(file, 'r') as f:
file_list = f.readlines()
file_list = map(str.rstrip, file_list)
file_list = filter(None, file_list)
return file_list
import os
import unittest
from .. import io_utils
class TestIoUtils(unittest.TestCase):
def setUp(self):
pass
def test_create_and_destroy_directory(self):
path = io_utils.create_dir()
self.assertTrue(os.path.exists(path))
io_utils.delete_dir(path)
self.assertFalse(os.path.exists(path))
import os
import unittest
from ..examples import get_path
from .. import utils
class TestUtils(unittest.TestCase):
def test_find_in_dict(self):
......@@ -36,4 +37,19 @@ class TestUtils(unittest.TestCase):
}
self.assertEqual(utils.find_nested_in_dict(d, 'a'), 1)
self.assertEqual(utils.find_nested_in_dict(d, ['c', 'f', 'g']), 5)
\ No newline at end of file
self.assertEqual(utils.find_nested_in_dict(d, ['c', 'f', 'g']), 5)
def test_create_and_destroy_directory(self):
path = utils.create_dir()
self.assertTrue(os.path.exists(path))
utils.delete_dir(path)
self.assertFalse(os.path.exists(path))
def test_file_to_list(self):
truth = ['AS15-M-0295_SML.png', 'AS15-M-0296_SML.png',
'AS15-M-0297_SML.png', 'AS15-M-0298_SML.png',
'AS15-M-0299_SML.png', 'AS15-M-0300_SML.png']
self.assertEqual(utils.file_to_list(get_path('pngs.lis')), truth)
\ No newline at end of file
......@@ -3,6 +3,42 @@ import shutil
import tempfile
import os
import fnmatch
import shutil
import tempfile
def create_dir(basedir=''):
"""
Create a unique, temporary directory in /tmp where processing will occur
Parameters
----------
basedir : str
The PATH to create the temporary directory in.
"""
return tempfile.mkdtemp(dir=basedir)
def delete_dir(dir):
"""
Delete a directory
Parameters
----------
dir : str
Remove a directory
"""
shutil.rmtree(dir)
def file_to_list(file):
with open(file, 'r') as f:
file_list = f.readlines()
file_list = map(str.rstrip, file_list)
file_list = filter(None, file_list)
return list(file_list)
def create_dir(basedir=''):
"""
......@@ -53,6 +89,7 @@ def file_search(searchdir,searchstring):
return filelist
def find_in_dict(obj, key):
"""
Recursively find an entry in a dictionary
......@@ -98,6 +135,7 @@ def find_nested_in_dict(data, key_list):
"""
return reduce(lambda d, k: d[k], key_list, data)
def xstr(s):
"""
Return an empty string if the input is a NoneType. Otherwise
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment