typing: Resolve incompatible operand issues
Change-Id: I7f3dd908053b9ace5206d0a1bd3b8258fd0264ef Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
parent
e28046cc19
commit
9de592ebaf
@ -77,8 +77,7 @@ class CreateLimit(command.ShowOne):
|
||||
)
|
||||
region = None
|
||||
if parsed_args.region:
|
||||
val = getattr(parsed_args, 'region', None)
|
||||
if 'None' not in val:
|
||||
if 'None' not in parsed_args.region:
|
||||
# NOTE (vishakha): Due to bug #1799153 and for any another
|
||||
# related case where GET resource API does not support the
|
||||
# filter by name, osc_lib.utils.find_resource() method cannot
|
||||
@ -149,11 +148,7 @@ class ListLimit(command.Lister):
|
||||
)
|
||||
region = None
|
||||
if parsed_args.region:
|
||||
region = utils.find_resource(
|
||||
identity_client.regions, parsed_args.region
|
||||
)
|
||||
val = getattr(parsed_args, 'region', None)
|
||||
if 'None' not in val:
|
||||
if 'None' not in parsed_args.region:
|
||||
# NOTE (vishakha): Due to bug #1799153 and for any another
|
||||
# related case where GET resource API does not support the
|
||||
# filter by name, osc_lib.utils.find_resource() method cannot
|
||||
|
@ -68,8 +68,7 @@ class CreateRegisteredLimit(command.ShowOne):
|
||||
)
|
||||
region = None
|
||||
if parsed_args.region:
|
||||
val = getattr(parsed_args, 'region', None)
|
||||
if 'None' not in val:
|
||||
if 'None' not in parsed_args.region:
|
||||
# NOTE (vishakha): Due to bug #1799153 and for any another
|
||||
# related case where GET resource API does not support the
|
||||
# filter by name, osc_lib.utils.find_resource() method cannot
|
||||
@ -175,8 +174,7 @@ class ListRegisteredLimit(command.Lister):
|
||||
)
|
||||
region = None
|
||||
if parsed_args.region:
|
||||
val = getattr(parsed_args, 'region', None)
|
||||
if 'None' not in val:
|
||||
if 'None' not in parsed_args.region:
|
||||
# NOTE (vishakha): Due to bug #1799153 and for any another
|
||||
# related case where GET resource API does not support the
|
||||
# filter by name, osc_lib.utils.find_resource() method cannot
|
||||
@ -280,8 +278,7 @@ class SetRegisteredLimit(command.ShowOne):
|
||||
|
||||
region = None
|
||||
if parsed_args.region:
|
||||
val = getattr(parsed_args, 'region', None)
|
||||
if 'None' not in val:
|
||||
if 'None' not in parsed_args.region:
|
||||
# NOTE (vishakha): Due to bug #1799153 and for any another
|
||||
# related case where GET resource API does not support the
|
||||
# filter by name, osc_lib.utils.find_resource() method cannot
|
||||
|
@ -17,6 +17,7 @@ import argparse
|
||||
import copy
|
||||
import json
|
||||
import logging
|
||||
import typing as ty
|
||||
|
||||
from cliff import columns as cliff_columns
|
||||
from osc_lib.cli import format_columns
|
||||
@ -39,6 +40,8 @@ class AdminStateColumn(cliff_columns.FormattableColumn):
|
||||
|
||||
|
||||
class SubPortColumn(format_columns.ListDictColumn):
|
||||
_value: ty.Any
|
||||
|
||||
def _retrieve_subports(self):
|
||||
if isinstance(self._value, dict):
|
||||
self._value = self._value['sub_ports']
|
||||
|
@ -25,7 +25,7 @@ class QuotaTests(base.TestCase):
|
||||
test runs as these may run in parallel and otherwise step on each other.
|
||||
"""
|
||||
|
||||
PROJECT_NAME = None
|
||||
PROJECT_NAME: str
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
|
@ -22,9 +22,9 @@ from openstackclient.tests.functional import base
|
||||
class ComputeTestCase(base.TestCase):
|
||||
"""Common functional test bits for Compute commands"""
|
||||
|
||||
flavor_name = None
|
||||
image_name = None
|
||||
network_arg = None
|
||||
flavor_name: str
|
||||
image_name: str
|
||||
network_arg: str
|
||||
|
||||
def setUp(self):
|
||||
"""Select common resources"""
|
||||
@ -34,7 +34,7 @@ class ComputeTestCase(base.TestCase):
|
||||
self.network_arg = self.get_network()
|
||||
|
||||
@classmethod
|
||||
def get_flavor(cls):
|
||||
def get_flavor(cls) -> str:
|
||||
# NOTE(rtheis): Get cirros256 or m1.tiny flavors since functional
|
||||
# tests may create other flavors.
|
||||
flavors = cls.openstack("flavor list", parse_output=True)
|
||||
@ -43,10 +43,13 @@ class ComputeTestCase(base.TestCase):
|
||||
if flavor['Name'] in ['m1.tiny', 'cirros256']:
|
||||
server_flavor = flavor['Name']
|
||||
break
|
||||
|
||||
assert server_flavor is not None
|
||||
|
||||
return server_flavor
|
||||
|
||||
@classmethod
|
||||
def get_image(cls):
|
||||
def get_image(cls) -> str:
|
||||
# NOTE(rtheis): Get first Cirros image since functional tests may
|
||||
# create other images. Image may be named '-uec' or
|
||||
# '-disk'.
|
||||
@ -59,10 +62,13 @@ class ComputeTestCase(base.TestCase):
|
||||
):
|
||||
server_image = image['Name']
|
||||
break
|
||||
|
||||
assert server_image is not None
|
||||
|
||||
return server_image
|
||||
|
||||
@classmethod
|
||||
def get_network(cls):
|
||||
def get_network(cls) -> str:
|
||||
try:
|
||||
# NOTE(rtheis): Get private network since functional tests may
|
||||
# create other networks.
|
||||
|
@ -75,6 +75,10 @@ class AddressGroupTests(common.NetworkTests):
|
||||
self.assertNotEqual(admin_project_id, demo_project_id)
|
||||
self.assertEqual(admin_project_id, auth_project_id)
|
||||
|
||||
# type narrow
|
||||
assert admin_project_id is not None
|
||||
assert demo_project_id is not None
|
||||
|
||||
name1 = uuid.uuid4().hex
|
||||
cmd_output = self.openstack(
|
||||
'address group create ' + name1,
|
||||
|
@ -94,9 +94,14 @@ class L3ConntrackHelperTests(common.NetworkTests):
|
||||
self.assertIn(ct, expected_helpers)
|
||||
|
||||
def test_l3_conntrack_helper_set_and_show(self):
|
||||
helper = {'helper': 'tftp', 'protocol': 'udp', 'port': 69}
|
||||
helper = 'tftp'
|
||||
proto = 'udp'
|
||||
port = 69
|
||||
router_id = self._create_router()
|
||||
created_helper = self._create_helpers(router_id, [helper])[0]
|
||||
created_helper = self._create_helpers(
|
||||
router_id,
|
||||
[{'helper': helper, 'protocol': proto, 'port': port}],
|
||||
)[0]
|
||||
output = self.openstack(
|
||||
'network l3 conntrack helper show {router_id} {ct_id} '
|
||||
'-f json'.format(
|
||||
@ -105,16 +110,16 @@ class L3ConntrackHelperTests(common.NetworkTests):
|
||||
),
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(helper['helper'], output['helper'])
|
||||
self.assertEqual(helper['protocol'], output['protocol'])
|
||||
self.assertEqual(helper['port'], output['port'])
|
||||
self.assertEqual(port, output['port'])
|
||||
self.assertEqual(helper, output['helper'])
|
||||
self.assertEqual(proto, output['protocol'])
|
||||
|
||||
raw_output = self.openstack(
|
||||
'network l3 conntrack helper set {router_id} {ct_id} '
|
||||
'--port {port} '.format(
|
||||
router_id=router_id,
|
||||
ct_id=created_helper['id'],
|
||||
port=helper['port'] + 1,
|
||||
port=port + 1,
|
||||
)
|
||||
)
|
||||
self.assertOutput('', raw_output)
|
||||
@ -127,6 +132,6 @@ class L3ConntrackHelperTests(common.NetworkTests):
|
||||
),
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(helper['port'] + 1, output['port'])
|
||||
self.assertEqual(helper['helper'], output['helper'])
|
||||
self.assertEqual(helper['protocol'], output['protocol'])
|
||||
self.assertEqual(port + 1, output['port'])
|
||||
self.assertEqual(helper, output['helper'])
|
||||
self.assertEqual(proto, output['protocol'])
|
||||
|
@ -77,6 +77,10 @@ class LocalIPTests(common.NetworkTests):
|
||||
self.assertNotEqual(admin_project_id, demo_project_id)
|
||||
self.assertEqual(admin_project_id, auth_project_id)
|
||||
|
||||
# type narrow
|
||||
assert admin_project_id is not None
|
||||
assert demo_project_id is not None
|
||||
|
||||
name1 = uuid.uuid4().hex
|
||||
cmd_output = self.openstack(
|
||||
'local ip create ' + name1,
|
||||
|
@ -22,8 +22,8 @@ from openstackclient.tests.functional.network.v2 import common
|
||||
class TestMeterRule(common.NetworkTests):
|
||||
"""Functional tests for meter rule"""
|
||||
|
||||
METER_ID = None
|
||||
METER_RULE_ID = None
|
||||
METER_ID: str
|
||||
METER_RULE_ID: str
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
|
@ -18,8 +18,8 @@ from openstackclient.tests.functional.network.v2 import common
|
||||
class NetworkRBACTests(common.NetworkTests):
|
||||
"""Functional tests for network rbac"""
|
||||
|
||||
OBJECT_ID = None
|
||||
ID = None
|
||||
OBJECT_ID: str
|
||||
ID: str
|
||||
HEADERS = ['ID']
|
||||
FIELDS = ['id']
|
||||
|
||||
|
@ -106,6 +106,10 @@ class RouterTests(common.NetworkTagTests):
|
||||
self.assertNotEqual(admin_project_id, demo_project_id)
|
||||
self.assertEqual(admin_project_id, auth_project_id)
|
||||
|
||||
# type narrow
|
||||
assert admin_project_id is not None
|
||||
assert demo_project_id is not None
|
||||
|
||||
name1 = uuid.uuid4().hex
|
||||
name2 = uuid.uuid4().hex
|
||||
cmd_output = self.openstack(
|
||||
|
@ -63,6 +63,10 @@ class SubnetPoolTests(common.NetworkTagTests):
|
||||
self.assertNotEqual(admin_project_id, demo_project_id)
|
||||
self.assertEqual(admin_project_id, auth_project_id)
|
||||
|
||||
# type narrow
|
||||
assert admin_project_id is not None
|
||||
assert demo_project_id is not None
|
||||
|
||||
name1 = uuid.uuid4().hex
|
||||
name2 = uuid.uuid4().hex
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user