[gedit-plugins/sessionsaver] Simple test



commit 09e57032691bc91aef79ded1761d93cab3d8e180
Author: Jordi Mas <jmas softcatala org>
Date:   Mon Jul 1 19:58:11 2019 +0200

    Simple test

 plugins/sessionsaver/meson.build          |  1 +
 plugins/sessionsaver/tests/meson.build    | 21 ++++++++++++++++++++
 plugins/sessionsaver/tests/testsession.py | 32 +++++++++++++++++++++++++++++++
 3 files changed, 54 insertions(+)
---
diff --git a/plugins/sessionsaver/meson.build b/plugins/sessionsaver/meson.build
index f73e51d..927715e 100644
--- a/plugins/sessionsaver/meson.build
+++ b/plugins/sessionsaver/meson.build
@@ -17,6 +17,7 @@ install_data(
   )
 )
 
+subdir('tests')
 
 sessionsaver_plugin_in = configure_file(
   input: 'sessionsaver.plugin.desktop.in.in',
diff --git a/plugins/sessionsaver/tests/meson.build b/plugins/sessionsaver/tests/meson.build
new file mode 100644
index 0000000..17e8c43
--- /dev/null
+++ b/plugins/sessionsaver/tests/meson.build
@@ -0,0 +1,21 @@
+sessionsaver_tests = {
+  'session': files('testsession.py'),
+}
+
+sessionsaver_srcdir = join_paths(
+  srcdir,
+  'plugins',
+  'sessionsaver',
+  'sessionsaver',
+)
+
+foreach test_name, test_script : sessionsaver_tests
+  test(
+    'test-sessionsaver-@0@'.format(test_name),
+    python3,
+    args: [test_script],
+    env: [
+      'PYTHONPATH=@0@'.format(sessionsaver_srcdir),
+    ]
+  )
+endforeach
diff --git a/plugins/sessionsaver/tests/testsession.py b/plugins/sessionsaver/tests/testsession.py
new file mode 100644
index 0000000..61a8d58
--- /dev/null
+++ b/plugins/sessionsaver/tests/testsession.py
@@ -0,0 +1,32 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (c) 2019 Jordi Mas i Hernandez <jmas softcatala org>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the
+# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+
+import unittest
+from session import Session
+
+class TestSession(unittest.TestCase):
+
+    def test_add_file(self):
+        session = Session("session_A")
+        session.add_file('file')
+        self.assertEqual(1, len(session.files))
+
+if __name__ == '__main__':
+    unittest.main()


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]