def test_migration(self):
        GoogleDriveUserSettings.remove()

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

        user.external_accounts = [account]

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


        node.add_addon('googledrive', auth=Auth(user))
        node_addon = node.get_addon('googledrive')
        node_addon.foreign_user_settings = user_addon
        node_addon.folder_id = 'abcdef0'
        node_addon.folder_path = '/'
        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 Google Drive)')
 def test_get_targets(self):
     GoogleDriveUserSettings.remove()
     addons = [
         GoogleDriveUserSettings(),
         GoogleDriveUserSettings(oauth_settings=GoogleDriveOAuthSettingsFactory()),
     ]
     for addon in addons:
         addon.save()
     targets = get_targets()
     assert_equal(targets.count(), 1)
     assert_equal(targets[0]._id, addons[-1]._id)
 def test_get_targets(self):
     GoogleDriveUserSettings.remove()
     addons = [
         GoogleDriveUserSettings(),
         GoogleDriveUserSettings(
             oauth_settings=GoogleDriveOAuthSettingsFactory()),
     ]
     for addon in addons:
         addon.save()
     targets = get_targets()
     assert_equal(targets.count(), 1)
     assert_equal(targets[0]._id, addons[-1]._id)
    def test_migration_no_account(self):
        GoogleDriveUserSettings.remove()

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

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

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

        do_migration()  # Would raise exception if fail
    def test_migration_removes_targets(self):
        GoogleDriveUserSettings.remove()

        user = UserFactory()
        project = ProjectFactory(creator=user)

        user.add_addon('googledrive', auth=Auth(user))
        user_addon = user.get_addon('googledrive')
        user_addon.oauth_settings = GoogleDriveOAuthSettingsFactory()
        user_addon.save()

        project.add_addon('googledrive', auth=Auth(user))
        node_addon = project.get_addon('googledrive')
        node_addon.foreign_user_settings = user_addon
        node_addon.save()

        assert_equal(get_targets().count(), 1)

        do_migration([user_addon])
        user_addon.reload()

        assert_equal(get_targets().count(), 0)
    def test_migration_removes_targets(self):
        GoogleDriveUserSettings.remove()

        user = UserFactory()
        project = ProjectFactory(creator=user)


        user.add_addon('googledrive', auth=Auth(user))
        user_addon = user.get_addon('googledrive')
        user_addon.oauth_settings = GoogleDriveOAuthSettingsFactory()
        user_addon.save()


        project.add_addon('googledrive', auth=Auth(user))
        node_addon = project.get_addon('googledrive')
        node_addon.foreign_user_settings = user_addon
        node_addon.save()

        assert_equal(get_targets().count(), 1)

        do_migration([user_addon])
        user_addon.reload()

        assert_equal(get_targets().count(), 0)
Esempio n. 7
0
 def tearDown(self):
     GitHubNodeSettings.remove()
     GitHubUserSettings.remove()
     GoogleDriveNodeSettings.remove()
     GoogleDriveUserSettings.remove()
Esempio n. 8
0
 def tearDown(self):
     GitHubNodeSettings.remove()
     GitHubUserSettings.remove()
     GoogleDriveNodeSettings.remove()
     GoogleDriveUserSettings.remove()