Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/svn/tests/test_loader.py
# Copyright (C) 2016-2018 The Software Heritage developers | # Copyright (C) 2016-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 | ||||
from nose.tools import istest | from nose.tools import istest | ||||
from test_base import BaseSvnLoaderTest | from test_base import BaseSvnLoaderTest | ||||
from unittest import TestCase | from unittest import TestCase | ||||
from swh.model import hashutil | from swh.model import hashutil | ||||
from swh.loader.svn.loader import build_swh_snapshot, DEFAULT_BRANCH | from swh.loader.svn.loader import build_swh_snapshot, DEFAULT_BRANCH | ||||
from swh.loader.svn.loader import SvnLoader | from swh.loader.svn.loader import SvnLoader, SvnLoaderFromRemoteDump | ||||
class TestSnapshot(TestCase): | class TestSnapshot(TestCase): | ||||
@istest | @istest | ||||
def build_swh_snapshot(self): | def build_swh_snapshot(self): | ||||
actual_snap = build_swh_snapshot('revision-id') | actual_snap = build_swh_snapshot('revision-id') | ||||
self.assertEquals(actual_snap, { | self.assertEquals(actual_snap, { | ||||
▲ Show 20 Lines • Show All 901 Lines • ▼ Show 20 Lines | def load(self): | ||||
last_revision: 'd853d9628f6f0008d324fed27dadad00ce48bc62', # noqa | last_revision: 'd853d9628f6f0008d324fed27dadad00ce48bc62', # noqa | ||||
} | } | ||||
self.assertRevisionsOk(expected_revisions) | self.assertRevisionsOk(expected_revisions) | ||||
self.assertEquals(len(self.loader.all_snapshots), 1) | self.assertEquals(len(self.loader.all_snapshots), 1) | ||||
# FIXME: Check the snapshot's state | # FIXME: Check the snapshot's state | ||||
self.assertEqual(self.loader.load_status(), {'status': 'eventful'}) | self.assertEqual(self.loader.load_status(), {'status': 'eventful'}) | ||||
self.assertEqual(self.loader.visit_status(), 'full') | self.assertEqual(self.loader.visit_status(), 'full') | ||||
class SvnLoaderFromRemoteDumpNoStorage(LoaderNoStorage, LoaderWithState, | |||||
SvnLoaderFromRemoteDump): | |||||
"""A SvnLoaderFromRemoteDump with no persistence. | |||||
Context: | |||||
Load a remote svn repository from a generated dump file. | |||||
""" | |||||
def swh_latest_snapshot_revision(self, origin_id, prev_swh_revision=None): | |||||
"""We do not know this repository so no revision. | |||||
""" | |||||
return {} | |||||
class SvnLoaderFromRemoteDump(BaseSvnLoaderTest): | |||||
""" | |||||
Check that the results obtained with the remote svn dump loader | |||||
and the base svn loader are the same. | |||||
""" | |||||
def setUp(self): | |||||
super().setUp(archive_name='pkg-gourmet.tgz') | |||||
@istest | |||||
def load(self): | |||||
""" | |||||
Compare results of remote dump loader and base loader | |||||
""" | |||||
dump_loader = SvnLoaderFromRemoteDumpNoStorage() | |||||
dump_loader.load(svn_url=self.svn_mirror_url) | |||||
base_loader = SvnLoaderNoStorage() | |||||
base_loader.load(svn_url=self.svn_mirror_url) | |||||
self.assertEqual(dump_loader.all_contents, | |||||
base_loader.all_contents) | |||||
self.assertEqual(dump_loader.all_directories, | |||||
base_loader.all_directories) | |||||
self.assertEqual(dump_loader.all_revisions, | |||||
base_loader.all_revisions) | |||||
self.assertEqual(dump_loader.all_snapshots, | |||||
base_loader.all_snapshots) | |||||
ardumont: \m/ |
\m/