diff options
Diffstat (limited to 'trove/tests/scenario')
-rw-r--r-- | trove/tests/scenario/helpers/mysql_helper.py | 2 | ||||
-rw-r--r-- | trove/tests/scenario/helpers/sql_helper.py | 3 | ||||
-rw-r--r-- | trove/tests/scenario/runners/configuration_runners.py | 2 | ||||
-rw-r--r-- | trove/tests/scenario/runners/module_runners.py | 15 | ||||
-rw-r--r-- | trove/tests/scenario/runners/test_runners.py | 17 |
5 files changed, 25 insertions, 14 deletions
diff --git a/trove/tests/scenario/helpers/mysql_helper.py b/trove/tests/scenario/helpers/mysql_helper.py index 7fada681..60f202c6 100644 --- a/trove/tests/scenario/helpers/mysql_helper.py +++ b/trove/tests/scenario/helpers/mysql_helper.py @@ -20,7 +20,7 @@ class MysqlHelper(SqlHelper): def __init__(self, expected_override_name, report): super(MysqlHelper, self).__init__(expected_override_name, report, - 'mysql') + 'mysql+pymysql') def get_helper_credentials(self): return {'name': 'lite', 'password': 'litepass', 'database': 'firstdb'} diff --git a/trove/tests/scenario/helpers/sql_helper.py b/trove/tests/scenario/helpers/sql_helper.py index 325fb03e..a158d963 100644 --- a/trove/tests/scenario/helpers/sql_helper.py +++ b/trove/tests/scenario/helpers/sql_helper.py @@ -27,7 +27,8 @@ class SqlHelper(TestHelper): DATA_COLUMN_NAME = 'value' - def __init__(self, expected_override_name, report, protocol, port=None): + def __init__(self, expected_override_name, report, + protocol="mysql+pymysql", port=None): super(SqlHelper, self).__init__(expected_override_name, report) self.protocol = protocol diff --git a/trove/tests/scenario/runners/configuration_runners.py b/trove/tests/scenario/runners/configuration_runners.py index 40fba068..a2c9c5f5 100644 --- a/trove/tests/scenario/runners/configuration_runners.py +++ b/trove/tests/scenario/runners/configuration_runners.py @@ -144,7 +144,7 @@ class ConfigurationRunner(TestRunner): configuration.has_field('description', six.string_types) configuration.has_field('values', dict) configuration.has_field('datastore_name', six.string_types) - configuration.has_field('datastore_version_id', unicode) + configuration.has_field('datastore_version_id', six.text_type) configuration.has_field('datastore_version_name', six.string_types) self.assert_equal(name, result.name) diff --git a/trove/tests/scenario/runners/module_runners.py b/trove/tests/scenario/runners/module_runners.py index c6483e31..e7806516 100644 --- a/trove/tests/scenario/runners/module_runners.py +++ b/trove/tests/scenario/runners/module_runners.py @@ -17,6 +17,7 @@ import os from proboscis import SkipTest import re +import six import tempfile import time @@ -43,7 +44,7 @@ class ModuleRunner(TestRunner): self.MODULE_BINARY_SUFFIX = '_bin_auto' self.MODULE_BINARY_SUFFIX2 = self.MODULE_BINARY_SUFFIX + '_2' self.MODULE_BINARY_CONTENTS = os.urandom(20) - self.MODULE_BINARY_CONTENTS2 = '\x00\xFF\xea\x9c\x11\xfeok\xb1\x8ax' + self.MODULE_BINARY_CONTENTS2 = b'\x00\xFF\xea\x9c\x11\xfeok\xb1\x8ax' self.module_name_order = [ {'suffix': self.MODULE_BINARY_SUFFIX, @@ -1283,12 +1284,12 @@ class ModuleRunner(TestRunner): if 'contents' in expected and expected['contents']: with open(filename, 'rb') as fh: contents = fh.read() - # convert contents into bytearray to work with py27 - # and py34 - contents = bytes([ord(item) for item in contents]) - expected_contents = bytes( - [ord(item) for item in expected['contents']]) - self.assert_equal(expected_contents, contents, + + expected = expected['contents'] + if isinstance(expected, six.string_types): + expected = expected.encode() + + self.assert_equal(expected, contents, "Unexpected contents for %s" % module_name) finally: diff --git a/trove/tests/scenario/runners/test_runners.py b/trove/tests/scenario/runners/test_runners.py index 58e079a6..43a4fecd 100644 --- a/trove/tests/scenario/runners/test_runners.py +++ b/trove/tests/scenario/runners/test_runners.py @@ -145,7 +145,7 @@ class RunnerFactory(object): # Only fail silently if it's something we expect, # such as a missing override class. Anything else # shouldn't be suppressed. - l_msg = ie.message.lower() + l_msg = str(ie).lower() if (load_type and load_type not in l_msg) or ( 'no module named' not in l_msg and 'cannot be found' not in l_msg): @@ -401,7 +401,16 @@ class TestRunner(object): """Assert that two lists contain same elements (with same multiplicities) ignoring the element order. """ - return cls.assert_equal(sorted(expected), sorted(actual), message) + # Sorts the elements of a given list, including dictionaries. + # For dictionaries sorts based on dictionary key. + # example: + # [1, 3, 2] -> [1, 2, 3] + # ["b", "a", "c"] -> ["a", "b", "c"] + # [{'b':'y'},{'a':'x'}] -> [{'a':'x'},{'b':'y'}] + sort = lambda object: sorted(object, key=lambda e: sorted(e.keys()) + if isinstance(e, dict) else e) + + return cls.assert_equal(sort(expected), sort(actual), message) @classmethod def assert_equal(cls, expected, actual, message=None): @@ -506,7 +515,7 @@ class TestRunner(object): if client: # Make sure that the client_cmd comes from the same client that # was passed in, otherwise asserting the client code may fail. - cmd_clz = client_cmd.im_self + cmd_clz = client_cmd.__self__ cmd_clz_name = cmd_clz.__class__.__name__ client_attrs = [attr[0] for attr in inspect.getmembers( client.real_client) @@ -700,7 +709,7 @@ class TestRunner(object): return False def _poll_while(self, instance_id, expected_status, - sleep_time=1, time_out=None): + sleep_time=1, time_out=0): poll_until(lambda: not self._has_status(instance_id, expected_status), sleep_time=sleep_time, time_out=time_out) |