This repository has been archived by the owner on Feb 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Xiangyu Bu <[email protected]>
- Loading branch information
Showing
8 changed files
with
137 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"account_id": "acct_id", | ||
"drive_id": "drive_id", | ||
"ignorefile_path": "/home/xb/.config/onedrived/ignore_v2.txt", | ||
"localroot_path": "/home/xb/OneDrive" | ||
} |
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,7 @@ | ||
{ | ||
"total": 1000, | ||
"used": 100, | ||
"remaining": 900, | ||
"deleted": 500, | ||
"state": "normal" | ||
} |
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,16 @@ | ||
import unittest | ||
|
||
from onedrived import od_context | ||
|
||
|
||
class TestUserContext(unittest.TestCase): | ||
|
||
def setUp(self): | ||
self.ctx = od_context.UserContext(loop=None) | ||
|
||
def test_get_login_username(self): | ||
self.assertIsInstance(od_context.get_login_username(), str) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
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,44 @@ | ||
import unittest | ||
|
||
from onedrived import od_task | ||
from onedrived import tasks | ||
|
||
|
||
class TestTaskPool(unittest.TestCase): | ||
|
||
def _get_dummy_task(self, local_abspath=None): | ||
t = tasks.base.TaskBase(repo=None, task_pool=self.task_pool) | ||
t.local_abspath = local_abspath | ||
return t | ||
|
||
def setUp(self): | ||
self.task_pool = od_task.TaskPool() | ||
|
||
def test_add_and_pop(self): | ||
ts = [self._get_dummy_task(local_abspath='/1'), self._get_dummy_task(local_abspath='/2')] | ||
for i, t in enumerate(ts): | ||
self.assertEqual(i, self.task_pool.outstanding_task_count) | ||
self.assertTrue(self.task_pool.add_task(t)) | ||
self.assertEqual(2, self.task_pool.outstanding_task_count) | ||
self.assertFalse(self.task_pool.add_task(self._get_dummy_task(local_abspath='/1'))) | ||
for i, t in enumerate(ts): | ||
self.assertIs(t, self.task_pool.pop_task()) | ||
self.assertEqual(len(ts) - i - 1, self.task_pool.outstanding_task_count) | ||
self.assertEqual(0, self.task_pool.outstanding_task_count) | ||
|
||
def test_has_pending_task(self): | ||
self.task_pool.add_task(self._get_dummy_task(local_abspath='/foo/bar')) | ||
self.assertTrue(self.task_pool.has_pending_task('/foo/bar')) | ||
for s in ('/foo/ba', '/foo/barz', '/foo/bar/baz', '/foo'): | ||
self.assertFalse(self.task_pool.has_pending_task(s)) | ||
|
||
def test_remove_children_tasks(self): | ||
for s in ('/foo', '/foo2', '/foo/bar', '/foo2/bar', '/foo/bar/baz'): | ||
self.task_pool.add_task(self._get_dummy_task(local_abspath=s)) | ||
self.task_pool.remove_children_tasks(local_parent_path='/foo') | ||
self.assertEqual(2, self.task_pool.outstanding_task_count) | ||
self.assertEqual('/foo2', self.task_pool.pop_task().local_abspath) | ||
self.assertEqual('/foo2/bar', self.task_pool.pop_task().local_abspath) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |
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,17 @@ | ||
import unittest | ||
|
||
from onedrived import od_task | ||
from onedrived import tasks | ||
|
||
|
||
class TestTaskBase(unittest.TestCase): | ||
|
||
def test_task_base(self): | ||
p = '/home/xb/123' | ||
base = tasks.base.TaskBase(repo=None, task_pool=od_task.TaskPool()) | ||
base.local_abspath = p | ||
self.assertEqual(p, base.local_abspath) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |