From 23b61265b85f321ae2ceddc6c75771f8881566d8 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Fri, 5 Sep 2008 10:13:10 -0400 Subject: Initial Import --- ldb/tests/python/api.py | 463 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 463 insertions(+) create mode 100755 ldb/tests/python/api.py (limited to 'ldb/tests/python/api.py') diff --git a/ldb/tests/python/api.py b/ldb/tests/python/api.py new file mode 100755 index 00000000..1ae3fde7 --- /dev/null +++ b/ldb/tests/python/api.py @@ -0,0 +1,463 @@ +#!/usr/bin/python +# Simple tests for the ldb python bindings. +# Copyright (C) 2007 Jelmer Vernooij + +import sys +import unittest + +# Required for the standalone LDB build +sys.path.append("swig") +sys.path.append("build/lib.linux-i686-2.4") + +import ldb + +class NoContextTests(unittest.TestCase): + def test_valid_attr_name(self): + self.assertTrue(ldb.valid_attr_name("foo")) + self.assertFalse(ldb.valid_attr_name("24foo")) + + def test_timestring(self): + self.assertEquals("19700101000000.0Z", ldb.timestring(0)) + self.assertEquals("20071119191012.0Z", ldb.timestring(1195499412)) + + def test_string_to_time(self): + self.assertEquals(0, ldb.string_to_time("19700101000000.0Z")) + self.assertEquals(1195499412, ldb.string_to_time("20071119191012.0Z")) + + +class SimpleLdb(unittest.TestCase): + def test_connect(self): + ldb.Ldb("foo.tdb") + + def test_connect_none(self): + ldb.Ldb() + + def test_connect_later(self): + x = ldb.Ldb() + x.connect("foo.tdb") + + def test_repr(self): + x = ldb.Ldb() + self.assertTrue(repr(x).startswith("