Total Complexity | 4 |
Total Lines | 33 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | """Test kytos.core.auth module.""" |
||
2 | import getpass |
||
3 | from unittest import TestCase |
||
4 | from unittest.mock import patch |
||
5 | |||
6 | |||
7 | def input_password(): |
||
8 | """Get password value""" |
||
9 | password = getpass.getpass() |
||
10 | return password |
||
11 | |||
12 | |||
13 | def input_value(): |
||
14 | """Get input value""" |
||
15 | value = input() |
||
16 | return value |
||
17 | |||
18 | |||
19 | class TestAuth(TestCase): |
||
20 | """Auth tests.""" |
||
21 | |||
22 | @patch("getpass.getpass") |
||
23 | def test_getpass(self, getpass): |
||
24 | """Test when getpass is calling on authentication.""" |
||
25 | getpass.return_value = "youshallnotpass" |
||
26 | assert input_password() == getpass.return_value |
||
27 | |||
28 | @patch("builtins.input") |
||
29 | def test_user_values(self, input): |
||
30 | """Test when input is calling on authentication.""" |
||
31 | input.return_value = "kuser" |
||
32 | assert input_value() == input.return_value |
||
33 |