Пример #1
0
 def test_authenticationFileNonexistent(self):
     options_filepath = os.path.join(self._test_dir, "options.json")
     authentication_filepath = os.path.join(self._test_dir,
                                            "credentials.json")
     options = self.options
     _ = options.pop('webdav_login')
     _ = options.pop('webdav_password')
     options.update({'authenticationfile': authentication_filepath})
     with open(options_filepath, 'w') as f:
         json.dump(options, f)
     with self.assertRaises(FileNotFoundError):
         _ = get_wdclient(options_filepath)
Пример #2
0
 def test_validOptionsFromFileWithAuthenticaltionFile(self):
     options_filepath = os.path.join(self._test_dir, "options.json")
     authentication_filepath = os.path.join(self._test_dir,
                                            "credentials.json")
     options = self.options
     login = options.pop('webdav_login')
     passwd = options.pop('webdav_password')
     options.update({'authenticationfile': authentication_filepath})
     with open(options_filepath, 'w') as f:
         json.dump(options, f)
     authentication = {'webdav_login': login, 'webdav_password': passwd}
     with open(authentication_filepath, 'w') as f:
         json.dump(authentication, f)
     client = get_wdclient(options_filepath)
     self.assertIsInstance(client, Client)
Пример #3
0
 def test_invalidOptionType(self):
     options = list(self.options.values())
     with self.assertRaises(TypeError):
         _ = get_wdclient(options)
Пример #4
0
 def test_invalidFileFormat(self):
     filepath = os.path.join(self._test_dir, "options.txt")
     with open(filepath, 'w') as f:
         json.dump(self.options, f)
     with self.assertRaises(NotImplementedError):
         _ = get_wdclient(filepath)
Пример #5
0
 def test_optionFileNonexistent(self):
     filepath = os.path.join(self._test_dir, "options.json")
     with self.assertRaises(FileNotFoundError):
         _ = get_wdclient(filepath)
Пример #6
0
 def test_invalidOptions(self):
     options = self.options
     _ = options.pop('webdav_login')
     with self.assertRaises(RuntimeError):
         _ = get_wdclient(options)
Пример #7
0
 def test_validOptionsFromFile(self):
     filepath = os.path.join(self._test_dir, "options.json")
     with open(filepath, 'w') as f:
         json.dump(self.options, f)
     client = get_wdclient(filepath)
     self.assertIsInstance(client, Client)
Пример #8
0
 def test_validOptionsFromDictionary(self):
     client = get_wdclient(self.options)
     self.assertIsInstance(client, Client)
Пример #9
0
 def setup_webdav_client(self, webdav_options):
     self._wdclient = get_wdclient(webdav_options)
     return self