Commit da37dcce authored by rajesh's avatar rajesh

Add test cases for clone feature and main function

parent 63d278fd
Pipeline #1511 failed with stages
in 15 seconds
......@@ -8,12 +8,13 @@ import pytest
class TestClitoo(object):
"""Classes can still be used to organize collections of test cases, with.
"""Classes can still be used to organize collections of test cases.
each test being a Method on the Class, rather than a standalone function.
Each test being a Method on the Class, rather than a standalone function.
"""
url = "https://yourlabs.io/oss/clitoo.git"
url = "https://gitlab.com/rajesh-cis/testclitoo.git"
ssh_url = "git@gitlab.com:rajesh-cis/testclitoo.git"
def test_python_3_version_compatibility(self):
"""Test python 3 version comptibility."""
......@@ -92,9 +93,9 @@ class TestClitoo(object):
assert 'debug' in cb.callables
def test_class_properties(self):
"""
Check class didnt change from a defined snapshot.
"""Test the properties of the class.
Check class didnt change from a defined snapshot
Class changes or new references makes this test fail to warn the dev,
who will decide if the change must be accounted.
"""
......@@ -128,7 +129,7 @@ class TestClitoo(object):
def test_no_filedoc(self):
"""Return default doc string.
If doc string is not avaliable for followling(clone,push).
If doc string is not avaliable for followling(clone,push,apply).
"""
base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
file_path = base_dir + '/clitoo/clitoo/git.py'
......@@ -143,23 +144,12 @@ class TestClitoo(object):
"""Test _run function of the git module."""
base_dir = os.path.dirname(os.path.abspath(__file__))
app_path = base_dir + "/clitoo/testcli"
cmd = ['clone', self.url]
cmd = ['clone', self.ssh_url]
cmd.append(app_path)
clitoo.git._run(cmd)
assert os.path.isdir(app_path)
shutil.rmtree(app_path)
def test_clone_cmd(self):
"""Test clone of the git module."""
base_dir = os.path.dirname(os.path.abspath(__file__))
clitoo.git.clone(self.url, base_dir + "/clitoo/testcli")
assert os.path.isdir(base_dir + "/clitoo/testcli/clitoo")
shutil.rmtree(base_dir + "/clitoo/testcli")
def test_apply_cmd(self):
"""Test apply of the git module."""
clitoo.git.apply()
def test_apply_help_cmd(self):
"""Return the help doc string for the apply."""
clitoo.help('git.apply')
......@@ -174,11 +164,11 @@ class TestClitoo(object):
print(clitoo.help('git.reset'))
def test_help(self):
"""Test help method."""
"""Test empty argument for the help method."""
clitoo.help()
def test_empty_debug(self):
"""Test debug method."""
"""Test empty argument for the debug method."""
clitoo.debug()
def test_args_debug(self):
......@@ -186,6 +176,38 @@ class TestClitoo(object):
clitoo.debug(*('git.clone', '12'))
def test_not_exists_method(self):
"""Test not avaliable method for clitoo module."""
"""Test not avaliable method in the clitoo module."""
with pytest.raises(AttributeError):
print(clitoo.exists())
def test_environ_method(self):
"""Test clone feature with ssh key.
Taken a clone using ssh and after check project directory is available
or not.
"""
os.environ['SSH_PRIVATE_KEY'] = ""
base_dir = os.path.dirname(os.path.abspath(__file__))
clitoo.git.clone(self.ssh_url, base_dir + "/clitoo/testclit")
assert os.path.isdir(base_dir + "/clitoo/testclit")
shutil.rmtree(base_dir + "/clitoo/testclit")
def test_apply_cmd(self):
"""Test apply of the git module."""
clitoo.git.apply()
def test_push_cmd(self):
"""Test apply of the git module."""
clitoo.git.push("Test commit")
def test_main_for_help(self):
"""Test main method for help."""
clitoo.main(['help'])
def test_main_empty(self):
"""Test empty argument for main method."""
clitoo.main([])
def test_main_for_single_dash(self):
"""Test dash argument for main method."""
clitoo.main(["-"])
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