11from uuid import UUID
22
3+ import pytest
4+
35from django_unicorn .call_method_parser import parse_args
46
57
@@ -28,17 +30,43 @@ def test_str_with_space_arg():
2830 assert isinstance (actual [0 ], str )
2931
3032
31- def test_complicated_str_with_space_arg ():
32- expected = ["django's \" ' unicorn" ]
33- actual = parse_args ("django's \" ' unicorn" )
33+ def test_str_with_extra_single_quote ():
34+ expected = ["django's unicorn" ]
35+ actual = parse_args ("'django's unicorn'" )
36+
37+ assert actual == expected
38+ assert isinstance (actual [0 ], str )
39+
40+
41+ def test_str_with_extra_double_quote ():
42+ expected = ['django "unicorn"' ]
43+ actual = parse_args ("'django \" unicorn\" '" )
44+
45+ assert actual == expected
46+ assert isinstance (actual [0 ], str )
47+
48+
49+ @pytest .mark .skip ("These are edge cases, but still are broken" )
50+ def test_str_with_comma ():
51+ expected = ["a', b" ]
52+ actual = parse_args ("'a', b'" )
53+
54+ assert actual == expected
55+ assert isinstance (actual [0 ], str )
56+
57+
58+ @pytest .mark .skip ("These are edge cases, but still are broken" )
59+ def test_str_with_stop_character ():
60+ expected = ["a'} b" ]
61+ actual = parse_args ("'a'} b'" )
3462
3563 assert actual == expected
3664 assert isinstance (actual [0 ], str )
3765
3866
3967def test_double_quote_str_arg ():
40- expected = ["1 " ]
41- actual = parse_args ('"1 "' )
68+ expected = ["string " ]
69+ actual = parse_args ('"string "' )
4270
4371 assert actual == expected
4472 assert isinstance (actual [0 ], str )
@@ -69,12 +97,11 @@ def test_args_with_nested_dict():
6997 assert isinstance (actual [1 ].get ("2" ), dict )
7098
7199
72- def test_args_with_nested_list ():
100+ def test_args_with_nested_list_3 ():
73101 expected = [[1 , ["2" , "3" ], 4 ], 9 ]
74102 actual = parse_args ("[1, ['2', '3'], 4], 9" )
75103
76104 assert actual == expected
77- assert isinstance (actual [0 ][1 ][1 ], str )
78105
79106
80107def test_args_with_nested_tuple ():
@@ -85,8 +112,8 @@ def test_args_with_nested_tuple():
85112
86113
87114def test_args_with_nested_objects ():
88- expected = [[0 , 1 ], {"2" : {"3" : 4 }}, (5 , 6 , [7 , 8 ])]
89- actual = parse_args ("[0,1], {'2': { '3': 4 }}, (5, 6, [7, 8])" )
115+ expected = [[0 , 1 ], {"2 2 " : {"3" : 4 }}, (5 , 6 , [7 , 8 ])]
116+ actual = parse_args ("[0, 1], {'2 2': { '3': 4 }}, (5, 6, [7, 8])" )
90117
91118 assert actual == expected
92119
0 commit comments