@@ -65,7 +65,38 @@ def setUp(self):
65
65
"updated_at": "2017-03-31T12:42:58Z",
66
66
"created_at": "2017-03-31T12:42:58Z"
67
67
}"""
68
-
68
+ self .hooks_list_json_str = """[
69
+ {
70
+ "id": 4,
71
+ "type": "gogs",
72
+ "config": {
73
+ "content_type": "json",
74
+ "url": "http://test.io/hook"
75
+ },
76
+ "events": [
77
+ "create",
78
+ "push",
79
+ "issues"
80
+ ],
81
+ "active": false,
82
+ "updated_at": "2017-03-31T12:42:58Z",
83
+ "created_at": "2017-03-31T12:42:58Z"
84
+ },
85
+ {
86
+ "id": 3,
87
+ "type": "gogs",
88
+ "config": {
89
+ "content_type": "json",
90
+ "url": "http://192.168.201.1:8080/hook22/"
91
+ },
92
+ "events": [
93
+ "issue_comment"
94
+ ],
95
+ "active": true,
96
+ "updated_at": "2017-03-31T12:47:56Z",
97
+ "created_at": "2017-03-31T12:42:54Z"
98
+ }
99
+ ]"""
69
100
self .expected_repo = gogs_client .GogsRepo .from_json (json .loads (self .repo_json_str ))
70
101
self .expected_user = gogs_client .GogsUser .from_json (json .loads (self .user_json_str ))
71
102
self .expected_hook = gogs_client .GogsRepo .Hook .from_json (json .loads (self .hook_json_str ))
@@ -323,6 +354,20 @@ def callback(request):
323
354
hook = self .client .update_hook (self .token , "repo1" , 4 , update , organization = "username" )
324
355
self .assert_hooks_equals (hook , self .expected_hook )
325
356
357
+ @responses .activate
358
+ def test_list_hooks (self ):
359
+ uri = self .path ("/repos/username/repo1/hooks" )
360
+ responses .add (responses .GET , uri , body = self .hooks_list_json_str , status = 20 )
361
+ hooks = self .client .get_repo_hooks (self .token , "username" , "repo1" )
362
+ self .assertEqual (len (hooks ), 2 )
363
+ self .assert_hooks_equals (hooks [0 ], self .expected_hook )
364
+
365
+ @responses .activate
366
+ def test_delete_hook (self ):
367
+ uri = self .path ("/repos/username/repo1/hooks/4" )
368
+ responses .add (responses .DELETE , uri , status = 204 )
369
+ hook = self .client .delete_hook (self .token , "username" , "repo1" , 4 )
370
+ self .assertEqual (hook .status_code , 204 )
326
371
327
372
# helper methods
328
373
0 commit comments