-
Notifications
You must be signed in to change notification settings - Fork 9
/
test_check_update.py
executable file
·74 lines (67 loc) · 2.12 KB
/
test_check_update.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env python3
# vim: ts=4:sw=4:expandtab
# Copyright (C) 2014-2021 by Andrew Ziem. All rights reserved.
# License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
# This is free software: you are free to change and redistribute it.
# There is NO WARRANTY, to the extent permitted by law.
#
#
"""
Verify the online update notification system returns the right version numbers
"""
from __future__ import absolute_import
import os
import sys
dir_bb_root = os.path.abspath('../bleachbit')
os.chdir(dir_bb_root)
sys.path.append(dir_bb_root)
import bleachbit
import bleachbit.Update
latest_stable = '4.6.2'
latest_beta = None
# tuple in the format
# (current version sent, version returned 1, version returned 2)
tests = \
(('3.0', latest_stable, None),
('3.1.0', latest_stable, None),
('3.2.0', latest_stable, None),
('3.9.0', latest_stable, None),
('3.9.2', latest_stable, None),
('4.0.0', latest_stable, None),
('4.1.0', latest_stable, None),
('4.2.0', latest_stable, None),
('4.4.0', latest_stable, None),
('4.4.2', latest_stable, None),
('4.5.0', latest_stable, None),
('4.5.1', latest_stable, None),
('4.6.0', latest_stable, None),
('4.6.1', latest_stable, None),
('4.6.2', None, None))
for test in tests:
print('\n', '*' * 10, test[0])
bleachbit.APP_VERSION = test[0]
bleachbit.update_check_url = "%s/update/%s" % (
bleachbit.base_url, bleachbit.APP_VERSION)
v1e = test[1] # e=expected
v2e = test[2]
cu = bleachbit.Update.check_updates(True, False, None, None)
print('returned=', cu)
match = False
if cu == ():
v1r = None # r=returned
v2r = None
else:
if cu[0]:
v1r = cu[0][0]
else:
v1r = None
if len(cu) > 1:
v2r = cu[1][0]
else:
v2r = None
if not v1e == v1r:
print('ERROR: sent version %s, expected v1=%s, returned v1=%s' %
(test[0], v1e, v1r))
if not v2e == v2r:
print('ERROR: sent version %s, expected v2=%s, returned v2=%s' %
(test[0], v2e, v2r))