Skip to content

Commit

Permalink
fix tests after updating testdata/
Browse files Browse the repository at this point in the history
  • Loading branch information
matthieucan committed May 1, 2021
1 parent 81ea041 commit 8af2692
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 32 deletions.
2 changes: 1 addition & 1 deletion contrib/docker/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[DEFAULT]
db_uri: postgresql://docker:docker@db_1:5432/debsources
root_dir: /opt/debsources
cache_dir: %(root_dir)s/cache
cache_dir: %(root_dir)s/testdata/cache
local_dir: %(root_dir)s/local
sources_dir: %(root_dir)s/testdata/sources
python_dir: %(root_dir)s/python
Expand Down
2 changes: 1 addition & 1 deletion doc/testing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ updated to avoid test failures. Here is the recommended procedures to do that:
1. start with *clean slate*: clean your DB (e.g., `dropdb debsources`) and your
local sources directory (e.g., `rm -rf /srv/debsources/sources`). Then
re-inizialize an empty DB (e.g.,
`bin/debsources-admin --createdb postgres:///debsources`)
`createdb debsources; bin/debsources-dbadmin --createdb postgres:///debsources`)

2. do a *full update run* using a version of the code base that is trusted
enough to create the new reference version of the DB to be used for tests
Expand Down
5 changes: 0 additions & 5 deletions lib/debsources/license_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,6 @@ def license_url(package, version):


def get_license(package, version, path, c):
# if not license_path:
# # retrieve license from DB
# return qry.get_license_w_path(session, package, version, path)
# import pdb; pdb.set_trace()

# pathlib.Path uses a str to internally represent a path. In case of
# invalid bytes for utf8 encoding, surrogate escape sequences are
# used. debian.copyright seems to only work with utf8 when reading the
Expand Down
2 changes: 1 addition & 1 deletion lib/debsources/plugins/hook_copyright.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def parse_license_file(path):
for line in licenses:
fields = line.rstrip().split(b'\t')
license = fields[0].decode('utf8')
filename = fields[1]
filename = Path(fields[1].decode('utf8', 'surrogateescape'))
license_list.append((license, filename))
return license_list

Expand Down
2 changes: 1 addition & 1 deletion lib/debsources/tests/test_fs_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class FsStorageTests(unittest.TestCase):
@istest
def assertWalkLength(self):
self.assertEqual(len([f for f in walk(make_path(''))]),
288)
261)

@istest
def assertWalkTestChecksums(self):
Expand Down
24 changes: 12 additions & 12 deletions lib/debsources/tests/test_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ def diskUsagesMatchReferenceDb(self):
'wheezy': 39688,
'jessie': 50528,
'sid': 54456,
'experimental': 12968,
'experimental': 12964,
}
total_size = 180732
total_size = 180728
self.assertSuiteCountsEqual(sizes, statistics.disk_usage)
self.assertEqual(total_size, statistics.disk_usage(self.session))

Expand Down Expand Up @@ -120,13 +120,13 @@ def slocCountsMatchReferenceDb(self):
@istest
def ctagsCountsMatchReferenceDb(self):
ctags = {
'squeeze': 30644,
'wheezy': 20150,
'jessie': 23444,
'sid': 28352,
'squeeze': 31015,
'wheezy': 20521,
'jessie': 23815,
'sid': 28723,
'experimental': 17284,
}
total_ctags = 116089
total_ctags = 116832
self.assertSuiteCountsEqual(ctags, statistics.ctags)
self.assertEqual(total_ctags, statistics.ctags(self.session))

Expand All @@ -135,7 +135,7 @@ def slocPerPkgMatchReferenceDb(self):
LARGEST = ('cvsnt', '2.5.03.2382-3', 293583)
SMALLEST = ('susv3', '6.1', 10)
LARGEST_exp = ('beignet', '1.0.0-1', 81413)
SMALLEST_exp = ('ledger', '3.0.0~20130313+b608ed2-1', 45848)
SMALLEST_exp = ('ledger', '3.0.0~20130313+b608ed2-1', 46060)

slocs_all = statistics.sloc_per_package(self.session)
self.assertEqual(slocs_all[0], LARGEST)
Expand All @@ -149,9 +149,9 @@ def slocPerPkgMatchReferenceDb(self):
@istest
def areaFiltersMatchReferenceDb(self):
self.assertEqual(statistics.disk_usage(self.session),
180732)
180728)
self.assertEqual(statistics.disk_usage(self.session, areas=['main']),
155176)
155172)
self.assertEqual(statistics.disk_usage(self.session,
suite='wheezy', areas=['main']),
35824)
Expand All @@ -172,7 +172,7 @@ def areaFiltersMatchReferenceDb(self):
statistics.sloccount_lang(self.session, 'ansic'))

area_count = statistics.ctags(self.session, areas=['main'])
self.assertEqual(area_count, 87507)
self.assertEqual(area_count, 88250)
self.assertLessEqual(area_count, statistics.ctags(self.session))

@istest
Expand All @@ -194,7 +194,7 @@ def test_group_by_stats(self):
self.assertEqual(stats['etch'], 32736)

stats = dict(statistics.stats_grouped_by(self.session, 'ctags'))
self.assertEqual(stats['wheezy'], 20150)
self.assertEqual(stats['wheezy'], 20521)

stats = dict(statistics.stats_grouped_by(self.session,
'source_packages'))
Expand Down
13 changes: 7 additions & 6 deletions lib/debsources/tests/test_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,16 +281,16 @@ def tearDown(self):

@istest
def sizeMatchesReferenceDb(self):
EXPECTED_SIZE = 180732
EXPECTED_SIZE = 180728
self.assertEqual(EXPECTED_SIZE, self.stats['total.disk_usage'])

@istest
def statsMatchReferenceDb(self):
expected_stats = { # just a few samples
'total.ctags': 116089,
'debian_sid.ctags': 28352,
'debian_squeeze.ctags': 30644,
'debian_experimental.disk_usage': 12968,
'total.ctags': 116832,
'debian_sid.ctags': 28723,
'debian_squeeze.ctags': 31015,
'debian_experimental.disk_usage': 12964,
'total.source_files': 9333,
'debian_experimental.source_files': 1396,
'debian_jessie.source_files': 2038,
Expand All @@ -306,7 +306,8 @@ def statsMatchReferenceDb(self):
'debian_wheezy.sloccount.python': 2798,
'debian_squeeze.sloccount.ruby': 193,
'debian_wheezy.sloccount.ruby': 193,
'total.sloccount': 1250618,
'total.sloccount': 1250830,
'total.sloccount.javascript': 212,
'debian_squeeze.sloccount': 315750,
}
self.assertDictContainsSubset(expected_stats, self.stats)
Expand Down
8 changes: 4 additions & 4 deletions lib/debsources/tests/test_webapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,8 @@ def test_api_checksum_search_within_package(self):

def test_api_search_ctag(self):
rv = json.loads(self.app.get('/api/ctag/?ctag=name').data)
self.assertEqual(rv["count"], 193)
self.assertEqual(len(rv["results"]), 193)
self.assertEqual(rv["count"], 195)
self.assertEqual(len(rv["results"]), 195)

def test_api_search_ctag_within_package(self):
rv = json.loads(self.app.get(
Expand Down Expand Up @@ -555,8 +555,8 @@ def test_info_version(self):
def test_api_stats_suite(self):
rv = json.loads(self.app.get('/api/stats/jessie/').data)
self.assertEqual(rv["suite"], "jessie")
# self.assertEqual(rv["results"]["debian_jessie.ctags"], 21767)
# self.assertEqual(rv["results"]["debian_jessie.disk_usage"], 43032)
self.assertEqual(rv["results"]["debian_jessie.ctags"], 23815)
self.assertEqual(rv["results"]["debian_jessie.disk_usage"], 50528)
self.assertEqual(rv["results"]["debian_jessie.source_files"], 2038)
self.assertEqual(rv["results"]["debian_jessie.sloccount.python"], 2916)

Expand Down
2 changes: 1 addition & 1 deletion testdata
Submodule testdata updated from 1fe54f to 370ace

0 comments on commit 8af2692

Please sign in to comment.