1616"""
1717C7N Type Adapter Test Cases.
1818"""
19+
1920import datetime
2021
2122import celpy .adapter
@@ -28,30 +29,32 @@ def test_json_to_cel():
2829 assert str (celpy .adapter .json_to_cel (False )) == str (celpy .celtypes .BoolType (False ))
2930 assert celpy .adapter .json_to_cel (2.5 ) == celpy .celtypes .DoubleType (2.5 )
3031 assert celpy .adapter .json_to_cel (42 ) == celpy .celtypes .IntType (42 )
31- assert celpy .adapter .json_to_cel ("Hello, world!" ) == celpy .celtypes .StringType ("Hello, world!" )
32+ assert celpy .adapter .json_to_cel ("Hello, world!" ) == celpy .celtypes .StringType (
33+ "Hello, world!"
34+ )
3235 assert celpy .adapter .json_to_cel (None ) is None
3336 assert celpy .adapter .json_to_cel (["Hello" , "world!" ]) == celpy .celtypes .ListType (
3437 [
3538 celpy .celtypes .StringType ("Hello" ),
3639 celpy .celtypes .StringType ("world!" ),
3740 ]
3841 )
39- assert celpy .adapter .json_to_cel (tuple (["Hello" , "world!" ])) == celpy .celtypes .ListType (
42+ assert celpy .adapter .json_to_cel (
43+ tuple (["Hello" , "world!" ])
44+ ) == celpy .celtypes .ListType (
4045 [
4146 celpy .celtypes .StringType ("Hello" ),
4247 celpy .celtypes .StringType ("world!" ),
4348 ]
4449 )
4550 assert celpy .adapter .json_to_cel ({"Hello" : "world!" }) == celpy .celtypes .MapType (
4651 {
47- celpy .celtypes .StringType ("Hello" ):
48- celpy .celtypes .StringType ("world!" ),
52+ celpy .celtypes .StringType ("Hello" ): celpy .celtypes .StringType ("world!" ),
4953 }
5054 )
51- assert (
52- celpy .adapter .json_to_cel (datetime .datetime (2020 , 9 , 10 , 11 , 12 , 13 , tzinfo = datetime .timezone .utc ))
53- == celpy .celtypes .TimestampType ("2020-09-10T11:12:13Z" )
54- )
55- assert (
56- celpy .adapter .json_to_cel (datetime .timedelta (days = 42 )) == celpy .celtypes .DurationType ("42d" )
57- )
55+ assert celpy .adapter .json_to_cel (
56+ datetime .datetime (2020 , 9 , 10 , 11 , 12 , 13 , tzinfo = datetime .timezone .utc )
57+ ) == celpy .celtypes .TimestampType ("2020-09-10T11:12:13Z" )
58+ assert celpy .adapter .json_to_cel (
59+ datetime .timedelta (days = 42 )
60+ ) == celpy .celtypes .DurationType ("42d" )
0 commit comments