def test_migration(self):
        BoxUserSettings.remove()

        user = UserFactory()
        node = ProjectFactory(creator=user)
        account = BoxAccountFactory()

        user.external_accounts = [account]

        user.add_addon('box', auth=Auth(user))
        user_addon = user.get_addon('box')
        user_addon.save()


        node.add_addon('box', auth=Auth(user))
        node_addon = node.get_addon('box')
        node_addon.foreign_user_settings = user_addon
        node_addon.folder_id = 'abcdef0'
        node_addon.folder_path = '/'
        node_addon.folder_name = '/ (Full Box)'
        node_addon.save()

        assert_equal(node_addon.external_account, None)
        assert_equal(node_addon.folder_id, 'abcdef0')

        do_migration()
        node_addon.reload()

        assert_equal(node_addon.external_account, account)
        assert_equal(node_addon.folder_id, 'abcdef0')
        assert_equal(node_addon.folder_path, '/')
        assert_equal(node_addon.folder_name, '/ (Full Box)')
Beispiel #2
0
    def test_fields(self):
        oauth_settings = BoxOAuthSettings(user_id='foo', username='bar', access_token='defined')
        oauth_settings.save()
        user_settings = BoxUserSettings(owner=self.user, oauth_settings=oauth_settings)

        user_settings.save()
        retrieved = BoxUserSettings.load(user_settings._id)

        assert_true(retrieved.owner)
        assert_true(retrieved.user_id)
        assert_true(retrieved.username)
        assert_true(retrieved.access_token)
    def test_migration_no_account(self):
        BoxUserSettings.remove()

        user = UserFactory()
        node = ProjectFactory(creator=user)

        user.add_addon('box', auth=Auth(user))
        user_addon = user.get_addon('box')
        user_addon.save()

        node.add_addon('box', auth=Auth(user))
        node_addon = node.get_addon('box')
        node_addon.foreign_user_settings = user_addon
        node_addon.save()

        do_migration()  # Would raise exception if fail
 def tearDown(self):
     super(TestBoxMigration, self).tearDown()
     BoxUserSettings.remove()
     ExternalAccount.remove()
def get_targets():
    return BoxUserSettings.find(
        Q('oauth_settings', 'ne', None)
    )