68
68
tree = self.create_shelvable_tree()
69
69
shelver = ExpectShelver(tree, tree.basis_tree())
70
70
e = self.assertRaises(AssertionError, shelver.run)
71
self.assertEqual('Unexpected prompt: Shelve? [yNfq]', str(e))
71
self.assertEqual('Unexpected prompt: Shelve? [yNfq?]', str(e))
73
73
def test_wrong_prompt_failure(self):
74
74
tree = self.create_shelvable_tree()
75
75
shelver = ExpectShelver(tree, tree.basis_tree())
76
76
shelver.expect('foo', 'y')
77
77
e = self.assertRaises(AssertionError, shelver.run)
78
self.assertEqual('Wrong prompt: Shelve? [yNfq]', str(e))
78
self.assertEqual('Wrong prompt: Shelve? [yNfq?]', str(e))
80
80
def test_shelve_not_diff(self):
81
81
tree = self.create_shelvable_tree()
82
82
shelver = ExpectShelver(tree, tree.basis_tree())
83
shelver.expect('Shelve? [yNfq]', 'n')
84
shelver.expect('Shelve? [yNfq]', 'n')
83
shelver.expect('Shelve? [yNfq?]', 'n')
84
shelver.expect('Shelve? [yNfq?]', 'n')
85
85
# No final shelving prompt because no changes were selected
87
87
self.assertFileEqual(LINES_ZY, 'tree/foo')
89
89
def test_shelve_diff_no(self):
90
90
tree = self.create_shelvable_tree()
91
91
shelver = ExpectShelver(tree, tree.basis_tree())
92
shelver.expect('Shelve? [yNfq]', 'y')
93
shelver.expect('Shelve? [yNfq]', 'y')
94
shelver.expect('Shelve 2 change(s)? [yNfq]', 'n')
92
shelver.expect('Shelve? [yNfq?]', 'y')
93
shelver.expect('Shelve? [yNfq?]', 'y')
94
shelver.expect('Shelve 2 change(s)? [yNfq?]', 'n')
96
96
self.assertFileEqual(LINES_ZY, 'tree/foo')
98
98
def test_shelve_diff(self):
99
99
tree = self.create_shelvable_tree()
100
100
shelver = ExpectShelver(tree, tree.basis_tree())
101
shelver.expect('Shelve? [yNfq]', 'y')
102
shelver.expect('Shelve? [yNfq]', 'y')
103
shelver.expect('Shelve 2 change(s)? [yNfq]', 'y')
101
shelver.expect('Shelve? [yNfq?]', 'y')
102
shelver.expect('Shelve? [yNfq?]', 'y')
103
shelver.expect('Shelve 2 change(s)? [yNfq?]', 'y')
105
105
self.assertFileEqual(LINES_AJ, 'tree/foo')
107
107
def test_shelve_one_diff(self):
108
108
tree = self.create_shelvable_tree()
109
109
shelver = ExpectShelver(tree, tree.basis_tree())
110
shelver.expect('Shelve? [yNfq]', 'y')
111
shelver.expect('Shelve? [yNfq]', 'n')
112
shelver.expect('Shelve 1 change(s)? [yNfq]', 'y')
110
shelver.expect('Shelve? [yNfq?]', 'y')
111
shelver.expect('Shelve? [yNfq?]', 'n')
112
shelver.expect('Shelve 1 change(s)? [yNfq?]', 'y')
114
114
self.assertFileEqual(LINES_AY, 'tree/foo')
117
117
tree = self.create_shelvable_tree()
118
118
self.build_tree_contents([('tree/foo', '\x00')])
119
119
shelver = ExpectShelver(tree, tree.basis_tree())
120
shelver.expect('Shelve binary changes? [yNfq]', 'y')
121
shelver.expect('Shelve 1 change(s)? [yNfq]', 'y')
120
shelver.expect('Shelve binary changes? [yNfq?]', 'y')
121
shelver.expect('Shelve 1 change(s)? [yNfq?]', 'y')
123
123
self.assertFileEqual(LINES_AJ, 'tree/foo')
126
126
tree = self.create_shelvable_tree()
127
127
tree.rename_one('foo', 'bar')
128
128
shelver = ExpectShelver(tree, tree.basis_tree())
129
shelver.expect('Shelve renaming "foo" => "bar"? [yNfq]', 'y')
130
shelver.expect('Shelve? [yNfq]', 'y')
131
shelver.expect('Shelve? [yNfq]', 'y')
132
shelver.expect('Shelve 3 change(s)? [yNfq]', 'y')
129
shelver.expect('Shelve renaming "foo" => "bar"? [yNfq?]', 'y')
130
shelver.expect('Shelve? [yNfq?]', 'y')
131
shelver.expect('Shelve? [yNfq?]', 'y')
132
shelver.expect('Shelve 3 change(s)? [yNfq?]', 'y')
134
134
self.assertFileEqual(LINES_AJ, 'tree/foo')
137
137
tree = self.create_shelvable_tree()
138
138
os.unlink('tree/foo')
139
139
shelver = ExpectShelver(tree, tree.basis_tree())
140
shelver.expect('Shelve removing file "foo"? [yNfq]', 'y')
141
shelver.expect('Shelve 1 change(s)? [yNfq]', 'y')
140
shelver.expect('Shelve removing file "foo"? [yNfq?]', 'y')
141
shelver.expect('Shelve 1 change(s)? [yNfq?]', 'y')
143
143
self.assertFileEqual(LINES_AJ, 'tree/foo')
148
148
self.build_tree(['tree/foo'])
150
150
shelver = ExpectShelver(tree, tree.basis_tree())
151
shelver.expect('Shelve adding file "foo"? [yNfq]', 'y')
152
shelver.expect('Shelve 1 change(s)? [yNfq]', 'y')
151
shelver.expect('Shelve adding file "foo"? [yNfq?]', 'y')
152
shelver.expect('Shelve 1 change(s)? [yNfq?]', 'y')
154
154
self.failIfExists('tree/foo')
158
158
os.unlink('tree/foo')
159
159
os.mkdir('tree/foo')
160
160
shelver = ExpectShelver(tree, tree.basis_tree())
161
shelver.expect('Shelve changing "foo" from file to directory? [yNfq]',
161
shelver.expect('Shelve changing "foo" from file to directory? [yNfq?]',
163
shelver.expect('Shelve 1 change(s)? [yNfq]', 'y')
163
shelver.expect('Shelve 1 change(s)? [yNfq?]', 'y')
165
165
def test_shelve_finish(self):
166
166
tree = self.create_shelvable_tree()
167
167
shelver = ExpectShelver(tree, tree.basis_tree())
168
shelver.expect('Shelve? [yNfq]', 'f')
169
shelver.expect('Shelve 2 change(s)? [yNfq]', 'y')
168
shelver.expect('Shelve? [yNfq?]', 'f')
169
shelver.expect('Shelve 2 change(s)? [yNfq?]', 'y')
171
171
self.assertFileEqual(LINES_AJ, 'tree/foo')
173
173
def test_shelve_quit(self):
174
174
tree = self.create_shelvable_tree()
175
175
shelver = ExpectShelver(tree, tree.basis_tree())
176
shelver.expect('Shelve? [yNfq]', 'q')
176
shelver.expect('Shelve? [yNfq?]', 'q')
177
177
self.assertRaises(errors.UserAbort, shelver.run)
178
178
self.assertFileEqual(LINES_ZY, 'tree/foo')
187
187
self.build_tree(['tree/bar'])
189
189
shelver = ExpectShelver(tree, tree.basis_tree(), file_list=['bar'])
190
shelver.expect('Shelve adding file "bar"? [yNfq]', 'y')
191
shelver.expect('Shelve 1 change(s)? [yNfq]', 'y')
190
shelver.expect('Shelve adding file "bar"? [yNfq?]', 'y')
191
shelver.expect('Shelve 1 change(s)? [yNfq?]', 'y')
194
def test_shelve_help(self):
195
tree = self.create_shelvable_tree()
196
shelver = ExpectShelver(tree, tree.basis_tree())
197
shelver.expect('Shelve? [yNfq?]', '?')
198
shelver.expect('Shelve? [(y)es, (N)o, (f)inish, or (q)uit]', 'f')
199
shelver.expect('Shelve 2 change(s)? [yNfq?]', 'y')