summaryrefslogtreecommitdiff
path: root/lib/ldb/tests/python/api.py
AgeCommit message (Collapse)AuthorFilesLines
2024-09-24ldb:tests: move api.py to api_miscDouglas Bagnall1-1047/+0
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org>
2024-09-24ldb:tests: make api_simple moduleDouglas Bagnall1-732/+0
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org>
2024-09-24ldb:tests: make api_add_modify moduleDouglas Bagnall1-355/+0
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org>
2024-09-24ldb:tests: make api_search moduleDouglas Bagnall1-1698/+0
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org>
2024-09-24ldb:tests: make api_base moduleDouglas Bagnall1-38/+6
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org>
2024-09-24ldb:tests:api.py uses .disconnect before rmdirDouglas Bagnall1-1/+1
super.tearDown() was removing the tmpdir, but because self.ldb had the file open, the directory was not cleared. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org>
2024-09-24ldb:pytest:api: remove unnecessary super() parametersDouglas Bagnall1-45/+45
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org>
2024-09-24ldb:pytest:api: remove pass-though tearDownsDouglas Bagnall1-48/+0
The result is exactly the same, unless we previously had the wrong class name in the pass-through, in which case the result is *probably* the same, only more correct. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org>
2024-05-07ldb:tests: add a test for dotted i uppercaseDouglas Bagnall1-0/+4
This didn't fail in the tr_TR locale before recent changes for https://bugzilla.samba.org/show_bug.cgi?id=15637, because this is a different casefold codepath. But it could fail if that other path goes wrong, so we might as well have the test. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2024-04-23ldb:pytests: test for Turkic i-dots in ldb_comparison_foldDouglas Bagnall1-0/+16
In tr_TR and some other locales where the letter 'i' uppercases to 'İ', which is not ideal for LDB as we need certain strings like 'guid' to casefold in the ASCII way. In fixing https://bugzilla.samba.org/show_bug.cgi?id=15248) we solved this problem in many cases, but for unindexed searches where the 'i' is not the last character in the string. This test shows that. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15637 Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2024-04-10ldb:pytests: test ldb.connect() works after .disconnect()Douglas Bagnall1-0/+9
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2024-03-20ldb:pytests: test duplicate connections failDouglas Bagnall1-0/+14
(they don't yet). Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2024-03-03ldb: Pass a supported opaque type to ldb.set_opaque()Jo Sutton1-1/+1
We are about to modify ldb.set_opaque() to accept only certain types, and ldb.Ldb is not one of those types. Pass in a value that is supported and whose lifetime is guaranteed to outlive the Ldb object. Signed-off-by: Jo Sutton <josutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2024-03-03ldb: Add tests for Python set_opaque() and get_opaque()Jo Sutton1-0/+68
Signed-off-by: Jo Sutton <josutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2024-03-03pyldb: Remove unused and broken Python access to LDB module APIAndrew Bartlett1-58/+0
These exposed the private LDB modules API to python, and was untested and broken since LDB was made async internally as it never called ldb_wait() on the result. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2024-02-29ldb: ldb_string_to_time reports more errorsDouglas Bagnall1-0/+1
The underlying function should return -1 and set errno when given invalid strings, but we were not looking and have decided on 0 for error. It would be a pain to change this function to return -1. Apart from the API fuss, it is sometimes used unchecked to set an unsigned number and an unchecked 0 is better than UINT*_MAX in those contexts. It is probably not easy to get an -1 from a timegm() -- most implementations will happily convert overflows for you, so e.g. the 15th month would be March of the next year. But EOVERFLOW is mentioned in the manpages. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-08-30lib:ldb:tests: Remove explicit comparison with FalseJoseph Sutton1-1/+1
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-04-04lib:ldb:tests: Fix code spellingAndreas Schneider1-4/+4
Best reviewed with: `git show --word-diff`. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Tue Apr 4 08:30:28 UTC 2023 on atb-devel-224
2022-10-05pyldb: Fix tests going unusedJoseph Sutton1-23/+15
These tests are redeclared later and so are never used. Give them new names so that they will be run again. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2021-09-28pyldb: Add tests for ldb.Message containment testingJoseph Sutton1-0/+23
These tests verify that the 'in' operator on ldb.Message is consistent with indexing and the get() method. This means that the 'dn' element should always be present, lookups should be case-insensitive, and use of an invalid type should result in a TypeError. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14845 Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2021-09-28pyldb: Add test for an invalid ldb.Message index typeJoseph Sutton1-0/+6
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14845 Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2021-06-11pyldb: Add test for Message.items()Joseph Sutton1-0/+21
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2021-03-01pyldb: catch potential overflow error in py_timestringStefan Metzmacher1-0/+19
Pair-Programmed-With: Björn Baumbach <bb@sernet.de> Signed-off-by: Stefan Metzmacher <metze@samba.org> Signed-off-by: Björn Baumbach <bb@sernet.de> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2021-02-22ldb: remove some 'if PY3's in testsDouglas Bagnall1-43/+17
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: David Mulder <dmulder@suse.com> Autobuild-User(master): David Mulder <dmulder@samba.org> Autobuild-Date(master): Mon Feb 22 15:50:55 UTC 2021 on sn-devel-184
2020-02-25ldb: Add tests aimed at the SCOPE_ONELEVEL bug in particularAndrew Bartlett1-0/+8
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14270 Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2020-02-25ldb: Ensure @IDXONE modes is tested in ldb.python (apy.py) testsAndrew Bartlett1-1/+68
Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2020-02-25ldb: Add tests aimed at the SCOPE_ONELEVEL particularAndrew Bartlett1-0/+171
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14270 Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2020-02-25ldb: Add tests for one-level indexes in conjunction with other indexesAndrew Bartlett1-0/+251
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14270 Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2019-07-04ldb ldb_key_value: test ldb batchGary Lockyer1-0/+57
Test the the ldb "batch_mode" option sets batch mode operation. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-07-04ldb: Add tests for Ldb.write_ldif() including the FLG_SHOW_BINARY and ↵Andrew Bartlett1-0/+51
FLAG_FORCE_NO_BASE64_LDIF Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2019-06-21lib ldb key value: fix index bufferingGary Lockyer1-1/+81
As a performance enhancement the key value layer maintains a cache of the index records, which is written to disk as part of a prepare commit. This patch adds an extra cache at the operation layer to ensure that the cached indexes remain consistent in the event of an operation failing. Add test to test for index corruption in a failed modify. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org> Signed-off-by: Andrew Bartlett <abartlet@samba.org>
2019-06-21lib ldb tests: remove deprecation warning from api.pyGary Lockyer1-15/+15
Remove the "DeprecationWarning: Please use assertEqual instead." warnings from api.py Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-06-21lib ldb tests: Test nested transactionsGary Lockyer1-0/+103
Add a test to document that ldb does not currently support nested transactions. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-03-26Fix tests whithout lmdbMathieu Parent1-1/+1
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13630 Signed-off-by: Mathieu Parent <math.parent@gmail.com> Reviewed-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-03-06Enable make test even without lmdbMathieu Parent1-0/+41
Bug: https://bugzilla.samba.org/show_bug.cgi?id=13630 Signed-off-by: Mathieu Parent <math.parent@gmail.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2019-01-29ldb: The test api.py should not rely on order of entries in dictLukas Slebodnik1-6/+8
Test failed on s390x but there is a simple reproducer for any architecture. The built-in function repr returns the canonical string representation of the object. We needn't care about order attributes in string representation. Therefore test should pass for any order. for i in {1..30}; do PYTHONHASHSEED=random \ python2 -c 'import ldb; msg = ldb.Message(); msg.dn = ldb.Dn(ldb.Ldb(), "dc=foo29"); msg["dc"] = b"foo"; print(repr(msg)) ' done ====================================================================== FAIL: test_repr (__main__.LdbMsgTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "tests/python/api.py", line 2322, in test_repr "Message({'dn': Dn('dc=foo29'), 'dc': MessageElement(['foo'])})") AssertionError: "Message({'dc': MessageElement(['foo']), 'dn': Dn('dc=foo29')})" != "Message({'dn': Dn('dc=foo29'), 'dc': MessageElement(['foo'])})" ---------------------------------------------------------------------- Ran 1025 tests in 29.146s FAILED (failures=1) Signed-off-by: Lukas Slebodnik <lslebodn@fedoraproject.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org>
2019-01-13lib/ldb/tests/python: Add test to pass utf8 encoded bytes to ldb.DnNoel Power1-0/+15
This test should demonstrate an error with the 'es' format in python where a 'str' byte-string is passed (containing utf8 encoded bytes) with some characters that cannot be decoded as ascii. The same code if run in python3 should generate an error (needs string not bytes) Also Add knownfail for ldb.Dn passed utf8 encoded byte string Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-12-14PY3: change shebang to python3 in lib dirJoe Guo1-1/+1
Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Noel Power <npower@samba.org>
2018-11-01ldb/tests/py/api: use proper name for ldb.LdbErrorDouglas Bagnall1-2/+2
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <noel.power@suse.com>
2018-10-25ldb/tests/py/api: reveal shadowed casefold testDouglas Bagnall1-1/+1
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <npower@samba.org>
2018-09-27lib/ldb/tests: add test for ldb.Dn passed utf8 unicodeNoel Power1-0/+4
object dn format should be a utf8 encoded string Note: Currently this fails in python2 as the c python binding for the dn string param uses PyArg_ParseTupleAndKeywords() with 's' format, this will accept str *or* unicode in the default encoding. The default encoding in python2 is... ascii. Also adding here a knownfail to squash the error produced by the test. Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-09-06PEP8: fix E128: continuation line under-indented for visual indentJoe Guo1-1/+1
Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Thu Sep 6 15:50:17 CEST 2018 on sn-devel-144
2018-08-24PEP8: fix E502: the backslash is redundant between bracketsJoe Guo1-1/+1
Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-08-24PEP8: fix E306: expected 1 blank line before a nested definition, found 0Joe Guo1-0/+2
Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-08-24PEP8: fix E303: too many blank lines (2)Joe Guo1-7/+0
Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-08-24PEP8: fix E302: expected 2 blank lines, found 1Joe Guo1-0/+21
Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-08-24PEP8: fix E301: expected 1 blank line, found 0Joe Guo1-0/+16
Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-08-24PEP8: fix E231: missing whitespace after ','Joe Guo1-2/+2
Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-08-24PEP8: fix E226: missing whitespace around arithmetic operatorJoe Guo1-1/+1
Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-08-24PEP8: fix E203: whitespace before ':'Joe Guo1-6/+6
Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>