Skip to content

Commit

Permalink
add func test
Browse files Browse the repository at this point in the history
  • Loading branch information
Polina-Gubina committed Oct 20, 2021
1 parent bf2311d commit 243d60d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
15 changes: 7 additions & 8 deletions octavia_proxy/api/v2/controllers/load_balancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from octavia_proxy.api.v2.controllers import base, pool as pool_controller,\
listener as li_controller
from octavia_proxy.api.v2.types import load_balancer as lb_types
from octavia_proxy.common import constants, validate, utils
from octavia_proxy.common import constants, validate
from octavia_proxy.common import exceptions
from octavia_proxy.i18n import _

Expand Down Expand Up @@ -310,13 +310,12 @@ def _graph_create(self, session, lb, pools, listeners):
if listeners:
for li in listeners:
default_pool = li.default_pool
pool_name = (
default_pool.name if default_pool else None)
if default_pool and not pool_name:
raise exceptions.ValidationException(
detail='Pools must be named when creating a fully '
'populated loadbalancer.')
pools.append(default_pool)
if not isinstance(default_pool, wtypes.UnsetType):
if not default_pool.name:
raise exceptions.ValidationException(
detail='Pools must be named when creating a fully '
'populated loadbalancer.')
pools.append(default_pool)

for p in pools:
members = p.members
Expand Down
16 changes: 16 additions & 0 deletions octavia_proxy/tests/functional/api/v2/test_load_balancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,22 @@ def test_create_with_tags(self, **optionals):
self._assert_request_matches_response(lb_json, self.api_lb)
self.delete(self.LB_PATH.format(lb_id=self.api_lb.get('id')))

def test_complex_create_v2_0(self, **optionals):
lb_json = {'name': 'test2',
'vip_subnet_id': self._network['subnet_id'],
'project_id': self.project_id,
"listeners": [{"name": "fav_listener", "protocol": "HTTP",
"protocol_port": "483"}]
}
lb_json.update(optionals)
body = self._build_body(lb_json)
response = self.post(self.LBS_PATH, body, use_v2_0=True)
self.api_lb = response.json.get(self.root_tag)
listeners = self.api_lb['listeners']
self.assertTrue(listeners)
self.delete(self.LB_PATH.format(lb_id=self.api_lb.get('id'),
cascade=True))

def test_create_without_vip(self):
lb_json = {'name': 'test1',
'project_id': self.project_id}
Expand Down

0 comments on commit 243d60d

Please sign in to comment.