Changeset View
Changeset View
Standalone View
Standalone View
swh/dataset/test/test_utils.py
| # Copyright (C) 2020 The Software Heritage developers | # Copyright (C) 2020 The Software Heritage developers | ||||
| # See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
| # License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
| # See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
| from swh.dataset.utils import SQLiteSet | import pytest | ||||
| from swh.dataset.utils import LevelDBSet, SQLiteSet | |||||
| def test_sqliteset(tmp_path): | |||||
| f = tmp_path / "test.sqlite3" | |||||
| with SQLiteSet(f) as s: | @pytest.fixture(params=[SQLiteSet, LevelDBSet]) | ||||
| def diskset(request, tmp_path): | |||||
| backend = request.param | |||||
| return backend(tmp_path / "test") | |||||
| def test_diskset(diskset): | |||||
| with diskset as s: | |||||
| assert s.add(b"a") | assert s.add(b"a") | ||||
| assert s.add(b"b") | assert s.add(b"b") | ||||
| assert not s.add(b"a") | assert not s.add(b"a") | ||||
| assert s.add(b"c") | assert s.add(b"c") | ||||
| assert not s.add(b"b") | assert not s.add(b"b") | ||||
| assert not s.add(b"c") | assert not s.add(b"c") | ||||
| assert not s.add(b"c") | assert not s.add(b"c") | ||||