33
44import pytest
55
6- from django_unicorn .call_method_parser import eval_arg
6+ from django_unicorn .call_method_parser import eval_value
77
88
99def test_args ():
1010 expected = (1 , 2 )
11- actual = eval_arg ("1, 2" )
11+ actual = eval_value ("1, 2" )
1212
1313 assert actual == expected
1414 assert isinstance (actual [0 ], int )
@@ -17,79 +17,79 @@ def test_args():
1717
1818def test_single_quote_str_arg ():
1919 expected = "1"
20- actual = eval_arg ("'1'" )
20+ actual = eval_value ("'1'" )
2121
2222 assert actual == expected
2323 assert isinstance (actual , str )
2424
2525
2626def test_str_with_space_arg ():
2727 expected = "django unicorn"
28- actual = eval_arg ("'django unicorn'" )
28+ actual = eval_value ("'django unicorn'" )
2929
3030 assert actual == expected
3131 assert isinstance (actual , str )
3232
3333
3434def test_str_with_extra_single_quote ():
3535 expected = "django's unicorn"
36- actual = eval_arg ("'django\\ 's unicorn'" )
36+ actual = eval_value ("'django\\ 's unicorn'" )
3737
3838 assert actual == expected
3939 assert isinstance (actual , str )
4040
4141
4242def test_str_with_extra_double_quote ():
4343 expected = 'django "unicorn"'
44- actual = eval_arg ("'django \" unicorn\" '" )
44+ actual = eval_value ("'django \" unicorn\" '" )
4545
4646 assert actual == expected
4747 assert isinstance (actual [0 ], str )
4848
4949
5050def test_str_with_comma ():
5151 expected = "'a', b'"
52- actual = eval_arg ("'a', b'" )
52+ actual = eval_value ("'a', b'" )
5353
5454 assert actual == expected
5555 assert isinstance (actual [0 ], str )
5656
5757
5858def test_str_with_stop_character ():
5959 expected = "'a'} b'"
60- actual = eval_arg ("'a'} b'" )
60+ actual = eval_value ("'a'} b'" )
6161
6262 assert actual == expected
6363 assert isinstance (actual [0 ], str )
6464
6565
6666def test_double_quote_str_arg ():
6767 expected = "string"
68- actual = eval_arg ('"string"' )
68+ actual = eval_value ('"string"' )
6969
7070 assert actual == expected
7171 assert isinstance (actual , str )
7272
7373
7474def test_args_with_single_quote_dict ():
7575 expected = (1 , {"2" : 3 })
76- actual = eval_arg ("1, {'2': 3}" )
76+ actual = eval_value ("1, {'2': 3}" )
7777
7878 assert actual == expected
7979 assert isinstance (actual [1 ], dict )
8080
8181
8282def test_args_with_double_quote_dict ():
8383 expected = (1 , {"2" : 3 })
84- actual = eval_arg ('1, {"2": 3}' )
84+ actual = eval_value ('1, {"2": 3}' )
8585
8686 assert actual == expected
8787 assert isinstance (actual [1 ], dict )
8888
8989
9090def test_args_with_nested_dict ():
9191 expected = (1 , {"2" : {"3" : 4 }})
92- actual = eval_arg ("1, {'2': { '3': 4 }}" )
92+ actual = eval_value ("1, {'2': { '3': 4 }}" )
9393
9494 assert actual == expected
9595 assert isinstance (actual [1 ], dict )
@@ -98,59 +98,59 @@ def test_args_with_nested_dict():
9898
9999def test_args_with_nested_list_3 ():
100100 expected = ([1 , ["2" , "3" ], 4 ], 9 )
101- actual = eval_arg ("[1, ['2', '3'], 4], 9" )
101+ actual = eval_value ("[1, ['2', '3'], 4], 9" )
102102
103103 assert actual == expected
104104
105105
106106def test_args_with_nested_tuple ():
107107 expected = (9 , (1 , ("2" , "3" ), 4 ))
108- actual = eval_arg ("9, (1, ('2', '3'), 4)" )
108+ actual = eval_value ("9, (1, ('2', '3'), 4)" )
109109
110110 assert actual == expected
111111
112112
113113def test_args_with_nested_objects ():
114114 expected = ([0 , 1 ], {"2 2" : {"3" : 4 }}, (5 , 6 , [7 , 8 ]))
115- actual = eval_arg ("[0, 1], {'2 2': { '3': 4 }}, (5, 6, [7, 8])" )
115+ actual = eval_value ("[0, 1], {'2 2': { '3': 4 }}, (5, 6, [7, 8])" )
116116
117117 assert actual == expected
118118
119119
120120def test_list_args ():
121121 expected = (1 , [2 , "3" ])
122- actual = eval_arg ("1, [2, '3']" )
122+ actual = eval_value ("1, [2, '3']" )
123123
124124 assert actual == expected
125125
126126
127127def test_datetime ():
128128 expected = datetime (2020 , 9 , 12 , 1 , 1 , 1 )
129- actual = eval_arg ("2020-09-12T01:01:01" )
129+ actual = eval_value ("2020-09-12T01:01:01" )
130130
131131 assert actual == expected
132132 assert isinstance (actual , datetime )
133133
134134
135135def test_uuid ():
136136 expected = UUID ("90144cb9-fc47-476d-b124-d543b0cff091" )
137- actual = eval_arg ("90144cb9-fc47-476d-b124-d543b0cff091" )
137+ actual = eval_value ("90144cb9-fc47-476d-b124-d543b0cff091" )
138138
139139 assert actual == expected
140140 assert isinstance (actual , UUID )
141141
142142
143143def test_float ():
144144 expected = [1 , 5.4 ]
145- actual = eval_arg ("[1, 5.4]" )
145+ actual = eval_value ("[1, 5.4]" )
146146
147147 assert actual == expected
148148 assert isinstance (actual [1 ], float )
149149
150150
151151def test_set ():
152152 expected = {1 , 5 }
153- actual = eval_arg ("{1, 5}" )
153+ actual = eval_value ("{1, 5}" )
154154
155155 assert actual == expected
156156 assert isinstance (actual , set )
0 commit comments