From 480f6f7f85d63d48c1be45b1231a6451c93e0c0b Mon Sep 17 00:00:00 2001
From: Simon Oehrl <oehrl@vr.rwth-aachen.de>
Date: Wed, 10 Jul 2019 17:02:19 +0200
Subject: [PATCH] Add testing python module

---
 pynesci/src/CMakeLists.txt                    |  1 +
 pynesci/src/testing/CMakeLists.txt            | 39 ++++++++++++++
 pynesci/src/testing/__init__.py               | 22 ++++++++
 pynesci/src/testing/pynesci_testing.cpp       | 54 +++++++++++++++++++
 .../test_pynesci_consumer_device_data_view.py |  5 +-
 5 files changed, 119 insertions(+), 2 deletions(-)
 create mode 100644 pynesci/src/testing/CMakeLists.txt
 create mode 100644 pynesci/src/testing/__init__.py
 create mode 100644 pynesci/src/testing/pynesci_testing.cpp

diff --git a/pynesci/src/CMakeLists.txt b/pynesci/src/CMakeLists.txt
index febeafd..0c44804 100644
--- a/pynesci/src/CMakeLists.txt
+++ b/pynesci/src/CMakeLists.txt
@@ -38,4 +38,5 @@ add_python_module(
   OUTPUT_DIRECTORY ${PYNESCI_OUTPUT_DIR}
   )
 
+add_subdirectory(testing)
 add_subdirectory(consumer)
diff --git a/pynesci/src/testing/CMakeLists.txt b/pynesci/src/testing/CMakeLists.txt
new file mode 100644
index 0000000..0db67d3
--- /dev/null
+++ b/pynesci/src/testing/CMakeLists.txt
@@ -0,0 +1,39 @@
+# -------------------------------------------------------------------------------
+# nesci -- neuronal simulator conan interface
+#
+# Copyright (c) 2018 RWTH Aachen University, Germany,
+# Virtual Reality & Immersive Visualization Group.
+# -------------------------------------------------------------------------------
+#                                  License
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# -------------------------------------------------------------------------------
+
+file(GLOB SOURCES *.cpp)
+file(GLOB HEADERS *.hpp)
+file(GLOB PYTHON_SOURCES *.py)
+
+set(PYNESCI_TESTING_OUTPUT_DIR
+  ${CMAKE_CURRENT_BINARY_DIR}/../../pynesci/testing
+  CACHE PATH "Output path for pynesci python module"
+  )
+
+add_python_module(
+  NAME _pynesci_testing
+  SOURCES ${SOURCES}
+  HEADERS ${HEADERS}
+  PYTHON_SOURCES ${PYTHON_SOURCES}
+  INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}
+  LINK_LIBRARIES Boost::python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR} Boost::disable_autolinking conduit nesci::nesci nesci::testing
+  OUTPUT_DIRECTORY ${PYNESCI_TESTING_OUTPUT_DIR}
+  )
diff --git a/pynesci/src/testing/__init__.py b/pynesci/src/testing/__init__.py
new file mode 100644
index 0000000..21638a9
--- /dev/null
+++ b/pynesci/src/testing/__init__.py
@@ -0,0 +1,22 @@
+# -------------------------------------------------------------------------------
+# nesci -- neuronal simulator conan interface
+#
+# Copyright (c) 2018 RWTH Aachen University, Germany,
+# Virtual Reality & Immersive Visualization Group.
+# -------------------------------------------------------------------------------
+#                                  License
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# -------------------------------------------------------------------------------
+
+from . _pynesci_testing import *
diff --git a/pynesci/src/testing/pynesci_testing.cpp b/pynesci/src/testing/pynesci_testing.cpp
new file mode 100644
index 0000000..829623e
--- /dev/null
+++ b/pynesci/src/testing/pynesci_testing.cpp
@@ -0,0 +1,54 @@
+//------------------------------------------------------------------------------
+// nesci -- neuronal simulator conan interface
+//
+// Copyright (c) 2017-2018 RWTH Aachen University, Germany,
+// Virtual Reality & Immersive Visualisation Group.
+//------------------------------------------------------------------------------
+//                                 License
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//------------------------------------------------------------------------------
+
+#include "boost/python.hpp"
+#include "nesci/testing/data.hpp"
+#include "pynesci/suppress_warnings.hpp"
+
+namespace pynesci {
+namespace testing {
+
+SUPPRESS_WARNINGS_BEGIN
+
+// cppcheck-suppress unusedFunction
+BOOST_PYTHON_MODULE(_pynesci_testing) {
+  using boost::noncopyable;
+  using boost::python::args;
+  using boost::python::bases;
+  using boost::python::class_;
+  using boost::python::def;
+  using boost::python::enum_;
+  using boost::python::init;
+  using boost::python::no_init;
+  using boost::python::pure_virtual;
+  using boost::python::scope;
+  using boost::python::wrapper;
+
+  def("CreateNestMultimeterDataNode",
+      &nesci::testing::CreateNestMultimeterDataNode);
+
+  def("CreateNestMultimeterDataNode",
+      &nesci::testing::CreateSpikeDetectorDataNode);
+}
+SUPPRESS_WARNINGS_END
+
+}  // namespace testing
+}  // namespace pynesci
diff --git a/pynesci/tests/test_pynesci_consumer_device_data_view.py b/pynesci/tests/test_pynesci_consumer_device_data_view.py
index d0a6567..6be3fbd 100644
--- a/pynesci/tests/test_pynesci_consumer_device_data_view.py
+++ b/pynesci/tests/test_pynesci_consumer_device_data_view.py
@@ -20,12 +20,13 @@
 # -------------------------------------------------------------------------------
 
 import pynesci
+import CreateSpikeDetectorDataNode from pynesci.testing
 
 
 def test_pynesci_consumer_device_data_view():
-    device = pynesci.consumer.DeviceDataView("SomeDeviceName")
+    device = pynesci.consumer.DeviceDataView(CreateSpikeDetectorDataNode())
 
 
 def test_pynesci_consumer_device_data_view_get_device_name():
-    device = pynesci.consumer.DeviceDataView("SomeDeviceName")
+    device = pynesci.consumer.DeviceDataView(CreateSpikeDetectorDataNode())
     assert device.GetDeviceName() == "SomeDeviceName"
-- 
GitLab