def old_transform(node_is_active): return 'active' if node_is_active else 'inactive' return get_sysnode_info_from(node_info_rows, old_transform) def new_sysnode_processor(node_info_rows): return get_sysnode_info_from(node_info_rows, lambda x: x) NODE_INFO_PER_URI_SQL = VersionRangeList( VersionRange( (0, 0), (0, 128), ('select http_uri, node_version, active from ' 'system.runtime.nodes where ' 'url_extract_host(http_uri) = \'%s\'', old_sysnode_processor)), VersionRange( (0, 128), (sys.maxsize, ), ('select http_uri, node_version, state from ' 'system.runtime.nodes where ' 'url_extract_host(http_uri) = \'%s\'', new_sysnode_processor))) EXTERNAL_IP_SQL = 'select url_extract_host(http_uri) from ' \ 'system.runtime.nodes WHERE node_id = \'%s\'' CATALOG_INFO_SQL = 'select catalog_name from system.metadata.catalogs' _LOGGER = logging.getLogger(__name__) DOWNLOAD_DIRECTORY = '/tmp' DEFAULT_RPM_NAME = 'presto-server-rpm.rpm' LATEST_RPM_URL = 'https://repository.sonatype.org/service/local/artifact/maven' \ '/content?r=central-proxy&g=com.facebook.presto' \
def test_valid_2_length_list(self): vl = VersionRangeList( VersionRange((0,), (1, 0), '0'), VersionRange((1, 0), (2, 0), '1')) self.assertEqual('0', vl.for_version((0, 5))) self.assertEqual('1', vl.for_version((1, 5)))
def test_1_length_list(self): vl = VersionRangeList( VersionRange((0,), (1, 0))) self.assertIsNone(vl.for_version((0, 5)))
def test_valid_2_length_list(self): vl = VersionRangeList(VersionRange((0, ), (1, 0), '0'), VersionRange((1, 0), (2, 0), '1')) self.assertEqual('0', vl.for_version((0, 5))) self.assertEqual('1', vl.for_version((1, 5)))
def test_1_length_list(self): vl = VersionRangeList(VersionRange((0, ), (1, 0))) self.assertIsNone(vl.for_version((0, 5)))
def test_0_length_list(self): vl = VersionRangeList() self.assertRaises(KeyError, vl.for_version, (1, 0))