-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtest_auth.py
More file actions
46 lines (36 loc) · 1.3 KB
/
test_auth.py
File metadata and controls
46 lines (36 loc) · 1.3 KB
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
39
40
41
42
43
44
45
46
"""
Unit tests for the Deis CLI auth commands.
Run these tests with "python -m unittest client.tests.test_auth"
or with "./manage.py test client.AuthTest".
"""
from __future__ import unicode_literals
from unittest import TestCase
import pexpect
from .utils import DEIS
from .utils import DEIS_SERVER
from .utils import purge
from .utils import register
class AuthTest(TestCase):
@classmethod
def setUpClass(cls):
cls.username, cls.password = register()
@classmethod
def tearDownClass(cls):
purge(cls.username, cls.password)
def test_login(self):
# log in the interactive way
child = pexpect.spawn("{} login {}".format(DEIS, DEIS_SERVER))
child.expect('username: ')
child.sendline(self.username)
child.expect('password: ')
child.sendline(self.password)
child.expect("Logged in as {}".format(self.username))
child.expect(pexpect.EOF)
def test_logout(self):
child = pexpect.spawn("{} logout".format(DEIS))
child.expect('Logged out')
# log in the one-liner way
child = pexpect.spawn("{} login {} --username={} --password={}".format(
DEIS, DEIS_SERVER, self.username, self.password))
child.expect("Logged in as {}".format(self.username))
child.expect(pexpect.EOF)