当前位置: 首页>>代码示例>>Python>>正文


Python AuthUserFactory.delete_addon方法代码示例

本文整理汇总了Python中tests.factories.AuthUserFactory.delete_addon方法的典型用法代码示例。如果您正苦于以下问题:Python AuthUserFactory.delete_addon方法的具体用法?Python AuthUserFactory.delete_addon怎么用?Python AuthUserFactory.delete_addon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tests.factories.AuthUserFactory的用法示例。


在下文中一共展示了AuthUserFactory.delete_addon方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestUserSettings

# 需要导入模块: from tests.factories import AuthUserFactory [as 别名]
# 或者: from tests.factories.AuthUserFactory import delete_addon [as 别名]

#.........这里部分代码省略.........
        assert_false(
            self.user_settings.verify_oauth_access(
                external_account=self.external_account,
                node=self.project,
                metadata={'baz': 'qiz'}
            )
        )

    def test_verify_true(self):
        self.user_settings.grant_oauth_access(
            external_account=self.external_account,
            node=self.project
        )

        assert_true(
            self.user_settings.verify_oauth_access(
                external_account=self.external_account,
                node=self.project
            )
        )

    def test_verify_true_with_metadata(self):
        self.user_settings.grant_oauth_access(
            external_account=self.external_account,
            node=self.project,
            metadata={'foo': 'bar'}
        )

        assert_true(
            self.user_settings.verify_oauth_access(
                external_account=self.external_account,
                node=self.project,
                metadata={'foo': 'bar'}
            )
        )

    def test_grant(self):
        self.user_settings.grant_oauth_access(
            external_account=self.external_account,
            node=self.project
        )

        assert_equal(
            self.user_settings.oauth_grants,
            {
                self.project._id: {
                    self.external_account._id: {}
                }
            }
        )

    def test_grant_not_owned(self):
        self.user.external_accounts = []

        with assert_raises(PermissionsError):
            self.user_settings.grant_oauth_access(
                external_account=self.external_account,
                node=self.project
            )

        assert_equal(
            self.user_settings.oauth_grants,
            {}
        )

    def test_grant_metadata(self):
        self.user_settings.grant_oauth_access(
            external_account=self.external_account,
            node=self.project,
            metadata={'foo': 'bar'}
        )

        assert_equal(
            self.user_settings.oauth_grants,
            {
                self.project._id: {
                    self.external_account._id: {'foo': 'bar'}
                }
            }
        )

    def test_on_delete(self):
        node_settings = self.project.get_or_add_addon(
            MockUserSettings.oauth_provider.short_name,
            auth=Auth(user=self.user)
        )

        node_settings.set_auth(
            external_account=self.external_account,
            user=self.user
        )

        self.user.delete_addon(
            MockUserSettings.oauth_provider.short_name
        )

        node_settings.reload()

        assert_is_none(node_settings.external_account)
        assert_is_none(node_settings.user_settings)
开发者ID:GageGaskins,项目名称:osf.io,代码行数:104,代码来源:test_addons_oauth.py


注:本文中的tests.factories.AuthUserFactory.delete_addon方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。