Update tests for Python 2.6

Signed-off-by: Ondrej Nosek <onosek@redhat.com>
This commit is contained in:
Ondrej Nosek 2018-03-29 16:34:52 +02:00
parent f3b5a66614
commit 1f0739831c
7 changed files with 35 additions and 21 deletions

View File

@ -17,7 +17,6 @@ from __future__ import print_function
import os
import copy
import lxml.etree
from functools import total_ordering
def get_variants_dtd(logger=None):
@ -207,7 +206,6 @@ class VariantsXmlParser(object):
return result
@total_ordering
class Variant(object):
def __init__(self, id, name, type, arches, groups, environments=None,
buildinstallpackages=None, is_empty=False, parent=None,
@ -257,6 +255,15 @@ class Variant(object):
ORDERING = {'variant': 0, 'addon': 1, 'layered-product': 1, 'optional': 2}
return (ORDERING[self.type], self.uid) < (ORDERING[other.type], other.uid)
def __le__(self, other):
return self < other or self == other
def __gt__(self, other):
return not (self <= other)
def __ge__(self, other):
return not (self < other)
def __hash__(self):
return hash((self.type, self.uid))

View File

@ -1,4 +1,7 @@
import mock
try:
import unittest2 as unittest
except ImportError:
import unittest
import six

View File

@ -37,15 +37,15 @@ class CompsWrapperTest(unittest.TestCase):
def test_get_groups(self):
comps = CompsWrapper(COMPS_FILE)
self.assertItemsEqual(
comps.get_comps_groups(),
['core', 'standard', 'text-internet', 'firefox', 'resilient-storage', 'basic-desktop'])
self.assertEqual(
sorted(comps.get_comps_groups()),
sorted(['core', 'standard', 'text-internet', 'firefox', 'resilient-storage', 'basic-desktop']))
def test_get_packages(self):
comps = CompsWrapper(COMPS_FILE)
self.assertItemsEqual(
comps.get_packages('text-internet'),
{'dummy-elinks', 'dummy-tftp'})
self.assertEqual(
sorted(comps.get_packages('text-internet')),
sorted(['dummy-elinks', 'dummy-tftp']))
def test_get_packages_for_non_existing_group(self):
comps = CompsWrapper(COMPS_FILE)

View File

@ -1,9 +1,13 @@
# -*- coding: utf-8 -*-
try:
import unittest2 as unittest
except ImportError:
import unittest
import mock
import os
import sys
import unittest
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))

View File

@ -3,7 +3,7 @@
import mock
import os
import sys
import unittest
import unittest2 as unittest
import itertools
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
@ -36,11 +36,11 @@ class TestIsoUtils(unittest.TestCase):
def test_get_implanted_md5_incorrect(self, mock_run):
mock_run.return_value = (0, INCORRECT_OUTPUT)
logger = mock.Mock()
self.assertIsNone(iso.get_implanted_md5('dummy.iso', logger=logger))
self.assertEqual(iso.get_implanted_md5('dummy.iso', logger=logger), None)
self.assertEqual(mock_run.call_args_list,
[mock.call(['/usr/bin/checkisomd5', '--md5sumonly', 'dummy.iso'],
universal_newlines=True)])
self.assertGreater(len(logger.mock_calls), 0)
self.assertTrue(len(logger.mock_calls) > 0)
@mock.patch('pungi.util.run_unmount_cmd')
@mock.patch('pungi.wrappers.iso.run')

View File

@ -92,7 +92,7 @@ class TestNotifier(unittest.TestCase):
n.send('cmd', **self.data)
makedirs.assert_called_once_with('/logs/notifications')
self.assertItemsEqual(run.call_args_list, [self._call('run-notify', 'cmd')])
self.assertEqual(run.call_args_list, [self._call('run-notify', 'cmd')])
@mock.patch('pungi.util.translate_path')
@mock.patch('kobo.shortcuts.run')
@ -104,10 +104,10 @@ class TestNotifier(unittest.TestCase):
n.compose = self.compose
n.send('cmd', **self.data)
self.assertItemsEqual(
run.call_args_list,
[self._call('run-notify', 'cmd'),
self._call('ping-user', 'cmd')])
self.assertEqual(
sorted(run.call_args_list),
sorted([self._call('run-notify', 'cmd'),
self._call('ping-user', 'cmd')]))
@mock.patch('kobo.shortcuts.run')
def test_translates_path(self, run, makedirs):
@ -120,7 +120,7 @@ class TestNotifier(unittest.TestCase):
n.compose = self.compose
n.send('cmd', **self.data)
self.assertItemsEqual(
self.assertEqual(
run.call_args_list,
[self._call('run-notify', 'cmd', location='http://example.com/compose/a/b')])
@ -140,7 +140,7 @@ class TestNotifier(unittest.TestCase):
n.compose = self.compose
n.send('cmd', **self.data)
self.assertItemsEqual(run.call_args_list, [self._call('run-notify', 'cmd')])
self.assertEqual(run.call_args_list, [self._call('run-notify', 'cmd')])
self.assertTrue(self.compose.log_warning.called)

View File

@ -4,7 +4,7 @@
import mock
import os
import sys
import unittest
import unittest2 as unittest
import json
import re