21
21
from autopilot.matchers import Eventually
22
from testtools.matchers import Equals, Contains, FileExists, DirExists, DirContains
22
from testtools.matchers import Equals, Contains, FileExists, DirExists, \
23
24
from terminal import TerminalAutopilotTestCase
28
29
def test_save_a_file(self):
29
30
self.keyboard.type("touch /tmp/test-file\n")
30
#Verify that test-file has been created
31
# Verify that test-file has been created
31
32
self.assertTrue('/tmp/testfile', FileExists())
32
#Delete the file we created
33
# Delete the file we created
33
34
self.addCleanup(os.remove, "/tmp/test-file")
35
36
def test_create_directory(self):
45
46
def test_move_directory_with_files(self):
46
47
self.create_temp_directory_with_temp_files()
47
#create directory to move to
48
# create directory to move to
48
49
self.keyboard.type('mkdir /tmp/temp-dir2\n')
49
#move temp-dir to temp-dir2
50
# move temp-dir to temp-dir2
50
51
self.keyboard.type('mv /tmp/temp-dir/ /tmp/temp-dir2/\n')
52
53
self.assertTrue('/tmp/temp-dir2/temp-dir/', DirExists())
54
self.assertTrue('/tmp/temp-dir2/temp-dir/', DirContains(['a', 'b', 'c']))
56
'/tmp/temp-dir2/temp-dir/', DirContains(['a', 'b', 'c']))
56
58
self.addCleanup(shutil.rmtree, '/tmp/temp-dir2')
58
60
def test_copying_file(self):
59
61
self.create_temp_directory_with_temp_files()
60
#create directory to move to
62
# create directory to move to
61
63
self.keyboard.type('mkdir /tmp/temp-dir2\n')
62
#move file 'a' to temp-dir2
64
# move file 'a' to temp-dir2
63
65
self.keyboard.type('cp /tmp/temp-dir/a /tmp/temp-dir2/\n')
65
67
self.assertTrue('/tmp/temp-dir2/temp-dir/', DirContains(['a']))
66
68
self.addCleanup(shutil.rmtree, '/tmp/temp-dir')
67
69
self.addCleanup(shutil.rmtree, '/tmp/temp-dir2')
81
83
terminal_window = self.app.select_single('TerminalWindow')
82
84
self.keyboard.type('cd\n')
83
85
self.keyboard.type('cd Documents\n')
84
self.assertThat(terminal_window.title, Eventually(Contains('~/Documents')))
87
terminal_window.title, Eventually(Contains('~/Documents')))
86
89
def test_open_new_tab(self, ):
88
91
self.keyboard.press_and_release('Ctrl+Shift+t')
89
92
# test number of tabs(containers) equals 2
90
93
tabs = self.app.select_many('TerminalScreenContainer')
91
94
self.assertThat(len(tabs), Equals(2))