Coverage for src/km3pipe/tests/test_shell.py: 100%
66 statements
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-19 03:14 +0000
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-19 03:14 +0000
1# Filename: test_shell.py
2# pylint: disable=locally-disabled,C0111,R0904,C0103
4from km3pipe.testing import TestCase
5from km3pipe.shell import Script
7__author__ = "Tamas Gal"
8__copyright__ = "Copyright 2017, Tamas Gal and the KM3NeT collaboration."
9__credits__ = []
10__license__ = "MIT"
11__maintainer__ = "Tamas Gal"
12__email__ = "tgal@km3net.de"
13__status__ = "Development"
16class TestScript(TestCase):
17 def test_add(self):
18 s = Script()
19 s.add("a")
20 s.add("b")
22 def test_str(self):
23 s = Script()
24 s.add("a")
25 s.add("b")
26 self.assertEqual("a\nb", str(s))
28 def test_clear(self):
29 s = Script()
30 s.add("a")
31 s.clear()
32 self.assertEqual("", str(s))
34 def test_add_two_argument_command(self):
35 s = Script()
36 s._add_two_argument_command("command", "a", "b")
37 self.assertEqual("command a b", str(s))
39 def test_add_two_argument_command_multiple_times(self):
40 s = Script()
41 s._add_two_argument_command("cmd1", "a", "b")
42 s._add_two_argument_command("cmd2", "c", "d")
43 s._add_two_argument_command("cmd3", "e", "f")
44 self.assertEqual("cmd1 a b\ncmd2 c d\ncmd3 e f", str(s))
46 def test_cp(self):
47 s = Script()
48 s.cp("a", "b")
49 self.assertEqual("cp a b", str(s))
51 def test_mv(self):
52 s = Script()
53 s.mv("a", "b")
54 self.assertEqual("mv a b", str(s))
56 def test_echo(self):
57 s = Script()
58 s.echo("test")
59 self.assertEqual('echo "test"', str(s))
61 def test_separator(self):
62 s = Script()
63 s.separator()
64 self.assertEqual('echo "' + "=" * 42 + '"', str(s))
66 def test_mkdir(self):
67 s = Script()
68 s.mkdir("/path/to/file")
69 self.assertEqual('mkdir -p "/path/to/file"', str(s))
71 def test_iget(self):
72 s = Script()
73 s.iget("/path/to/file")
74 self.assertEqual('iget -v "/path/to/file"', str(s))
76 def test_combining_scripts(self):
77 s1 = Script()
78 s2 = Script()
79 s1.add("a")
80 s1.add("b")
81 s2.add("c")
82 s2.add("d")
83 assert "a\nb\nc\nd" == str(s1 + s2)