From b88d461cffbbc7f6178d85e746476668132a01ac Mon Sep 17 00:00:00 2001 From: Dakota Benjamin Date: Fri, 19 Feb 2016 14:00:05 -0500 Subject: [PATCH] Simple resize test --- scripts/resize.py | 2 +- tests/test_odm.py | 76 +++++++++++++++++++-------------------- tests/test_prematching.py | 37 ------------------- 3 files changed, 38 insertions(+), 77 deletions(-) delete mode 100644 tests/test_prematching.py diff --git a/scripts/resize.py b/scripts/resize.py index 66d08899..9a890a77 100644 --- a/scripts/resize.py +++ b/scripts/resize.py @@ -7,7 +7,7 @@ from opendm import system from opendm import io from opendm import types -class ODMResizeCell(ecto.Cell): +class ODMResizeCell(ecto.Cell): def declare_params(self, params): params.declare("resize_to", "resizes images by the largest side", 2400) diff --git a/tests/test_odm.py b/tests/test_odm.py index 1b5d8146..5a6476f8 100644 --- a/tests/test_odm.py +++ b/tests/test_odm.py @@ -1,48 +1,46 @@ -import sys +import unittest from opendm import config +from opendm import context import ecto from scripts.odm_app import ODMApp -from scripts.resize import ODMResizeCell -err = sys.stderr -# Fixture functions -app = None - - -def setup_odm(): - # initialize ecto - global app - app = ODMApp(args=config.args) - plasm = ecto.Plasm() - plasm.insert(app) - err.write('MODULE SETUP\n') - - -def teardown_odm(): - # teardown ecto - err.write('MODULE TEARDOWN\n') - - -# The tests -def test_config(): - # check the args - test_args = 'tests/test_data' # sample test args - assert test_args == config.args.get('project_path') - - -class TestResize: - def __init__(self): - # Initialize whatever +from ecto.opts import scheduler_options, run_plasm +# +class TestResize(unittest.TestCase): + ''' + Tests the resize function + ''' def setUp(self): - #call cell - resizeCell = ODMResizeCell() + # Run tests + self.parser = config.parser + scheduler_options(self.parser) + self.options = self.parser.parse_args() + self.options.project_path = context.tests_data_path + self.app, self.plasm = self.appSetup(self.options) + print 'Run Setup: Initial Run' + run_plasm(self.options, self.plasm) - def tearDown(self): - #teardown functions + def test_resize(self): + # rerun resize cell and set params + self.options.rerun = 'resize' + self.options.resize_to = 1600 + print "Run Test 1: Rerun resize: %s" % self.options.resize_to + # rebuild app + self.app, self.plasm = self.appSetup(self.options) + run_plasm(self.options, self.plasm) + # assert each image is sized to the option.resize_to + print "Run Test 1: Check that the resize happens" + if self.app.resize.outputs.photos[0].height > self.app.resize.outputs.photos[0].width: + self.assertEquals(self.app.resize.outputs.photos[0].height, self.options.resize_to) + else: + self.assertEquals(self.app.resize.outputs.photos[0].width, self.options.resize_to) - # assert proper config/args + def appSetup(self, options): + app = ODMApp(args=vars(options)) + plasm = ecto.Plasm() + plasm.insert(app) + return app, plasm - # Check images in images_resize - - # Check images are resized (imagemagick?) +if __name__ == '__main__': + unittest.main() diff --git a/tests/test_prematching.py b/tests/test_prematching.py deleted file mode 100644 index 9cab390b..00000000 --- a/tests/test_prematching.py +++ /dev/null @@ -1,37 +0,0 @@ -from opendm import config -from opendm import context -from opendm import log -from opendm import system - -import sys -import ecto -from scripts.odm_app import ODMApp -from scripts.opensfm import ODMOpenSfMCell - -app = None - -def setup_prematching(self): - args = {'end_with':'resize','project_path':'tests/test_data'} - global app - app = ODMApp(args=config.args) - -def teardown_prematching(self): - # Delete the test folders - # if folders exist - # delete all but "images" folder - -def setUp(): - # create opensfm cell - # opensfm = ODMOpenSfMCell(use_exif_size=False, - # feature_process_size=config.args['resize_to'], - # feature_min_frames=config.args['min_num_features'], - # processes=context.num_cores, - # matching_gps_neighbors=config.args['matcher_k']), - -def test_prematching_config(): - # assert that relevant run args are what they say they are - - def test_opensfm_config_file(self): - # assert that the args i nthe opensfm config file match those it is set to - # when metcher_distance > 0 - # when the arg is out of bounds