@@ -553,6 +553,62 @@ def resp_get_environment(url, request):
553
553
self .assertEqual (environment .last_deployment , "sometime" )
554
554
self .assertEqual (environment .name , "environment_name" )
555
555
556
+ def test_project_additional_statistics (self ):
557
+ @urlmatch (
558
+ scheme = "http" , netloc = "localhost" , path = "/api/v4/projects/1$" , method = "get"
559
+ )
560
+ def resp_get_project (url , request ):
561
+ headers = {"content-type" : "application/json" }
562
+ content = '{"name": "name", "id": 1}' .encode ("utf-8" )
563
+ return response (200 , content , headers , None , 5 , request )
564
+
565
+ @urlmatch (
566
+ scheme = "http" ,
567
+ netloc = "localhost" ,
568
+ path = "/api/v4/projects/1/statistics" ,
569
+ method = "get" ,
570
+ )
571
+ def resp_get_environment (url , request ):
572
+ headers = {"content-type" : "application/json" }
573
+ content = """{"fetches": {"total": 50, "days": [{"count": 10, "date": "2018-01-10"}]}}""" .encode (
574
+ "utf-8"
575
+ )
576
+ return response (200 , content , headers , None , 5 , request )
577
+
578
+ with HTTMock (resp_get_project , resp_get_environment ):
579
+ project = self .gl .projects .get (1 )
580
+ statistics = project .additionalstatistics .get ()
581
+ self .assertIsInstance (statistics , ProjectAdditionalStatistics )
582
+ self .assertEqual (statistics .fetches ["total" ], 50 )
583
+
584
+ def test_project_issues_statistics (self ):
585
+ @urlmatch (
586
+ scheme = "http" , netloc = "localhost" , path = "/api/v4/projects/1$" , method = "get"
587
+ )
588
+ def resp_get_project (url , request ):
589
+ headers = {"content-type" : "application/json" }
590
+ content = '{"name": "name", "id": 1}' .encode ("utf-8" )
591
+ return response (200 , content , headers , None , 5 , request )
592
+
593
+ @urlmatch (
594
+ scheme = "http" ,
595
+ netloc = "localhost" ,
596
+ path = "/api/v4/projects/1/issues_statistics" ,
597
+ method = "get" ,
598
+ )
599
+ def resp_get_environment (url , request ):
600
+ headers = {"content-type" : "application/json" }
601
+ content = """{"statistics": {"counts": {"all": 20, "closed": 5, "opened": 15}}}""" .encode (
602
+ "utf-8"
603
+ )
604
+ return response (200 , content , headers , None , 5 , request )
605
+
606
+ with HTTMock (resp_get_project , resp_get_environment ):
607
+ project = self .gl .projects .get (1 )
608
+ statistics = project .issuesstatistics .get ()
609
+ self .assertIsInstance (statistics , ProjectIssuesStatistics )
610
+ self .assertEqual (statistics .statistics ["counts" ]["all" ], 20 )
611
+
556
612
def test_groups (self ):
557
613
@urlmatch (
558
614
scheme = "http" , netloc = "localhost" , path = "/api/v4/groups/1" , method = "get"
0 commit comments