Add UT for unsupported operators

This commit is contained in:
Bo Maryniuk 2017-05-24 16:27:50 +02:00
parent c0abef6879
commit 22732504a3

View File

@ -1071,3 +1071,22 @@ Repository 'DUMMY' not found by its alias, number, or URI.
# Auto-fix feature: moves operator from end to front
for op in zypper.Wildcard.Z_OP:
assert zypper.Wildcard(_zpr)('libzypp', '16*{0}'.format(op)) == '{0}16.2.5-25.1'.format(op)
def test_wildcard_to_query_unsupported_operators(self):
'''
Test wildcard to query unsupported operators.
:return:
'''
xmldoc = """<?xml version='1.0'?><stream>
<search-result version="0.0"><solvable-list>
<solvable status="installed" name="libzypp" kind="package" edition="16.2.4-19.5" arch="x86_64" repository="foo"/>
<solvable status="other-version" name="libzypp" kind="package" edition="16.2.5-25.1" arch="x86_64" repository="foo"/>
<solvable status="other-version" name="libzypp" kind="package" edition="17.2.6-27.9.1" arch="x86_64" repository="foo"/>
</solvable-list></search-result></stream>
"""
_zpr = MagicMock()
_zpr.nolock.xml.call = MagicMock(return_value=minidom.parseString(xmldoc))
with self.assertRaises(CommandExecutionError):
for op in ['>>', '==', '<<', '+']:
zypper.Wildcard(_zpr)('libzypp', '{0}*.1'.format(op))