python: Test samdb import
authorDavid Mulder <dmulder@suse.com>
Mon, 7 Dec 2020 14:39:00 +0000 (07:39 -0700)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 10 Mar 2021 21:43:34 +0000 (21:43 +0000)
Signed-off-by: David Mulder <dmulder@suse.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/tests/imports.py [new file with mode: 0644]
selftest/knownfail.d/gpo [new file with mode: 0644]
source4/selftest/tests.py

diff --git a/python/samba/tests/imports.py b/python/samba/tests/imports.py
new file mode 100644 (file)
index 0000000..727f529
--- /dev/null
@@ -0,0 +1,31 @@
+# Unix SMB/CIFS implementation. Tests for python imports
+# Copyright (C) David Mulder <dmulder@samba.org> 2020
+#
+# 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 <http://www.gnu.org/licenses/>.
+#
+from samba.tests import TestCase
+
+class PyImportsTestCase(TestCase):
+    def setUp(self):
+        super().setUp()
+
+    def tearDown(self):
+        super().tearDown()
+
+    def test_samdb_import(self):
+        try:
+            from samba import dsdb, dsdb_dns
+            from samba import samdb
+        except ImportError as e:
+            self.fail('Failed to import samdb from samba: %s' % str(e))
diff --git a/selftest/knownfail.d/gpo b/selftest/knownfail.d/gpo
new file mode 100644 (file)
index 0000000..05e6226
--- /dev/null
@@ -0,0 +1 @@
+^samba.tests.imports
index bc8fea83474043005ea2e82319c345240dcd75c5..a0afe76e8d98b9438b35afb1be33194323fa1941 100755 (executable)
@@ -809,6 +809,10 @@ planoldpythontestsuite("ad_dc:local", "samba.tests.gpo", extra_args=['-U"$USERNA
 planoldpythontestsuite("ad_member", "samba.tests.gpo_member", extra_args=['-U"$USERNAME%$PASSWORD"'])
 planoldpythontestsuite("ad_dc:local", "samba.tests.dckeytab", extra_args=['-U"$USERNAME%$PASSWORD"'])
 
+# Run the import test in environments that may not have the ad-dc built
+for env in ['fileserver_smb1', 'nt4_member', 'clusteredmember', 'ktest', 'nt4_dc', 'nt4_dc_smb1_done', 'nt4_dc_smb1', 'simpleserver', 'fileserver_smb1_done', 'fileserver', 'maptoguest', 'nt4_dc_schannel']:
+    planoldpythontestsuite(env, "samba.tests.imports")
+
 planoldpythontestsuite("none", "samba.tests.krb5.kcrypto")
 planoldpythontestsuite("ad_dc_default", "samba.tests.krb5.simple_tests",
                        environ={'SERVICE_USERNAME':'$SERVER'})