-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
57 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import os | ||
import unittest | ||
|
||
from hyo2.abc2.lib.testing import Testing | ||
from hyo2.abc2.lib.onedrive import OneDrive | ||
|
||
|
||
class TestABCOneDrive(unittest.TestCase): | ||
|
||
def test_init(self): | ||
_ = OneDrive() | ||
|
||
def test_download_and_unzip(self): | ||
onedrive_link = r"https://universitysystemnh-my.sharepoint.com/:u:/g/personal/" \ | ||
r"gma72_usnh_edu/EabgRi9pTtdEvIVDXoEXHOYBH4FBHtN07i_8VkjpAAstYQ?e=Wn7q98&download=1" | ||
|
||
root_folder = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir) | ||
tp = Testing(root_folder=root_folder) | ||
zip_path = os.path.join(tp.output_data_folder(), "test.zip") | ||
unzip_path = os.path.join(tp.output_data_folder(), "test.txt") | ||
|
||
if os.path.exists(zip_path): | ||
os.remove(zip_path) | ||
if os.path.exists(unzip_path): | ||
os.remove(unzip_path) | ||
|
||
od = OneDrive(show_progress=True, debug_mode=True) | ||
od.get_file(file_src=onedrive_link, file_dst=zip_path, unzip_it=True) | ||
|
||
if os.path.exists(unzip_path): | ||
with open(unzip_path) as fid: | ||
text = fid.read().strip() | ||
self.assertEqual(text, "test") | ||
|
||
|
||
def suite(): | ||
s = unittest.TestSuite() | ||
s.addTests(unittest.TestLoader().loadTestsFromTestCase(TestABCOneDrive)) | ||
return s |