Changeset View
Changeset View
Standalone View
Standalone View
swh/indexer/tests/test_origin_head.py
# Copyright (C) 2017-2018 The Software Heritage developers | # Copyright (C) 2017-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 | ||||
import unittest | import unittest | ||||
from swh.indexer.origin_head import OriginHeadIndexer | from swh.indexer.origin_head import OriginHeadIndexer | ||||
from swh.indexer.tests.utils import ( | from swh.indexer.tests.utils import ( | ||||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | def test_git_partial_snapshot(self): | ||||
}]) | }]) | ||||
self.indexer.storage.origin_visit_update( | self.indexer.storage.origin_visit_update( | ||||
origin_url, visit.visit, status='partial', snapshot=b'foo') | origin_url, visit.visit, status='partial', snapshot=b'foo') | ||||
self.indexer.run([origin_url]) | self.indexer.run([origin_url]) | ||||
self.assertEqual(self.indexer.results, []) | self.assertEqual(self.indexer.results, []) | ||||
def test_vcs_missing_snapshot(self): | def test_vcs_missing_snapshot(self): | ||||
self.indexer.storage.origin_add([{ | self.indexer.storage.origin_add([{ | ||||
'type': 'git', | |||||
'url': 'https://github.com/SoftwareHeritage/swh-indexer', | 'url': 'https://github.com/SoftwareHeritage/swh-indexer', | ||||
}]) | }]) | ||||
self.indexer.run( | self.indexer.run( | ||||
['https://github.com/SoftwareHeritage/swh-indexer']) | ['https://github.com/SoftwareHeritage/swh-indexer']) | ||||
self.assertEqual(self.indexer.results, []) | self.assertEqual(self.indexer.results, []) | ||||
def test_pypi_missing_branch(self): | def test_pypi_missing_branch(self): | ||||
origin_url = 'https://pypi.org/project/abcdef/' | origin_url = 'https://pypi.org/project/abcdef/' | ||||
Show All 22 Lines | def test_ftp(self): | ||||
['rsync://ftp.gnu.org/gnu/3dldf']) | ['rsync://ftp.gnu.org/gnu/3dldf']) | ||||
self.assertEqual(self.indexer.results, [{ | self.assertEqual(self.indexer.results, [{ | ||||
'revision_id': b'\x8e\xa9\x8e/\xea}\x9feF\xf4\x9f\xfd\xee' | 'revision_id': b'\x8e\xa9\x8e/\xea}\x9feF\xf4\x9f\xfd\xee' | ||||
b'\xcc\x1a\xb4`\x8c\x8by', | b'\xcc\x1a\xb4`\x8c\x8by', | ||||
'origin_url': 'rsync://ftp.gnu.org/gnu/3dldf'}]) | 'origin_url': 'rsync://ftp.gnu.org/gnu/3dldf'}]) | ||||
def test_ftp_missing_snapshot(self): | def test_ftp_missing_snapshot(self): | ||||
self.indexer.storage.origin_add([{ | self.indexer.storage.origin_add([{ | ||||
'type': 'ftp', | |||||
'url': 'rsync://ftp.gnu.org/gnu/foobar', | 'url': 'rsync://ftp.gnu.org/gnu/foobar', | ||||
}]) | }]) | ||||
self.indexer.run( | self.indexer.run( | ||||
['rsync://ftp.gnu.org/gnu/foobar']) | ['rsync://ftp.gnu.org/gnu/foobar']) | ||||
self.assertEqual(self.indexer.results, []) | self.assertEqual(self.indexer.results, []) | ||||
def test_deposit(self): | def test_deposit(self): | ||||
self.indexer.run( | self.indexer.run( | ||||
['https://forge.softwareheritage.org/source/' | ['https://forge.softwareheritage.org/source/' | ||||
'jesuisgpl/']) | 'jesuisgpl/']) | ||||
self.assertEqual(self.indexer.results, [{ | self.assertEqual(self.indexer.results, [{ | ||||
'revision_id': b'\xe7n\xa4\x9c\x9f\xfb\xb7\xf76\x11\x08{' | 'revision_id': b'\xe7n\xa4\x9c\x9f\xfb\xb7\xf76\x11\x08{' | ||||
b'\xa6\xe9\x99\xb1\x9e]q\xeb', | b'\xa6\xe9\x99\xb1\x9e]q\xeb', | ||||
'origin_url': 'https://forge.softwareheritage.org/source/' | 'origin_url': 'https://forge.softwareheritage.org/source/' | ||||
'jesuisgpl/'}]) | 'jesuisgpl/'}]) | ||||
def test_deposit_missing_snapshot(self): | def test_deposit_missing_snapshot(self): | ||||
self.indexer.storage.origin_add([{ | self.indexer.storage.origin_add([{ | ||||
'type': 'deposit', | |||||
'url': 'https://forge.softwareheritage.org/source/foobar', | 'url': 'https://forge.softwareheritage.org/source/foobar', | ||||
}]) | }]) | ||||
self.indexer.run( | self.indexer.run( | ||||
['https://forge.softwareheritage.org/source/foobar']) | ['https://forge.softwareheritage.org/source/foobar']) | ||||
self.assertEqual(self.indexer.results, []) | self.assertEqual(self.indexer.results, []) | ||||
def test_pypi(self): | def test_pypi(self): | ||||
self.indexer.run( | self.indexer.run( | ||||
Show All 13 Lines |