@@ -165,19 +165,19 @@ def test_show_list(self, mock_show):
165165 self .device .show (commands )
166166 self .device .show .assert_called_with (commands )
167167
168+ @mock .patch ("pyntc.devices.jnpr_device.JunosDevice.startup_config" , new_callable = mock .PropertyMock )
168169 @mock .patch ("pyntc.devices.jnpr_device.SCP" , autospec = True )
169- def test_save (self , mock_scp ):
170- self .device .show = mock .MagicMock ()
171- self .device .show .return_value = b"file contents"
170+ def test_save (self , mock_scp , mock_startup_config ):
171+ mock_startup_config .return_value = "file contents"
172172
173173 result = self .device .save (filename = "saved_config" )
174174
175175 self .assertTrue (result )
176- self . device . show . assert_called_with ( "show config" )
176+ mock_startup_config . assert_called_once_with ( )
177177
178178 def test_file_copy_remote_exists (self ):
179- temp_file = NamedTemporaryFile ()
180- temp_file .write (b "file contents" )
179+ temp_file = NamedTemporaryFile (mode = "w" )
180+ temp_file .write ("file contents" )
181181 temp_file .flush ()
182182
183183 local_checksum = "4a8ec4fa5f01b4ab1a0ab8cbccb709f0"
@@ -189,8 +189,8 @@ def test_file_copy_remote_exists(self):
189189 self .device .fs .checksum .assert_called_with ("dest" )
190190
191191 def test_file_copy_remote_exists_failure (self ):
192- temp_file = NamedTemporaryFile ()
193- temp_file .write (b "file contents" )
192+ temp_file = NamedTemporaryFile (mode = "w" )
193+ temp_file .write ("file contents" )
194194 temp_file .flush ()
195195
196196 self .device .fs .checksum .return_value = "deadbeef"
@@ -202,8 +202,8 @@ def test_file_copy_remote_exists_failure(self):
202202
203203 @mock .patch ("pyntc.devices.jnpr_device.SCP" )
204204 def test_file_copy (self , mock_scp ):
205- temp_file = NamedTemporaryFile ()
206- temp_file .write (b "file contents" )
205+ temp_file = NamedTemporaryFile (mode = "w" )
206+ temp_file .write ("file contents" )
207207 temp_file .flush ()
208208
209209 local_checksum = "4a8ec4fa5f01b4ab1a0ab8cbccb709f0"
@@ -241,7 +241,7 @@ def test_rollback(self, mock_scp):
241241 @mock .patch ("pyntc.devices.jnpr_device.SCP" , autospec = True )
242242 def test_checkpoint (self , mock_scp ):
243243 self .device .show = mock .MagicMock ()
244- self .device .show .return_value = b "file contents"
244+ self .device .show .return_value = "file contents"
245245 self .device .checkpoint ("saved_config" )
246246 self .device .show .assert_called_with ("show config" )
247247
0 commit comments