Skip to content
Snippets Groups Projects
Unverified Commit c35028fa authored by jlaura's avatar jlaura Committed by GitHub
Browse files

Fixes #4 (#13)

* removes custom json parsing

* Logical test and fixture renaming

* fixes #4 pluginlist iterator

* Removes version warning for << operator

* Adds license file

* Fixes linking on OSX

* Logical test and fixture renaming

* fixes #4 pluginlist iterator

* Removes version warning for << operator

* Adds license file

* Fixes linking on OSX

* Updates env and recipe
parent 6c0b1b22
No related branches found
No related tags found
No related merge requests found
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org/>
name: csmswig name: csmswig
channels: channels:
- conda-forge - conda-forge
- usgs-astrogeology
dependencies: dependencies:
- cmake >= 3.10 - cmake >= 3.10
- csm - csm
......
%module(package="csmapi") plugin %module(package="csmapi") plugin
%{ %{
#include "Plugin.h" #include "Plugin.h"
typedef csm::Plugin Plugin;
%} %}
%include <std_string.i> %include <std_string.i>
%include <std_list.i> %include <std_list.i>
%include Model.h %include Model.h
%apply SWIGTYPE *DYNAMIC { csm::Model * }; %apply SWIGTYPE *DYNAMIC { csm::Model * };
%include Plugin.h %include Plugin.h
typedef csm::Plugin Plugin;
// Returns a list of pointer to pointers (which is necessary because the
// plugin is an abstract base class...)
%template(PluginList) std::list<const csm::Plugin*>; %template(PluginList) std::list<const csm::Plugin*>;
%{ %{
namespace swig { namespace swig {
template <> struct traits<csm::Plugin> template <> struct traits<csm::Plugin>
...@@ -27,7 +28,6 @@ ...@@ -27,7 +28,6 @@
} }
%} %}
// A general purpose function for dynamic casting of a Model * // A general purpose function for dynamic casting of a Model *
%{ %{
static swig_type_info * static swig_type_info *
......
...@@ -22,8 +22,16 @@ include_directories(${CSM_INCLUDE_DIR}) ...@@ -22,8 +22,16 @@ include_directories(${CSM_INCLUDE_DIR})
swig_add_library(csmapi swig_add_library(csmapi
LANGUAGE python LANGUAGE python
SOURCES ../csmapi.i) SOURCES ../csmapi.i)
set_target_properties(_csmapi PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SWIG_OUTDIR}) set_target_properties(_csmapi PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SWIG_OUTDIR})
swig_link_libraries(csmapi ${CSM_LIBRARY} ${PYTHON_LIBRARY})
if (APPLE)
set_target_properties(_csmapi PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
# On OSX, do not link python - this causes segfaults
swig_link_libraries(csmapi ${CSM_LIBRARY})
else()
swig_link_libraries(csmapi ${CSM_LIBRARY} ${PYTHON_LIBRARY})
endif()
# Build out a standard directory structure # Build out a standard directory structure
# file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tests) # file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tests)
......
...@@ -17,8 +17,7 @@ def isd(): ...@@ -17,8 +17,7 @@ def isd():
@pytest.fixture @pytest.fixture
def plugin(): def plugin():
plugin = csmapi.Plugin.findPlugin('PluginFixture') return csmapi.Plugin.findPlugin('PluginFixture')
return plugin
@pytest.fixture @pytest.fixture
def model(isd, plugin): def model(isd, plugin):
...@@ -58,5 +57,4 @@ def test_bad_ground_to_image(model): ...@@ -58,5 +57,4 @@ def test_bad_ground_to_image(model):
gnd_coord = csmapi.EcefCoord(-1, -1, 0) gnd_coord = csmapi.EcefCoord(-1, -1, 0)
with pytest.warns(Warning) as w: with pytest.warns(Warning) as w:
img = model.groundToImage(gnd_coord, 0) img = model.groundToImage(gnd_coord, 0)
assert len(w) == 1 assert len(w) == 1
\ No newline at end of file
\ No newline at end of file
...@@ -5,25 +5,48 @@ import pytest ...@@ -5,25 +5,48 @@ import pytest
def test_loadlib(loadlib): def test_loadlib(loadlib):
assert loadlib is not None assert loadlib is not None
@pytest.fixture @pytest.fixture
def model(): def plugin_pool():
plugin = csmapi.Plugin """
pl = plugin.findPlugin('PluginFixture') This fixture is the umbrella plugin object that
return pl stores all of the currently loaded plugin.
"""
return csmapi.Plugin
def test_plugin_size(): @pytest.fixture
def plugin(plugin_pool):
plugin_list = csmapi.Plugin.getList() """
This fixture is a single loaded plugin accessed
from the plugin pool. From this plugin a model
could be loaded.
"""
return plugin_pool.findPlugin('PluginFixture')
def test_plugin_size(plugin_pool):
plugin_list = plugin_pool.getList()
assert len(plugin_list) == 1 assert len(plugin_list) == 1
def test_plugin_name(): def test_plugin_list_type(plugin_pool):
plugin = csmapi.Plugin plugin_list = plugin_pool.getList()
pl = plugin.getList()[0] assert isinstance(plugin_list, csmapi.PluginList)
def test_plugin_list_element_type_by_position(plugin_pool):
plugin_list = plugin_pool.getList()
assert isinstance(plugin_list[0], csmapi.Plugin)
def test_plugin_list_element_type_via_iterator(plugin_pool):
plugin_list = plugin_pool.getList()
for i in plugin_list:
assert isinstance(i, csmapi.Plugin)
def test_plugin_name(plugin_pool):
pl = plugin_pool.getList()[0]
plugin_name = pl.getPluginName() plugin_name = pl.getPluginName()
assert plugin_name == "PluginFixture" assert plugin_name == "PluginFixture"
def test_model_getNumModels(model): def test_model_getNumModels(plugin):
assert model.getNumModels() == 1 assert plugin.getNumModels() == 1
def test_model_getModelName(model): def test_model_getModelName(plugin):
assert model.getModelName(0) == 'FixtureSensorModel' assert plugin.getModelName(0) == 'FixtureSensorModel'
\ No newline at end of file
...@@ -9,11 +9,10 @@ requirements: ...@@ -9,11 +9,10 @@ requirements:
build: build:
- {{ compiler('cxx') }} # [linux] - {{ compiler('cxx') }} # [linux]
- cmake >=3.10 - cmake >=3.10
host:
- libcsm - libcsm
- python - python
- swig - swig
host:
- python
run: run:
- libcsm - libcsm
- python - python
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
%include <std_string.i> %include <std_string.i>
%rename ("$ignore", fullname=1) csm::Version::print; %rename ("$ignore", fullname=1) csm::Version::print;
%ignore operator<<;
%include "Version.h" %include "Version.h"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment