mirror of
https://git.launchpad.net/~ubuntu-release/britney/+git/britney2-ubuntu
synced 2025-05-28 02:41:35 +00:00
refactoring, add tests for passing and failing adt test
This commit is contained in:
parent
e1dc047c7e
commit
fecf3be811
@ -199,54 +199,88 @@ args.func()
|
|||||||
''' % {'py': sys.executable, 'path': self.data.path, 'rq': request})
|
''' % {'py': sys.executable, 'path': self.data.path, 'rq': request})
|
||||||
|
|
||||||
def run_britney(self, args=[]):
|
def run_britney(self, args=[]):
|
||||||
'''Run britney and return (exit, out, err)'''
|
'''Run britney.
|
||||||
|
|
||||||
|
Assert that it succeeds and does not produce anything on stderr.
|
||||||
|
Return generated excuses.html output.
|
||||||
|
'''
|
||||||
britney = subprocess.Popen([self.britney, '-c', self.britney_conf],
|
britney = subprocess.Popen([self.britney, '-c', self.britney_conf],
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE,
|
stderr=subprocess.PIPE,
|
||||||
cwd=self.data.path,
|
cwd=self.data.path,
|
||||||
universal_newlines=True)
|
universal_newlines=True)
|
||||||
(out, err) = britney.communicate()
|
(out, err) = britney.communicate()
|
||||||
return (britney.returncode, out, err)
|
self.assertEqual(britney.returncode, 0, out + err)
|
||||||
|
self.assertEqual(err, '')
|
||||||
|
|
||||||
|
with open(os.path.join(self.data.path, 'output', 'excuses.html')) as f:
|
||||||
|
excuses = f.read()
|
||||||
|
|
||||||
|
return excuses
|
||||||
|
|
||||||
def test_no_request_for_uninstallable(self):
|
def test_no_request_for_uninstallable(self):
|
||||||
'''Does not request a test for an uninstallable package'''
|
'''Does not request a test for an uninstallable package'''
|
||||||
|
|
||||||
# uninstallable unstable version
|
self.do_test(
|
||||||
self.data.add('green', True,
|
# uninstallable unstable version
|
||||||
{'Version': '1.1~beta',
|
[('green', {'Version': '1.1~beta', 'Depends': 'libc6 (>= 0.9), libgreen1 (>= 2)'})],
|
||||||
'Depends': 'libc6 (>= 0.9), libgreen1 (>= 2)'})
|
'green 1.1~beta RUNNING green 1.1~beta\n',
|
||||||
|
False,
|
||||||
|
[r'\bgreen\b.*>1</a> to .*>1.1~beta<',
|
||||||
|
'green/amd64 unsatisfiable Depends: libgreen1 \(>= 2\)'],
|
||||||
|
# autopkgtest should not be triggered for uninstallable pkg
|
||||||
|
['autopkgtest'])
|
||||||
|
|
||||||
self.make_adt_britney('green 1.1~beta FAIL green 1.1~beta\n')
|
def test_request_for_installable_running(self):
|
||||||
|
'''Requests a test for an installable package, test still running'''
|
||||||
|
|
||||||
(c, o, e) = self.run_britney()
|
self.do_test(
|
||||||
self.assertEqual(e, '', e)
|
[('green', {'Version': '1.1~beta', 'Depends': 'libc6 (>= 0.9), libgreen1'})],
|
||||||
self.assertEqual(c, 0, o + e)
|
'green 1.1~beta RUNNING green 1.1~beta\n',
|
||||||
|
False,
|
||||||
|
[r'\bgreen\b.*>1</a> to .*>1.1~beta<',
|
||||||
|
'<li>autopkgtest for green 1.1~beta: RUNNING'])
|
||||||
|
|
||||||
with open(os.path.join(self.data.path, 'output', 'excuses.html')) as f:
|
def test_request_for_installable_fail(self):
|
||||||
excuses = f.read()
|
'''Requests a test for an installable package, test fail'''
|
||||||
self.assertIn('green/amd64 unsatisfiable Depends: libgreen1 (>= 2)', excuses)
|
|
||||||
# does not request autopkgtest for uninstallable package
|
|
||||||
self.assertNotIn('autopkgtest', excuses)
|
|
||||||
|
|
||||||
def test_request_for_installable(self):
|
self.do_test(
|
||||||
'''Requests a test for an installable package'''
|
[('green', {'Version': '1.1~beta', 'Depends': 'libc6 (>= 0.9), libgreen1'})],
|
||||||
|
'green 1.1~beta FAIL green 1.1~beta\n',
|
||||||
|
False,
|
||||||
|
[r'\bgreen\b.*>1</a> to .*>1.1~beta<',
|
||||||
|
'<li>autopkgtest for green 1.1~beta: FAIL'])
|
||||||
|
|
||||||
# installable unstable version
|
def test_request_for_installable_pass(self):
|
||||||
self.data.add('green', True,
|
'''Requests a test for an installable package, test pass'''
|
||||||
{'Version': '1.1~beta',
|
|
||||||
'Depends': 'libc6 (>= 0.9), libgreen1'})
|
|
||||||
|
|
||||||
self.make_adt_britney('green 1.1~beta RUNNING green 1.1~beta\n')
|
self.do_test(
|
||||||
|
[('green', {'Version': '1.1~beta', 'Depends': 'libc6 (>= 0.9), libgreen1'})],
|
||||||
|
'green 1.1~beta PASS green 1.1~beta\n',
|
||||||
|
True,
|
||||||
|
[r'\bgreen\b.*>1</a> to .*>1.1~beta<',
|
||||||
|
'<li>autopkgtest for green 1.1~beta: PASS'])
|
||||||
|
|
||||||
(c, o, e) = self.run_britney()
|
def do_test(self, unstable_add, adt_request, considered, expect=None,
|
||||||
self.assertEqual(c, 0, o + e)
|
no_expect=None):
|
||||||
self.assertEqual(e, '')
|
for (pkg, fields) in unstable_add:
|
||||||
|
self.data.add(pkg, True, fields)
|
||||||
|
|
||||||
|
self.make_adt_britney(adt_request)
|
||||||
|
|
||||||
|
excuses = self.run_britney()
|
||||||
|
if considered:
|
||||||
|
self.assertIn('Valid candidate', excuses)
|
||||||
|
else:
|
||||||
|
self.assertIn('Not considered', excuses)
|
||||||
|
|
||||||
|
if expect:
|
||||||
|
for re in expect:
|
||||||
|
self.assertRegexpMatches(excuses, re)
|
||||||
|
if no_expect:
|
||||||
|
for re in no_expect:
|
||||||
|
self.assertNotRegexpMatches(excuses, re)
|
||||||
|
|
||||||
with open(os.path.join(self.data.path, 'output', 'excuses.html')) as f:
|
|
||||||
excuses = f.read()
|
|
||||||
self.assertRegexpMatches(excuses, r'\bgreen\b.*>1</a> to .*>1.1~beta<')
|
|
||||||
self.assertIn('<li>autopkgtest for green 1.1~beta: RUNNING', excuses)
|
|
||||||
|
|
||||||
def shell(self):
|
def shell(self):
|
||||||
# uninstallable unstable version
|
# uninstallable unstable version
|
||||||
|
Loading…
x
Reference in New Issue
Block a user