-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_user_function.py
25 lines (19 loc) · 991 Bytes
/
test_user_function.py
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
# Tests (copy to tests/test_user_functions.py)
import pytest
import io
from email_function import *
def test_email_with_user_input_no_at_sign(monkeypatch):
monkeypatch.setattr('sys.stdin', io.StringIO('petra.adaltas.com'))
assert get_email_from_input() is None
def test_email_with_user_input_no_dot(monkeypatch):
monkeypatch.setattr('sys.stdin', io.StringIO('petra@adaltascom'))
assert get_email_from_input() is None
def test_email_with_user_input_correct(monkeypatch):
monkeypatch.setattr('sys.stdin', io.StringIO('[email protected]'))
assert get_email_from_input() == '[email protected]'
def test_username_with_user_input_correct(monkeypatch):
monkeypatch.setattr('sys.stdin', io.StringIO('wigins'))
assert get_user_name_from_input() == 'wigins'
def test_password_with_user_input_correct(monkeypatch):
monkeypatch.setattr('sys.stdin', io.StringIO('Fake@password57'))
assert get_password_from_input() == "Password has successfully been updated"