@@ -82,6 +82,12 @@ def check_bool(self, obj: str, key: str) -> None:
8282 for bad in ("" , 0 , "True" ):
8383 self .check_invalid_transaction ({obj : {key : bad }})
8484
85+ def check_rfc3339_time (self , obj : str , key : str ) -> None :
86+ for good in GOOD_TIMES :
87+ self .check_transaction ({obj : {key : good }})
88+ for bad in BAD_TIMES + NON_STRING_TIMES :
89+ self .check_invalid_transaction ({obj : {key : bad }})
90+
8591 def setup_report (self , report : dict [str , Any ]) -> None :
8692 if "ip_address" not in report :
8793 report ["ip_address" ] = "1.2.3.4"
@@ -186,18 +192,7 @@ def test_phone_was_verification_successful(self) -> None:
186192 self .check_bool (self .type , "phone_was_verification_successful" )
187193
188194 def test_phone_verification_time (self ) -> None :
189- for good in GOOD_TIMES :
190- self .check_transaction ({self .type : {"phone_verification_time" : good }})
191- for bad in BAD_TIMES :
192- self .check_invalid_transaction (
193- {self .type : {"phone_verification_time" : bad }},
194- )
195-
196- def test_phone_verification_time_not_string (self ) -> None :
197- for bad in NON_STRING_TIMES :
198- self .check_invalid_transaction (
199- {self .type : {"phone_verification_time" : bad }},
200- )
195+ self .check_rfc3339_time (self .type , "phone_verification_time" )
201196
202197
203198class TestBillingAddress (AddressBase ):
@@ -372,14 +367,7 @@ def test_domain(self) -> None:
372367 self .check_invalid_transaction ({"email" : {"domain" : bad }})
373368
374369 def test_verification_time (self ) -> None :
375- for good in GOOD_TIMES :
376- self .check_transaction ({"email" : {"verification_time" : good }})
377- for bad in BAD_TIMES :
378- self .check_invalid_transaction ({"email" : {"verification_time" : bad }})
379-
380- def test_verification_time_not_string (self ) -> None :
381- for bad in NON_STRING_TIMES :
382- self .check_invalid_transaction ({"email" : {"verification_time" : bad }})
370+ self .check_rfc3339_time ("email" , "verification_time" )
383371
384372 def test_was_verification_successful (self ) -> None :
385373 self .check_bool ("email" , "was_verification_successful" )
@@ -399,14 +387,7 @@ def test_shop_id(self) -> None:
399387 self .check_transaction_str_type ("event" , "shop_id" )
400388
401389 def test_time (self ) -> None :
402- for good in GOOD_TIMES :
403- self .check_transaction ({"event" : {"time" : good }})
404- for bad in BAD_TIMES :
405- self .check_invalid_transaction ({"event" : {"time" : bad }})
406-
407- def test_time_not_string (self ) -> None :
408- for bad in NON_STRING_TIMES :
409- self .check_invalid_transaction ({"event" : {"time" : bad }})
390+ self .check_rfc3339_time ("event" , "time" )
410391
411392 def test_time_impossible_date_message (self ) -> None :
412393 transaction : dict [str , Any ] = {"event" : {"time" : "2026-02-30T10:00:00Z" }}
0 commit comments