Esempio n. 1
0
__author__ = 'xb'

import unittest

from onedrive_d.api import drives
from onedrive_d.common.drive_config import DriveConfig
from onedrive_d.store import drives_db
from onedrive_d.tests import get_data
from onedrive_d.tests.api.account_factory import get_sample_personal_account
from onedrive_d.tests.mocks import mock_atexit
from onedrive_d.tests.mocks import mock_logger
from onedrive_d.tests.store.test_account_db import get_sample_account_storage

mock_atexit.mock_register()
mock_logger.mock_loggers()


class TestDriveStorage(unittest.TestCase):
    def setUp(self):
        self.personal_account = get_sample_personal_account()
        self.account_store = get_sample_account_storage(self.personal_account.client, None)
        self.account_store.add_account(self.personal_account)
        self.drives_store = drives_db.DriveStorage(':memory:', self.account_store)
        self.drive_root = self.drives_store.get_drive_root(
            self.personal_account.profile.user_id, self.personal_account.TYPE)

    def test_get_drive_root(self):
        self.assertIsInstance(self.drive_root, drives.DriveRoot)
        self.assertIs(self.drive_root.account, self.personal_account)

    def test_get_all_drives(self):
Esempio n. 2
0
__author__ = 'xb'

import os
import sys
import unittest

from onedrive_d.common import drive_config
from onedrive_d.common import path_filter
from onedrive_d.tests import assert_factory
from onedrive_d.tests import get_data
from onedrive_d.tests.mocks import mock_logger

mock_logger.mock_loggers()


class TestDriveConfig(unittest.TestCase):
    data = get_data('drive_config.json')
    conf = drive_config.DriveConfig(data)

    def test_parse(self):
        assert_factory.assert_dict_equals_attributes(self, self.data, self.conf)

    def test_append_default_values(self):
        del self.data['max_get_size_bytes']
        conf = drive_config.DriveConfig(self.data)
        self.assertEqual(drive_config.DriveConfig.DEFAULT_VALUES['max_get_size_bytes'], conf.max_get_size_bytes)

    def test_serialize(self):
        dump = self.conf.dump()
        new_conf = drive_config.DriveConfig(dump)
        for k, v in self.data.items():