1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-11-11 07:06:16 +01:00
github.com_openSUSE_osc/tests/test_results.py

57 lines
2.3 KiB
Python
Raw Normal View History

2018-11-05 22:51:23 +01:00
import os
import sys
import osc.commandline
from .common import GET, OscTestCase
2018-11-05 22:51:23 +01:00
def suite():
import unittest
return unittest.defaultTestLoader.loadTestsFromTestCase(TestResults)
2018-11-05 22:51:23 +01:00
class TestResults(OscTestCase):
def setUp(self):
super().setUp(copytree=False)
2018-11-05 22:51:23 +01:00
def _get_fixtures_name(self):
return 'results_fixtures'
def _get_fixtures_dir(self):
return os.path.join(os.path.dirname(__file__), self._get_fixtures_name())
def _run_osc(self, *args):
"""Runs osc, returning captured STDOUT as a string."""
cli = osc.commandline.Osc()
argv = ['osc', '--no-keyring']
2018-11-05 22:51:23 +01:00
argv.extend(args)
cli.main(argv=argv)
return sys.stdout.getvalue()
@GET('http://localhost/build/testproject/_result', file='result.xml')
def testPrjresults(self):
out = self._run_osc('prjresults', '--xml', 'testproject')
self.assertEqualMultiline(out, self._get_fixture('result.xml')+'\n')
@GET('http://localhost/build/testproject/_result', file='result-dirty.xml')
@GET('http://localhost/build/testproject/_result?oldstate=c57e2ee592dbbf26ebf19cc4f1bc1e83', file='result.xml')
def testPrjresultsWatch(self):
out = self._run_osc('prjresults', '--watch', '--xml', 'testproject')
self.assertEqualMultiline(out, self._get_fixture('result-dirty.xml')+'\n'+self._get_fixture('result.xml')+'\n')
2018-11-05 22:51:23 +01:00
@GET('http://localhost/build/testproject/_result?package=python-MarkupSafe&multibuild=1&locallink=1', file='result.xml')
def testResults(self):
out = self._run_osc('results', '--xml', 'testproject', 'python-MarkupSafe')
self.assertEqualMultiline(out, self._get_fixture('result.xml'))
@GET('http://localhost/build/testproject/_result?package=python-MarkupSafe&multibuild=1&locallink=1', file='result-dirty.xml')
@GET('http://localhost/build/testproject/_result?package=python-MarkupSafe&oldstate=c57e2ee592dbbf26ebf19cc4f1bc1e83&multibuild=1&locallink=1', file='result.xml')
def testResultsWatch(self):
out = self._run_osc('results', '--watch', '--xml', 'testproject', 'python-MarkupSafe')
self.assertEqualMultiline(out, self._get_fixture('result-dirty.xml')+self._get_fixture('result.xml'))
if __name__ == '__main__':
import unittest
unittest.main()