コード例 #1
0
 def test_process_file_existing_file(self):
     files = set()
     # Existing file
     sync_drive.download_file(item=self.file_item, local_file=self.local_file_path)
     self.assertFalse(
         sync_drive.process_file(
             item=self.file_item,
             destination_path=self.destination_path,
             filters=self.filters,
             files=files,
         )
     )
コード例 #2
0
    def test_download_file(self):
        self.assertTrue(
            sync_drive.download_file(
                item=self.file_item, local_file=self.local_file_path
            )
        )

        # Verbose
        with self.assertLogs() as captured:
            self.assertTrue(
                sync_drive.download_file(
                    item=self.file_item, local_file=self.local_file_path
                )
            )
            self.assertTrue(len(captured.records) > 0)
            self.assertIn("Downloading ", captured.records[0].getMessage())
コード例 #3
0
 def test_file_existing_file(self):
     # File exists
     sync_drive.download_file(item=self.file_item, local_file=self.local_file_path)
     actual = sync_drive.file_exists(
         item=self.file_item, local_file=self.local_file_path
     )
     self.assertTrue(actual)
     # Verbose
     sync_drive.download_file(item=self.file_item, local_file=self.local_file_path)
     with self.assertLogs(logger=LOGGER, level="DEBUG") as captured:
         actual = sync_drive.file_exists(
             item=self.file_item, local_file=self.local_file_path
         )
         self.assertTrue(actual)
         self.assertTrue(len(captured.records) > 0)
         self.assertIn("No changes detected.", captured.records[0].getMessage())
コード例 #4
0
 def test_download_file_key_error_data_token(self):
     with patch.object(self.file_item, "open") as mock_item:
         mock_item.side_effect = KeyError("data_token")
         self.assertFalse(
             sync_drive.download_file(
                 item=self.file_item, local_file=self.local_file_path
             )
         )
コード例 #5
0
 def test_download_file_non_existing(self):
     self.assertFalse(
         sync_drive.download_file(
             item=self.file_item,
             local_file=os.path.join(
                 self.destination_path, "non-existent-folder", self.file_name
             ),
         )
     )
コード例 #6
0
 def test_download_file_none_local_file(self):
     self.assertFalse(sync_drive.download_file(item=self.file_item, local_file=None))
コード例 #7
0
 def test_download_file_none_item(self):
     self.assertFalse(
         sync_drive.download_file(item=None, local_file=self.local_file_path)
     )