mirror of
https://github.com/graphql-python/graphene.git
synced 2024-11-22 17:46:57 +03:00
Fixed double underscore converter
This commit is contained in:
parent
f68763b822
commit
20a493b9d1
|
@ -69,8 +69,8 @@ def assert_not_orderable(field):
|
|||
def test_filter_explicit_filterset_arguments():
|
||||
field = DjangoFilterConnectionField(ArticleNode, filterset_class=ArticleFilter)
|
||||
assert_arguments(field,
|
||||
'headline', 'headlineIcontains',
|
||||
'pubDate', 'pubDateGt', 'pubDateLt',
|
||||
'headline', 'headline_Icontains',
|
||||
'pubDate', 'pubDate_Gt', 'pubDate_Lt',
|
||||
'reporter',
|
||||
)
|
||||
|
||||
|
@ -89,7 +89,7 @@ def test_filter_shortcut_filterset_arguments_dict():
|
|||
'reporter': ['exact'],
|
||||
})
|
||||
assert_arguments(field,
|
||||
'headline', 'headlineIcontains',
|
||||
'headline', 'headline_Icontains',
|
||||
'reporter',
|
||||
)
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ def to_camel_case(snake_str):
|
|||
components = snake_str.split('_')
|
||||
# We capitalize the first letter of each component except the first one
|
||||
# with the 'title' method and join them together.
|
||||
return components[0] + "".join(x.title() for x in components[1:])
|
||||
return components[0] + "".join(x.title() if x else '_' for x in components[1:])
|
||||
|
||||
|
||||
# From this response in Stackoverflow
|
||||
|
|
|
@ -4,11 +4,14 @@ from ..str_converters import to_camel_case, to_snake_case
|
|||
def test_snake_case():
|
||||
assert to_snake_case('snakesOnAPlane') == 'snakes_on_a_plane'
|
||||
assert to_snake_case('SnakesOnAPlane') == 'snakes_on_a_plane'
|
||||
assert to_snake_case('SnakesOnA_Plane') == 'snakes_on_a__plane'
|
||||
assert to_snake_case('snakes_on_a_plane') == 'snakes_on_a_plane'
|
||||
assert to_snake_case('snakes_on_a__plane') == 'snakes_on_a__plane'
|
||||
assert to_snake_case('IPhoneHysteria') == 'i_phone_hysteria'
|
||||
assert to_snake_case('iPhoneHysteria') == 'i_phone_hysteria'
|
||||
|
||||
|
||||
def test_camel_case():
|
||||
assert to_camel_case('snakes_on_a_plane') == 'snakesOnAPlane'
|
||||
assert to_camel_case('snakes_on_a__plane') == 'snakesOnA_Plane'
|
||||
assert to_camel_case('i_phone_hysteria') == 'iPhoneHysteria'
|
||||
|
|
Loading…
Reference in New Issue
Block a user