Skip to content

Commit

Permalink
unittest for SSH keys
Browse files Browse the repository at this point in the history
  • Loading branch information
Gauvain Pocentek committed Feb 17, 2013
1 parent 967ea88 commit 7631e5e
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/main.py
@@ -1,6 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-

import os
import sys
sys.path.append("../")
import unittest
Expand Down Expand Up @@ -110,6 +111,29 @@ def test_gitlab_issues(self):
i_list = self.gl.Issue()
self.assertEqual(len(i_list), 0)

class UserTest(unittest.TestCase):
def setUp(self):
self.gl = Gitlab(url, email=email, password=password)
self.gl.auth()

def test_key(self):
k_list = self.gl.user.Key()
self.assertEqual(len(k_list), 0)

key = open(os.path.expanduser("~/.ssh/id_rsa.pub")).read().strip()
k = self.gl.user.Key({'title': 'key1', 'key': key})
k.save()

k_list = self.gl.user.Key()
self.assertEqual(len(k_list), 1)

k = k_list[0]
self.assertEqual(k.key, key.strip())

k.delete()
k_list = self.gl.user.Key()
self.assertEqual(len(k_list), 0)


if __name__ == '__main__':
unittest.main()

0 comments on commit 7631e5e

Please sign in to comment.