Skip to content

Commit

Permalink
rm failing _extract_name method from vpc (#497)
Browse files Browse the repository at this point in the history
rm failing _extract_name method from vpc

Epmon failing, fixed name extraction for empty url

Reviewed-by: Vladimir Hasko <[email protected]>
  • Loading branch information
anton-sidelnikov authored Nov 25, 2024
1 parent bfd2621 commit 4c0a4fc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
12 changes: 5 additions & 7 deletions otcextensions/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,11 @@ def extract_url_parts(url: str, project_id: str) -> list:
url_parts = [x for x in path.split('/') if x != project_id]

# Exclude parts that are version identifiers
url_parts = list(
filter(
lambda x: not any(
c.isdigit() for c in x[1:]) and (x[0].lower() != 'v'),
url_parts
)
)
url_parts = list(filter(
lambda x: len(x) > 0 and not
(x.lower().startswith('v') and x[1:].isdigit()),
url_parts
))

# Strip out empty or None segments and return
return [part for part in url_parts if part]
14 changes: 14 additions & 0 deletions otcextensions/tests/unit/sdk/vpc/v1/test_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,3 +235,17 @@ def test_subnet_delete(self):
'ignore_missing': True,
'base_path': subnet.vpc_subnet_base_path('vpc'),
})


class TestExtractName(TestVpcProxy):

def test_extract_name(self):
self.assertEqual(
['vpcs'],
self.proxy._extract_name('/v1/123/vpcs', project_id='123')
)
self.assertEqual(
[],
self.proxy._extract_name(
'/', project_id='123')
)

0 comments on commit 4c0a4fc

Please sign in to comment.