diff --git a/gapic/schema/metadata.py b/gapic/schema/metadata.py index 0276fe0989..0b1f6df2d5 100644 --- a/gapic/schema/metadata.py +++ b/gapic/schema/metadata.py @@ -115,9 +115,12 @@ def module_alias(self) -> str: return '_'.join( ( ''.join( - i[0] - for i in self.package - if i != self.api_naming.version + [ + partial_name[0] + for i in self.package + for partial_name in i.split("_") + if i != self.api_naming.version + ] ), self.module, ) diff --git a/tests/unit/schema/test_metadata.py b/tests/unit/schema/test_metadata.py index 4be166bc1b..693beffa9b 100644 --- a/tests/unit/schema/test_metadata.py +++ b/tests/unit/schema/test_metadata.py @@ -184,6 +184,14 @@ def test_address_name_builtin_keyword(): ) assert addr_kword.module_alias == "gp_class" + addr_kword = metadata.Address( + name="Class", + module="class", + package=("google", "appengine_admin"), + api_naming=naming.NewNaming(proto_package="foo.bar.baz.v1"), + ) + assert addr_kword.module_alias == "gaa_class" + def test_doc_nothing(): meta = metadata.Metadata()