Skip to content

Commit 748bc7c

Browse files
author
Costin Bleotu
committed
Test list user repos
1 parent dbce610 commit 748bc7c

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

tests/interface_test.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,47 @@ def setUp(self):
3636
"pull": true
3737
}
3838
}"""
39+
self.repos_list_json_str = """[{
40+
"id": 27,
41+
"owner": {
42+
"id": 1,
43+
"username": "unknwon",
44+
"full_name": "",
45+
"email": "u@gogs.io",
46+
"avatar_url": "/avatars/1"
47+
},
48+
"full_name": "unknwon/Hello-World",
49+
"private": false,
50+
"fork": false,
51+
"html_url": "http://localhost:3000/unknwon/Hello-World",
52+
"clone_url": "http://localhost:3000/unknwon/hello-world.git",
53+
"ssh_url": "jiahuachen@localhost:unknwon/hello-world.git",
54+
"permissions": {
55+
"admin": true,
56+
"push": true,
57+
"pull": true
58+
}
59+
},{
60+
"id": 28,
61+
"owner": {
62+
"id": 1,
63+
"username": "unknwon",
64+
"full_name": "",
65+
"email": "u@gogs.io",
66+
"avatar_url": "/avatars/1"
67+
},
68+
"full_name": "unknwon/Hello-World-Again",
69+
"private": false,
70+
"fork": false,
71+
"html_url": "http://localhost:3000/unknwon/Hello-World-Again",
72+
"clone_url": "http://localhost:3000/unknwon/hello-world-again.git",
73+
"ssh_url": "jiahuachen@localhost:unknwon/hello-world-again.git",
74+
"permissions": {
75+
"admin": true,
76+
"push": true,
77+
"pull": true
78+
}
79+
}]"""
3980
self.user_json_str = """{
4081
"id": 1,
4182
"username": "unknwon",
@@ -183,6 +224,15 @@ def test_get_repo1(self):
183224
last_call = responses.calls[1]
184225
self.assertEqual(last_call.request.url, self.path_with_token(uri2))
185226

227+
@responses.activate
228+
def test_get_user_repos(self):
229+
uri = self.path("/users/username/repos")
230+
responses.add(responses.GET, uri, body=self.repos_list_json_str, status=200)
231+
repos = self.client.get_user_repos(self.token, "username")
232+
self.assertEqual(len(repos), 2)
233+
self.assert_repos_equal(repos[0], self.expected_repo)
234+
235+
186236
@responses.activate
187237
def test_delete_repo1(self):
188238
uri1 = self.path("/repos/username/repo1")

0 commit comments

Comments
 (0)