當前位置: 首頁>>代碼示例>>Python>>正文


Python DropboxNodeSettingsFactory.after_remove_contributor方法代碼示例

本文整理匯總了Python中website.addons.dropbox.tests.factories.DropboxNodeSettingsFactory.after_remove_contributor方法的典型用法代碼示例。如果您正苦於以下問題:Python DropboxNodeSettingsFactory.after_remove_contributor方法的具體用法?Python DropboxNodeSettingsFactory.after_remove_contributor怎麽用?Python DropboxNodeSettingsFactory.after_remove_contributor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在website.addons.dropbox.tests.factories.DropboxNodeSettingsFactory的用法示例。


在下文中一共展示了DropboxNodeSettingsFactory.after_remove_contributor方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: TestNodeSettingsCallbacks

# 需要導入模塊: from website.addons.dropbox.tests.factories import DropboxNodeSettingsFactory [as 別名]
# 或者: from website.addons.dropbox.tests.factories.DropboxNodeSettingsFactory import after_remove_contributor [as 別名]
class TestNodeSettingsCallbacks(OsfTestCase):
    def setUp(self):
        super(TestNodeSettingsCallbacks, self).setUp()
        # Create node settings with auth
        self.user_settings = DropboxUserSettingsFactory(access_token="123abc")
        self.node_settings = DropboxNodeSettingsFactory(user_settings=self.user_settings, folder="")

        self.project = self.node_settings.owner
        self.user = self.user_settings.owner

    def test_after_fork_by_authorized_dropbox_user(self):
        fork = ProjectFactory()
        clone, message = self.node_settings.after_fork(node=self.project, fork=fork, user=self.user_settings.owner)
        assert_equal(clone.user_settings, self.user_settings)

    def test_after_fork_by_unauthorized_dropbox_user(self):
        fork = ProjectFactory()
        user = UserFactory()
        clone, message = self.node_settings.after_fork(node=self.project, fork=fork, user=user, save=True)
        # need request context for url_for
        assert_is(clone.user_settings, None)

    def test_before_fork(self):
        node = ProjectFactory()
        message = self.node_settings.before_fork(node, self.user)
        assert_true(message)

    def test_before_remove_contributor_message(self):
        message = self.node_settings.before_remove_contributor(self.project, self.user)
        assert_true(message)
        assert_in(self.user.fullname, message)
        assert_in(self.project.project_or_component, message)

    def test_after_remove_authorized_dropbox_user_self(self):
        auth = Auth(user=self.user_settings.owner)
        message = self.node_settings.after_remove_contributor(self.project, self.user_settings.owner, auth)
        self.node_settings.save()
        assert_is_none(self.node_settings.user_settings)
        assert_true(message)
        assert_not_in("You can re-authenticate", message)

    def test_after_remove_authorized_dropbox_user_not_self(self):
        message = self.node_settings.after_remove_contributor(node=self.project, removed=self.user_settings.owner)
        self.node_settings.save()
        assert_is_none(self.node_settings.user_settings)
        assert_true(message)
        assert_in("You can re-authenticate", message)

    def test_after_delete(self):
        self.project.remove_node(Auth(user=self.project.creator))
        # Ensure that changes to node settings have been saved
        self.node_settings.reload()
        assert_true(self.node_settings.user_settings is None)
        assert_true(self.node_settings.folder is None)
開發者ID:rmoorman,項目名稱:osf.io,代碼行數:56,代碼來源:test_models.py


注:本文中的website.addons.dropbox.tests.factories.DropboxNodeSettingsFactory.after_remove_contributor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。