-
Notifications
You must be signed in to change notification settings - Fork 112
Expand file tree
/
Copy pathtest_keys.py
More file actions
38 lines (29 loc) · 984 Bytes
/
test_keys.py
File metadata and controls
38 lines (29 loc) · 984 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"""
Unit tests for the Deis CLI keys commands.
Run these tests with "python -m unittest client.tests.test_keys"
or with "./manage.py test client.KeysTest".
"""
from __future__ import unicode_literals
from unittest import TestCase
import glob
import os.path
import pexpect
from .utils import DEIS
from .utils import purge
from .utils import register
class KeysTest(TestCase):
@classmethod
def setUpClass(cls):
cls.username, cls.password = register(False, False)
@classmethod
def tearDownClass(cls):
purge(cls.username, cls.password)
def test_add(self):
# test adding a specified key--the "choose a key" path is well
# covered in utils.register()
ssh_dir = os.path.expanduser('~/.ssh')
pubkey = glob.glob(os.path.join(ssh_dir, '*.pub'))[0]
child = pexpect.spawn("{} keys:add {}".format(DEIS, pubkey))
child.expect('Uploading')
child.expect('...done')
child.expect(pexpect.EOF)