Coverage for class_generator/tests/test_camelcase_to_snake.py: 100%

5 statements  

« prev     ^ index     » next       coverage.py v7.6.10, created at 2025-01-30 10:45 +0200

1import pytest 

2 

3from class_generator.class_generator import ( 

4 convert_camel_case_to_snake_case, 

5) 

6 

7 

8@pytest.mark.parametrize( 

9 "camel_case_str, expected", 

10 [ 

11 pytest.param("Title", "title", id="title_word"), 

12 pytest.param("tolerations", "tolerations", id="lowercase_word"), 

13 pytest.param("UPPERCASEWORD", "uppercaseword", id="uppercase_word"), 

14 pytest.param("ipFamilies", "ip_families", id="combined_basic_with_two_words"), 

15 pytest.param( 

16 "allocateLoadBalancerNodePorts", 

17 "allocate_load_balancer_node_ports", 

18 id="combined_basic_with_multiple_words", 

19 ), 

20 pytest.param("XMLHttpRequest", "xml_http_request", id="combined_uppercase_word_is_first"), 

21 pytest.param( 

22 "additionalCORSAllowedOS", 

23 "additional_cors_allowed_os", 

24 id="combined_uppercase_word_in_the_middle", 

25 ), 

26 pytest.param("hostIPC", "host_ipc", id="combined_uppercase_word_is_last"), 

27 pytest.param( 

28 "clusterIPs", 

29 "cluster_ips", 

30 id="combined_uppercase_word_is_last_ends_with_one_lowercase_char", 

31 ), 

32 pytest.param( 

33 "dataVolumeTTLSeconds", 

34 "data_volume_ttl_seconds", 

35 id="combined_uppercase_word_followed_by_uppercase_word_is_last_ends_with_lowercase", 

36 ), 

37 ], 

38) 

39def test_convert_camel_case_to_snake_case(camel_case_str, expected): 

40 assert convert_camel_case_to_snake_case(string_=camel_case_str) == expected