Esempio n. 1
0
 def test_eq(self):
     file1 = FileInfo(self.fss_api, self.dev_id, '/a/path/file1.txt', 1436276773, 7989,
                      "967FDA522517B9CE0C3E056EDEB485BB", 'md5')
     file2 = FileInfo(self.fss_api, self.dev_id, '/a/path/file1.txt', 1436276773, 7989,
                      "967FDA522517B9CE0C3E056EDEB485BB", 'md5')
     self.assertEqual(file1, file2)
     self.assertFalse(file1 is file2)
Esempio n. 2
0
 def test_delete(self):
     self.fss_api.delete_file.side_effect = ({self.dev_id: None},)
     file1 = FileInfo(self.fss_api, self.dev_id, '/a/path/file1.txt', 1436276773, 7989,
                      "967FDA522517B9CE0C3E056EDEB485BB", 'md5')
     self.assertIsNone(file1.delete())
     self.assertEqual(1, self.fss_api.delete_file.call_count)
     call_name, call_args, call_kwargs = self.fss_api.delete_file.mock_calls[0]
     self.assertEqual(call_args[0]._device_id, self.dev_id)
     self.assertEqual(call_args[1], '/a/path/file1.txt')
Esempio n. 3
0
 def test_parse(self):
     fss_api = mock.Mock()
     dev_id = 'my_dev_id'
     file1 = FileInfo(fss_api, dev_id, '/a/path/file1.txt', 1436276773, 7989,
                      "967FDA522517B9CE0C3E056EDEB485BB", 'md5')
     file2 = FileInfo(fss_api, dev_id, '/a/path/file2.py', 1434377919, 181,
                      "DEA17715739E46079C1A6DDCB38344DF", 'md5')
     dir1 = DirectoryInfo(fss_api, dev_id, '/a/path/dir', 1436203917)
     linfo = LsCommand.parse_response(ET.fromstring(LS_BLOCK), device_id=dev_id, fssapi=fss_api)
     self.assertEqual(linfo, LsInfo(directories=[dir1], files=[file1, file2]))
Esempio n. 4
0
 def test_get_data_error(self):
     error = ErrorInfo(1, "error message")
     self.fss_api.get_file.side_effect = ({self.dev_id: error},)
     file1 = FileInfo(self.fss_api, self.dev_id, '/a/path/file1.txt', 1436276773, 7989,
                      "967FDA522517B9CE0C3E056EDEB485BB", 'md5')
     self.assertEqual(error, file1.get_data())
     self.assertEqual(1, self.fss_api.get_file.call_count)
     call_name, call_args, call_kwargs = self.fss_api.get_file.mock_calls[0]
     self.assertEqual(call_args[0]._device_id, self.dev_id)
     self.assertEqual(call_args[1], '/a/path/file1.txt')
Esempio n. 5
0
 def test_list_contents(self):
     file1 = FileInfo(self.fss_api, self.dev_id, '/a/path/file1.txt', 1436276773, 7989,
                      "967FDA522517B9CE0C3E056EDEB485BB", 'md5')
     file2 = FileInfo(self.fss_api, self.dev_id, '/a/path/file1.txt', 1436276773, 7989,
                      "967FDA522517B9CE0C3E056EDEB485BB", 'md5')
     self.fss_api.list_files.side_effect = ({self.dev_id: LsInfo([], [file1, file2])},)
     dir1 = DirectoryInfo(self.fss_api, self.dev_id, '/a/path/dir1', 1436276773)
     dirs, files = dir1.list_contents()
     self.assertEqual(0, len(dirs))
     self.assertListEqual([file1, file2], files)
     self.assertEqual(1, self.fss_api.list_files.call_count)
     call_name, call_args, call_kwargs = self.fss_api.list_files.mock_calls[0]
     self.assertEqual(call_args[0]._device_id, self.dev_id)
     self.assertEqual(call_args[1], '/a/path/dir1')
Esempio n. 6
0
    def setUp(self):
        HttpTestBase.setUp(self)
        self.fss_api = self.dc.get_fss_api()
        self.sci_api = mock.Mock()
        self.fss_api._sci_api = self.sci_api
        self.target = AllTarget()
        self.dev1_id = '00000000-00000000-18A905FF-FF2F1BBD'
        self.dev2_id = '00000000-00000000-18A905FF-FF2F1BBE'

        # Create some file, directory, and error info objects to use in tests
        self.file1 = FileInfo(self.fss_api, self.dev1_id, '/a/path/file1.txt', 1436276773, 7989,
                              "967FDA522517B9CE0C3E056EDEB485BB", 'md5')
        self.file2 = FileInfo(self.fss_api, self.dev1_id, '/a/path/file2.py', 1434377919, 181,
                              "DEA17715739E46079C1A6DDCB38344DF", 'md5')
        self.dir1 = DirectoryInfo(self.fss_api, self.dev1_id, '/a/path/dir', 1436203917)
        self.errinfo = ErrorInfo(errno=1, message="an error message")
Esempio n. 7
0
 def test_eq_not_eq(self):
     file1 = FileInfo(self.fss_api, self.dev_id, '/a/path/file1.txt', 1436276773, 7989,
                      "967FDA522517B9CE0C3E056EDEB485BB", 'md5')
     file2 = FileInfo(self.fss_api, self.dev_id, '/a/path/file2.py', 1434377919, 181,
                      "DEA17715739E46079C1A6DDCB38344DF", 'md5')
     self.assertNotEqual(file1, file2)
Esempio n. 8
0
 def clone_file(self, orig_file):
     return FileInfo(orig_file._fssapi, orig_file.device_id, orig_file.path,
                     orig_file.last_modified, orig_file.size, orig_file.hash, orig_file.hash_type)