Commit 5343d163 authored by rajesh's avatar rajesh

Added test cases for settings and ls

parent 986030c3
Pipeline #1566 passed with stages
in 42 seconds
......@@ -54,7 +54,7 @@ def test_save(capsys):
@pytest.mark.django_db
def test_delete():
def test_delete(capsys):
"""Test delete method for the user.
Create new user 'TestUser1' and check user count is 1
......@@ -69,7 +69,9 @@ def test_delete():
'settings.AUTH_USER_MODEL',
username='TestUser1',
)
cap = capsys.readouterr()
assert users.count() == 0
assert "Deleted 1 objects" in cap.out
@pytest.mark.django_db
......@@ -120,3 +122,46 @@ def test_chpasswd(capsys):
)
cap = capsys.readouterr()
assert 'Password updated !' in cap.out
@pytest.mark.django_db
def test_settings(capsys):
"""Test settings method and to check settings variable."""
djcli.settings('DATABASES', 'INSTALLED_APPS')
cap = capsys.readouterr()
assert 'AUTOCOMMIT' in cap.out
@pytest.mark.django_db
def test_save_for_args_or_kwargs(capsys):
"""Test save method for args or kwargs.
Create new user 'TestUser1' for args and kwargs
Test usernames:
Test enter enter use name exist or not.
"""
djcli.save(
'settings.AUTH_USER_MODEL',
'email',
username='TestUser1',
email='test2@gmail.com'
)
cap = capsys.readouterr()
assert 'test2@gmail.com' in cap.out
@pytest.mark.django_db
def test_ls_for_not_exists_record(capsys):
"""Test ls method for not avaliable record.
Check message content for the not avaliable record
@response = 'No result found !'.
"""
with pytest.raises(SystemExit):
djcli.ls(
'settings.AUTH_USER_MODEL',
'first_name',
)
cap = capsys.readouterr()
assert 'No result found !' in cap.out
print(cap.out, cap.err)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment