Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/tests/algos/test_snapshot.py
# Copyright (C) 2018 The Software Heritage developers | # Copyright (C) 2018 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 | ||||
import unittest | import unittest | ||||
import pytest | import pytest | ||||
from hypothesis import given | from hypothesis import given | ||||
from hypothesis.strategies import datetimes | from hypothesis.strategies import datetimes | ||||
from swh.model.identifiers import snapshot_identifier, identifier_to_bytes | from swh.model.identifiers import snapshot_identifier, identifier_to_bytes | ||||
from swh.model.hypothesis_strategies import \ | from swh.model.hypothesis_strategies import \ | ||||
origins, snapshots, branch_names, branch_targets | origins, snapshots, branch_names, branch_targets | ||||
from swh.storage.tests.storage_testing import StorageTestFixture | |||||
from swh.storage.algos.snapshot import snapshot_get_all_branches | from swh.storage.algos.snapshot import snapshot_get_all_branches | ||||
@pytest.mark.xfail | |||||
@pytest.mark.db | @pytest.mark.db | ||||
@pytest.mark.property_based | @pytest.mark.property_based | ||||
class TestSnapshotAllBranches(StorageTestFixture, unittest.TestCase): | class TestSnapshotAllBranches(unittest.TestCase): | ||||
@given(origins().map(lambda x: x.to_dict()), | @given(origins().map(lambda x: x.to_dict()), | ||||
datetimes(), | datetimes(), | ||||
snapshots(min_size=0, max_size=10, only_objects=False)) | snapshots(min_size=0, max_size=10, only_objects=False)) | ||||
def test_snapshot_small(self, origin, ts, snapshot): | def test_snapshot_small(self, origin, ts, snapshot): | ||||
snapshot = snapshot.to_dict() | snapshot = snapshot.to_dict() | ||||
self.storage.snapshot_add([snapshot]) | self.storage.snapshot_add([snapshot]) | ||||
returned_snapshot = snapshot_get_all_branches(self.storage, | returned_snapshot = snapshot_get_all_branches(self.storage, | ||||
Show All 22 Lines |