Пример #1
0
class AccountTest(CloudFSTestCase):

    FORBIDDEN_SETTERS = ['id', 'storage_usage', 'state_display_name', 'state_id',
                           'plan_id', 'over_storage_limit', 'storage_usage',
                           'storage_limit', 'plan_display_name']

    def setUp(self):
        self.s = Session(self.CLOUDFS_BASE,
                self.CLOUDFS_ID,
                self.CLOUDFS_SECRET)

        self.assertRaises(
            errors.CloudFSError,
            self.s.account
        )

        self.s.authenticate(self.TEST_USER_EMAIL, self.TEST_USER_PASSWORD)
        self.assertEqual(True, self.s.is_linked(), "Authentication failed.")

    def get_example_object(self):
        return self.s.account()

    def test_account(self):
        acct = self.get_example_object()
        # basic field check
        self.assertTrue(acct.storage_usage >= 0, 'Usage expected to be above 0!')
        self.assertTrue(acct.storage_limit >= 0)
        self.assertEqual(acct.plan_display_name, u'CloudFS End User', 'Account should be CloudFS End User Apparently!')
        self.assertTrue(acct.id is not '', 'Empty account id.')
        self.assertEqual(acct.storage_usage > acct.storage_limit, acct.over_storage_limit, 'Over storage limit flag does not reflect storage numbers!')
        self.assertEqual(acct.state_display_name, 'Active', 'Account is active!')
        self.assertTrue(acct.session_locale != '', 'Session locale not set!')
        self.assertTrue(acct.locale != '', 'Account locale not set!')
    def test_ping(self):
        s = Session(self.CLOUDFS_BASE,
                self.CLOUDFS_ID,
                self.CLOUDFS_SECRET)

        self.assertEqual(False, s.is_linked())
        s.authenticate(self.TEST_USER_EMAIL, self.TEST_USER_PASSWORD)
        self.assertEqual(True, s.is_linked())
Пример #3
0
class SessionTestCase(CloudFSTestCase):
    def setUp(self):
        self.s = Session(self.CLOUDFS_BASE,
                self.CLOUDFS_ID,
                self.CLOUDFS_SECRET)

        self.s.authenticate(self.TEST_USER_EMAIL, self.TEST_USER_PASSWORD)
        self.assertEqual(True, self.s.is_linked(), "Authentication failed.")
    def test_history(self):
        s = Session(self.CLOUDFS_BASE,
                self.CLOUDFS_ID,
                self.CLOUDFS_SECRET)

        s.authenticate(self.TEST_USER_EMAIL, self.TEST_USER_PASSWORD)

        history = s.action_history(start_version = -10)
        self.assertTrue(len(history) <= 10)
    def test_set_access_token(self):
        s = Session(self.CLOUDFS_BASE,
                self.CLOUDFS_ID,
                self.CLOUDFS_SECRET)

        s.authenticate(self.TEST_USER_EMAIL, self.TEST_USER_PASSWORD)

        s2 = Session(self.CLOUDFS_BASE,
                self.CLOUDFS_ID,
                self.CLOUDFS_SECRET)

        s2.set_access_token(s.rest_interface.bc_conn.auth_token)

        s2.is_linked()
    def test_base_formatting(self):
        base_versions = [
            'http://' + self.CLOUDFS_BASE,
            'https://' + self.CLOUDFS_BASE,
            'http://www.' + self.CLOUDFS_BASE,
            'www.' + self.CLOUDFS_BASE
        ]

        for version in base_versions:
            s = Session(version,
                self.CLOUDFS_ID,
                self.CLOUDFS_SECRET)
            self.assertEqual(False, s.is_linked())
            s.authenticate(self.TEST_USER_EMAIL, self.TEST_USER_PASSWORD)
            self.assertEqual(True, s.is_linked())
Пример #7
0
class UserTests(CloudFSTestCase):

    FORBIDDEN_SETTERS = ['id', 'username', 'last_login', 'created_at']
    UNIMPLEMENTED_SETTERS = ['email', 'first_name', 'last_name']

    def setUp(self):
        self.s = Session(self.CLOUDFS_BASE,
                self.CLOUDFS_ID,
                self.CLOUDFS_SECRET)

        self.assertRaises(
            errors.CloudFSError,
            self.s.user
        )

        self.s.authenticate(self.TEST_USER_EMAIL, self.TEST_USER_PASSWORD)
        self.assertEqual(True, self.s.is_linked(), "Authentication failed.")

    def tearDown(self):
        self.s.unlink()

    def get_example_object(self):
        return self.s.user()

    # def test_create_user(self):
    #     self.s.set_admin_credentials(self.ADMIN_ID, self.ADMIN_SECRET)
    #     self.s.create_account('test6', '111111')

    def test_user(self):
        # intended to test basic funnctionality
        user = self.get_example_object()
        self.assertEqual('', user.email, 'Email is not blank!')
        self.assertEqual(self.TEST_USER_EMAIL, user.username, 'Username is not the one set in the admin panel')
        # last_login is in ms
        self.assertEqual(datetime.date.today(), datetime.date.fromtimestamp(user.last_login/1000), 'Last login is not today!')
        self.assertTrue(user.id != '', 'Missing user id!')
        self.assertTrue(user.created_at != '', 'Missing user creation time!')

    def test_user_stub(self):
        self.assertRaises(
            errors.MethodNotImplemented,
            self.get_example_object().save
        )
    def test_authenticate(self):
        s = Session(self.CLOUDFS_BASE,
                self.CLOUDFS_ID,
                self.CLOUDFS_SECRET)

        s.authenticate(self.TEST_USER_EMAIL, self.TEST_USER_PASSWORD)