From b6f0c6f49a6c045c2f7ebab8def6eb1414171f28 Mon Sep 17 00:00:00 2001
From: Pierre-Antoine Rouby <pierre-antoine.rouby@inrae.fr>
Date: Fri, 19 Jan 2024 11:20:53 +0100
Subject: [PATCH] tests: Add a mage meshingtool test.

---
 src/Meshing/Mage.py         |  3 ++-
 src/Meshing/__init__.py     | 17 +++++++++++++++++
 src/Meshing/test_Meshing.py | 37 +++++++++++++++++++++++++++++++++++++
 tests.sh                    |  2 +-
 4 files changed, 57 insertions(+), 2 deletions(-)
 create mode 100644 src/Meshing/__init__.py
 create mode 100644 src/Meshing/test_Meshing.py

diff --git a/src/Meshing/Mage.py b/src/Meshing/Mage.py
index c89f1781..11385042 100644
--- a/src/Meshing/Mage.py
+++ b/src/Meshing/Mage.py
@@ -52,7 +52,8 @@ class MeshingWithMage(AMeshingTool):
         self._init_c_purge()
         self._init_c_output_bief()
 
-    def _lib_path(self):
+    @classmethod
+    def _lib_path(cls):
         ext = "so" if os.name == "posix" else "dll"
 
         return os.path.abspath(
diff --git a/src/Meshing/__init__.py b/src/Meshing/__init__.py
new file mode 100644
index 00000000..89e3fbe8
--- /dev/null
+++ b/src/Meshing/__init__.py
@@ -0,0 +1,17 @@
+# __init__.py -- Pamhyr
+# Copyright (C) 2023  INRAE
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+# -*- coding: utf-8 -*-
diff --git a/src/Meshing/test_Meshing.py b/src/Meshing/test_Meshing.py
new file mode 100644
index 00000000..81b54b71
--- /dev/null
+++ b/src/Meshing/test_Meshing.py
@@ -0,0 +1,37 @@
+# test_Model.py -- Pamhyr
+# Copyright (C) 2023  INRAE
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+# -*- coding: utf-8 -*-
+
+import os
+import unittest
+import warnings
+import tempfile
+
+from Model.Saved import SavedStatus
+from Model.Study import Study
+from Model.River import River
+
+from Meshing.Mage import MeshingWithMage
+
+mage_mesher = os.path.exists(MeshingWithMage._lib_path())
+
+
+class MeshingTestCase(unittest.TestCase):
+    @unittest.skipIf(not mage_mesher, "libbief is not available")
+    def test_create_meshingtool_mage(self):
+        mesher = MeshingWithMage()
+        self.assertNotEqual(mesher, None)
diff --git a/tests.sh b/tests.sh
index ff235027..831d8952 100755
--- a/tests.sh
+++ b/tests.sh
@@ -11,7 +11,7 @@ pip3 install -U -r ./full-requirements.txt
 echo " UNITTEST"
 
 cd src/
-python3 -m unittest discover -v -t .
+python3 -Walways -m unittest discover -v -t .
 cd ..
 
 echo " PEP8"
-- 
GitLab