@@ -473,7 +473,7 @@ def test_no_auth(self):
473
473
"""
474
474
channel = self .make_request ("GET" , self .url , b"{}" )
475
475
476
- self .assertEqual (401 , int ( channel .result [ " code" ]) , msg = channel .result [ "body" ] )
476
+ self .assertEqual (401 , channel .code , msg = channel .json_body )
477
477
self .assertEqual (Codes .MISSING_TOKEN , channel .json_body ["errcode" ])
478
478
479
479
def test_requester_is_no_admin (self ):
@@ -485,7 +485,7 @@ def test_requester_is_no_admin(self):
485
485
486
486
channel = self .make_request ("GET" , self .url , access_token = other_user_token )
487
487
488
- self .assertEqual (403 , int ( channel .result [ " code" ]) , msg = channel .result [ "body" ] )
488
+ self .assertEqual (403 , channel .code , msg = channel .json_body )
489
489
self .assertEqual (Codes .FORBIDDEN , channel .json_body ["errcode" ])
490
490
491
491
def test_all_users (self ):
@@ -497,11 +497,11 @@ def test_all_users(self):
497
497
channel = self .make_request (
498
498
"GET" ,
499
499
self .url + "?deactivated=true" ,
500
- b"{}" ,
500
+ {} ,
501
501
access_token = self .admin_user_tok ,
502
502
)
503
503
504
- self .assertEqual (200 , int ( channel .result [ " code" ]) , msg = channel .result [ "body" ] )
504
+ self .assertEqual (200 , channel .code , msg = channel .json_body )
505
505
self .assertEqual (3 , len (channel .json_body ["users" ]))
506
506
self .assertEqual (3 , channel .json_body ["total" ])
507
507
@@ -532,7 +532,7 @@ def _search_test(
532
532
)
533
533
channel = self .make_request (
534
534
"GET" ,
535
- url . encode ( "ascii" ) ,
535
+ url ,
536
536
access_token = self .admin_user_tok ,
537
537
)
538
538
self .assertEqual (expected_http_code , channel .code , msg = channel .json_body )
@@ -598,7 +598,7 @@ def test_invalid_parameter(self):
598
598
access_token = self .admin_user_tok ,
599
599
)
600
600
601
- self .assertEqual (400 , int ( channel .result [ " code" ]) , msg = channel .result [ "body" ] )
601
+ self .assertEqual (400 , channel .code , msg = channel .json_body )
602
602
self .assertEqual (Codes .INVALID_PARAM , channel .json_body ["errcode" ])
603
603
604
604
# negative from
@@ -608,7 +608,7 @@ def test_invalid_parameter(self):
608
608
access_token = self .admin_user_tok ,
609
609
)
610
610
611
- self .assertEqual (400 , int ( channel .result [ " code" ]) , msg = channel .result [ "body" ] )
611
+ self .assertEqual (400 , channel .code , msg = channel .json_body )
612
612
self .assertEqual (Codes .INVALID_PARAM , channel .json_body ["errcode" ])
613
613
614
614
# invalid guests
@@ -618,7 +618,7 @@ def test_invalid_parameter(self):
618
618
access_token = self .admin_user_tok ,
619
619
)
620
620
621
- self .assertEqual (400 , int ( channel .result [ " code" ]) , msg = channel .result [ "body" ] )
621
+ self .assertEqual (400 , channel .code , msg = channel .json_body )
622
622
self .assertEqual (Codes .UNKNOWN , channel .json_body ["errcode" ])
623
623
624
624
# invalid deactivated
@@ -628,7 +628,7 @@ def test_invalid_parameter(self):
628
628
access_token = self .admin_user_tok ,
629
629
)
630
630
631
- self .assertEqual (400 , int ( channel .result [ " code" ]) , msg = channel .result [ "body" ] )
631
+ self .assertEqual (400 , channel .code , msg = channel .json_body )
632
632
self .assertEqual (Codes .UNKNOWN , channel .json_body ["errcode" ])
633
633
634
634
# unkown order_by
@@ -648,7 +648,7 @@ def test_invalid_parameter(self):
648
648
access_token = self .admin_user_tok ,
649
649
)
650
650
651
- self .assertEqual (400 , int ( channel .result [ " code" ]) , msg = channel .result [ "body" ] )
651
+ self .assertEqual (400 , channel .code , msg = channel .json_body )
652
652
self .assertEqual (Codes .UNKNOWN , channel .json_body ["errcode" ])
653
653
654
654
def test_limit (self ):
@@ -666,7 +666,7 @@ def test_limit(self):
666
666
access_token = self .admin_user_tok ,
667
667
)
668
668
669
- self .assertEqual (200 , int ( channel .result [ " code" ]) , msg = channel .result [ "body" ] )
669
+ self .assertEqual (200 , channel .code , msg = channel .json_body )
670
670
self .assertEqual (channel .json_body ["total" ], number_users )
671
671
self .assertEqual (len (channel .json_body ["users" ]), 5 )
672
672
self .assertEqual (channel .json_body ["next_token" ], "5" )
@@ -687,7 +687,7 @@ def test_from(self):
687
687
access_token = self .admin_user_tok ,
688
688
)
689
689
690
- self .assertEqual (200 , int ( channel .result [ " code" ]) , msg = channel .result [ "body" ] )
690
+ self .assertEqual (200 , channel .code , msg = channel .json_body )
691
691
self .assertEqual (channel .json_body ["total" ], number_users )
692
692
self .assertEqual (len (channel .json_body ["users" ]), 15 )
693
693
self .assertNotIn ("next_token" , channel .json_body )
@@ -708,7 +708,7 @@ def test_limit_and_from(self):
708
708
access_token = self .admin_user_tok ,
709
709
)
710
710
711
- self .assertEqual (200 , int ( channel .result [ " code" ]) , msg = channel .result [ "body" ] )
711
+ self .assertEqual (200 , channel .code , msg = channel .json_body )
712
712
self .assertEqual (channel .json_body ["total" ], number_users )
713
713
self .assertEqual (channel .json_body ["next_token" ], "15" )
714
714
self .assertEqual (len (channel .json_body ["users" ]), 10 )
@@ -731,7 +731,7 @@ def test_next_token(self):
731
731
access_token = self .admin_user_tok ,
732
732
)
733
733
734
- self .assertEqual (200 , int ( channel .result [ " code" ]) , msg = channel .result [ "body" ] )
734
+ self .assertEqual (200 , channel .code , msg = channel .json_body )
735
735
self .assertEqual (channel .json_body ["total" ], number_users )
736
736
self .assertEqual (len (channel .json_body ["users" ]), number_users )
737
737
self .assertNotIn ("next_token" , channel .json_body )
@@ -744,7 +744,7 @@ def test_next_token(self):
744
744
access_token = self .admin_user_tok ,
745
745
)
746
746
747
- self .assertEqual (200 , int ( channel .result [ " code" ]) , msg = channel .result [ "body" ] )
747
+ self .assertEqual (200 , channel .code , msg = channel .json_body )
748
748
self .assertEqual (channel .json_body ["total" ], number_users )
749
749
self .assertEqual (len (channel .json_body ["users" ]), number_users )
750
750
self .assertNotIn ("next_token" , channel .json_body )
@@ -757,7 +757,7 @@ def test_next_token(self):
757
757
access_token = self .admin_user_tok ,
758
758
)
759
759
760
- self .assertEqual (200 , int ( channel .result [ " code" ]) , msg = channel .result [ "body" ] )
760
+ self .assertEqual (200 , channel .code , msg = channel .json_body )
761
761
self .assertEqual (channel .json_body ["total" ], number_users )
762
762
self .assertEqual (len (channel .json_body ["users" ]), 19 )
763
763
self .assertEqual (channel .json_body ["next_token" ], "19" )
@@ -771,7 +771,7 @@ def test_next_token(self):
771
771
access_token = self .admin_user_tok ,
772
772
)
773
773
774
- self .assertEqual (200 , int ( channel .result [ " code" ]) , msg = channel .result [ "body" ] )
774
+ self .assertEqual (200 , channel .code , msg = channel .json_body )
775
775
self .assertEqual (channel .json_body ["total" ], number_users )
776
776
self .assertEqual (len (channel .json_body ["users" ]), 1 )
777
777
self .assertNotIn ("next_token" , channel .json_body )
@@ -781,7 +781,10 @@ def test_order_by(self):
781
781
Testing order list with parameter `order_by`
782
782
"""
783
783
784
+ # make sure that the users do not have the same timestamps
785
+ self .reactor .advance (10 )
784
786
user1 = self .register_user ("user1" , "pass1" , admin = False , displayname = "Name Z" )
787
+ self .reactor .advance (10 )
785
788
user2 = self .register_user ("user2" , "pass2" , admin = False , displayname = "Name Y" )
786
789
787
790
# Modify user
@@ -841,6 +844,11 @@ def test_order_by(self):
841
844
self ._order_test ([self .admin_user , user2 , user1 ], "avatar_url" , "f" )
842
845
self ._order_test ([user1 , user2 , self .admin_user ], "avatar_url" , "b" )
843
846
847
+ # order by creation_ts
848
+ self ._order_test ([self .admin_user , user1 , user2 ], "creation_ts" )
849
+ self ._order_test ([self .admin_user , user1 , user2 ], "creation_ts" , "f" )
850
+ self ._order_test ([user2 , user1 , self .admin_user ], "creation_ts" , "b" )
851
+
844
852
def _order_test (
845
853
self ,
846
854
expected_user_list : List [str ],
@@ -863,7 +871,7 @@ def _order_test(
863
871
url += "dir=%s" % (dir ,)
864
872
channel = self .make_request (
865
873
"GET" ,
866
- url . encode ( "ascii" ) ,
874
+ url ,
867
875
access_token = self .admin_user_tok ,
868
876
)
869
877
self .assertEqual (200 , channel .code , msg = channel .json_body )
@@ -887,6 +895,7 @@ def _check_fields(self, content: JsonDict):
887
895
self .assertIn ("shadow_banned" , u )
888
896
self .assertIn ("displayname" , u )
889
897
self .assertIn ("avatar_url" , u )
898
+ self .assertIn ("creation_ts" , u )
890
899
891
900
def _create_users (self , number_users : int ):
892
901
"""
0 commit comments