예제 #1
0
    def test_restore_default_config_file_copies_the_default_config_if_user_confirms(self, user_input_stub,
                                                                                    get_config_stub):
        default_config_file = open('data/.default_config.yaml', 'r')
        default_config_info = default_config_file.read()
        default_config_file.close()
        main.restore_default_config_file()
        config_file = open('data/test/fake_config.yaml', 'r')
        config_info = config_file.read()
        config_file.close()

        self.assertEqual(config_info, default_config_info)
        os.remove('data/test/fake_config.yaml')
예제 #2
0
 def test_restore_default_config_file_returns_1_if_exception_raised_during_restoration(self, user_input_stub,
                                                                                              open_func_stub):
     file_mock = Mock()
     open_func_stub.return_value = file_mock
     file_mock.write.assert_not_called()
     self.assertEqual(main.restore_default_config_file(), 1)
예제 #3
0
 def test_restore_default_config_file_returns_1_if_the_user_input_times_out(self, user_input_stub,
                                                                                   open_func_stub):
     self.assertEqual(main.restore_default_config_file(), 1)
예제 #4
0
 def test_restore_default_config_file_aborts_and_returns_1_if_the_user_input_times_out(self, user_input_stub,
                                                                                              open_func_stub):
     file_mock = Mock()
     open_func_stub.return_value = file_mock
     file_mock.write.assert_not_called()
     self.assertEqual(main.restore_default_config_file(), 1)
예제 #5
0
 def test_restore_default_config_file_returns_0_if_restored_successfully(self, user_input_stub,
                                                                                open_func_stub):
     file_mock = Mock()
     open_func_stub.return_value = file_mock
     self.assertEqual(main.restore_default_config_file(), 0)