Remove re-import of octavia-lib constants

W0404: Reimport 'constants' (imported line 17) (reimported)

constants was already imported, just use the first one.

Change-Id: I5d999d72cfe55600238c0daaa22766b7fe716e41
This commit is contained in:
Brian Haley
2020-11-19 16:05:05 -05:00
parent 58bf439bda
commit 15a68fd426

View File

@@ -27,7 +27,6 @@ from octavia.db import api as db_api
from octavia.tests.common import constants as c_const from octavia.tests.common import constants as c_const
from octavia.tests.common import sample_certs from octavia.tests.common import sample_certs
from octavia.tests.functional.api.v2 import base from octavia.tests.functional.api.v2 import base
from octavia_lib.common import constants as lib_consts
class TestPool(base.BaseAPITest): class TestPool(base.BaseAPITest):
@@ -1073,7 +1072,7 @@ class TestPool(base.BaseAPITest):
expect_error_msg = ("Validation failure: Cookie names are not " expect_error_msg = ("Validation failure: Cookie names are not "
"supported for %s pools.") % ( "supported for %s pools.") % (
"/".join((constants.PROTOCOL_UDP, "/".join((constants.PROTOCOL_UDP,
lib_consts.PROTOCOL_SCTP))) lib_constants.PROTOCOL_SCTP)))
res = self.post(self.POOLS_PATH, self._build_body(req_dict), res = self.post(self.POOLS_PATH, self._build_body(req_dict),
status=400, expect_errors=True) status=400, expect_errors=True)
self.assertEqual(expect_error_msg, res.json['faultstring']) self.assertEqual(expect_error_msg, res.json['faultstring'])
@@ -1097,7 +1096,7 @@ class TestPool(base.BaseAPITest):
"pools.") % ( "pools.") % (
type, type,
"/".join((constants.PROTOCOL_UDP, "/".join((constants.PROTOCOL_UDP,
lib_consts.PROTOCOL_SCTP))) lib_constants.PROTOCOL_SCTP)))
sp.update({'type': type}) sp.update({'type': type})
req_dict['session_persistence'] = sp req_dict['session_persistence'] = sp
res = self.post(self.POOLS_PATH, self._build_body(req_dict), res = self.post(self.POOLS_PATH, self._build_body(req_dict),
@@ -1124,7 +1123,7 @@ class TestPool(base.BaseAPITest):
"persistence_granularity.") % ( "persistence_granularity.") % (
constants.SESSION_PERSISTENCE_SOURCE_IP, constants.SESSION_PERSISTENCE_SOURCE_IP,
" and ".join((constants.PROTOCOL_UDP, " and ".join((constants.PROTOCOL_UDP,
lib_consts.PROTOCOL_SCTP))) lib_constants.PROTOCOL_SCTP)))
res = self.post(self.POOLS_PATH, self._build_body(req_dict), res = self.post(self.POOLS_PATH, self._build_body(req_dict),
status=400, expect_errors=True) status=400, expect_errors=True)
self.assertEqual(expect_error_msg, res.json['faultstring']) self.assertEqual(expect_error_msg, res.json['faultstring'])
@@ -1146,7 +1145,7 @@ class TestPool(base.BaseAPITest):
"persistence_granularity is only for %s protocol " "persistence_granularity is only for %s protocol "
"pools.") % ( "pools.") % (
" and ".join((constants.PROTOCOL_UDP, " and ".join((constants.PROTOCOL_UDP,
lib_consts.PROTOCOL_SCTP))) lib_constants.PROTOCOL_SCTP)))
for s in sps: for s in sps:
req_dict.update({'session_persistence': s}) req_dict.update({'session_persistence': s})
res = self.post(self.POOLS_PATH, self._build_body(req_dict), res = self.post(self.POOLS_PATH, self._build_body(req_dict),
@@ -1375,7 +1374,7 @@ class TestPool(base.BaseAPITest):
expect_error_msg = ( expect_error_msg = (
"Validation failure: Cookie names are not supported for %s" "Validation failure: Cookie names are not supported for %s"
" pools.") % ("/".join((constants.PROTOCOL_UDP, " pools.") % ("/".join((constants.PROTOCOL_UDP,
lib_consts.PROTOCOL_SCTP))) lib_constants.PROTOCOL_SCTP)))
sess_p['type'] = constants.SESSION_PERSISTENCE_HTTP_COOKIE sess_p['type'] = constants.SESSION_PERSISTENCE_HTTP_COOKIE
sess_p['cookie_name'] = 'test-cookie-name' sess_p['cookie_name'] = 'test-cookie-name'
new_pool = {'session_persistence': sess_p} new_pool = {'session_persistence': sess_p}
@@ -1392,7 +1391,8 @@ class TestPool(base.BaseAPITest):
"only accepts: type, persistence_timeout, " "only accepts: type, persistence_timeout, "
"persistence_granularity.") % ( "persistence_granularity.") % (
constants.SESSION_PERSISTENCE_SOURCE_IP, constants.SESSION_PERSISTENCE_SOURCE_IP,
" and ".join((constants.PROTOCOL_UDP, lib_consts.PROTOCOL_SCTP))) " and ".join((constants.PROTOCOL_UDP,
lib_constants.PROTOCOL_SCTP)))
sess_p['type'] = constants.SESSION_PERSISTENCE_SOURCE_IP sess_p['type'] = constants.SESSION_PERSISTENCE_SOURCE_IP
sess_p['cookie_name'] = 'test-cookie-name' sess_p['cookie_name'] = 'test-cookie-name'
sess_p['persistence_timeout'] = 4 sess_p['persistence_timeout'] = 4
@@ -1413,7 +1413,7 @@ class TestPool(base.BaseAPITest):
"pools.") % ( "pools.") % (
ty, ty,
"/".join((constants.PROTOCOL_UDP, "/".join((constants.PROTOCOL_UDP,
lib_consts.PROTOCOL_SCTP))) lib_constants.PROTOCOL_SCTP)))
sess_p['type'] = ty sess_p['type'] = ty
res = self.put(self.POOL_PATH.format(pool_id=api_pool.get('id')), res = self.put(self.POOL_PATH.format(pool_id=api_pool.get('id')),
self._build_body(new_pool), status=400, self._build_body(new_pool), status=400,
@@ -1845,8 +1845,8 @@ class TestPool(base.BaseAPITest):
self.assertIsNone(update_pool.get('crl_container_ref')) self.assertIsNone(update_pool.get('crl_container_ref'))
def test_update_with_tls_versions(self): def test_update_with_tls_versions(self):
tls_versions = [lib_consts.TLS_VERSION_1_3, tls_versions = [lib_constants.TLS_VERSION_1_3,
lib_consts.TLS_VERSION_1_2] lib_constants.TLS_VERSION_1_2]
api_pool = self.create_pool( api_pool = self.create_pool(
self.lb_id, self.lb_id,
constants.PROTOCOL_HTTP, constants.PROTOCOL_HTTP,
@@ -1859,7 +1859,7 @@ class TestPool(base.BaseAPITest):
self.assertCountEqual(tls_versions, self.assertCountEqual(tls_versions,
api_pool['tls_versions']) api_pool['tls_versions'])
new_pool = {'tls_versions': [lib_consts.TLS_VERSION_1_3]} new_pool = {'tls_versions': [lib_constants.TLS_VERSION_1_3]}
self.put(self.POOL_PATH.format(pool_id=api_pool.get('id')), self.put(self.POOL_PATH.format(pool_id=api_pool.get('id')),
self._build_body(new_pool)) self._build_body(new_pool))
self.assert_correct_status( self.assert_correct_status(
@@ -1871,7 +1871,7 @@ class TestPool(base.BaseAPITest):
self.set_lb_status(self.lb_id) self.set_lb_status(self.lb_id)
response = self.get(self.POOL_PATH.format( response = self.get(self.POOL_PATH.format(
pool_id=api_pool.get('id'))).json.get(self.root_tag) pool_id=api_pool.get('id'))).json.get(self.root_tag)
self.assertCountEqual([lib_consts.TLS_VERSION_1_3], self.assertCountEqual([lib_constants.TLS_VERSION_1_3],
response['tls_versions']) response['tls_versions'])
self.assertIsNotNone(response.get('created_at')) self.assertIsNotNone(response.get('created_at'))
self.assertIsNotNone(response.get('updated_at')) self.assertIsNotNone(response.get('updated_at'))
@@ -1880,13 +1880,13 @@ class TestPool(base.BaseAPITest):
pool_id=response.get('id')) pool_id=response.get('id'))
def test_update_with_empty_tls_versions(self): def test_update_with_empty_tls_versions(self):
default_pool_tls_versions = [lib_consts.TLS_VERSION_1_3, default_pool_tls_versions = [lib_constants.TLS_VERSION_1_3,
lib_consts.TLS_VERSION_1_2] lib_constants.TLS_VERSION_1_2]
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF)) self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
self.conf.config(group='api_settings', self.conf.config(group='api_settings',
default_pool_tls_versions=default_pool_tls_versions) default_pool_tls_versions=default_pool_tls_versions)
tls_versions = [lib_consts.TLS_VERSION_1_3] tls_versions = [lib_constants.TLS_VERSION_1_3]
api_pool = self.create_pool( api_pool = self.create_pool(
self.lb_id, self.lb_id,
constants.PROTOCOL_HTTP, constants.PROTOCOL_HTTP,