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


Python AuthUserFactory.watch方法代码示例

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


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

示例1: TestAUser

# 需要导入模块: from tests.factories import AuthUserFactory [as 别名]
# 或者: from tests.factories.AuthUserFactory import watch [as 别名]
class TestAUser(OsfTestCase):
    def setUp(self):
        super(TestAUser, self).setUp()
        self.user = AuthUserFactory()
        self.auth = self.user.auth

    def test_can_see_profile_url(self):
        res = self.app.get(self.user.url).maybe_follow()
        assert_in(self.user.url, res)

    def test_can_see_homepage(self):
        # Goes to homepage
        res = self.app.get("/").maybe_follow()  # Redirects
        assert_equal(res.status_code, 200)

    def test_is_redirected_to_dashboard_already_logged_in_at_login_page(self):
        res = self.app.get("/login/", auth=self.user.auth)
        assert_equal(res.status_code, 302)
        res = res.follow(auth=self.user.auth)
        assert_equal(res.request.path, "/dashboard/")

    def test_sees_projects_in_her_dashboard(self):
        # the user already has a project
        project = ProjectFactory(creator=self.user)
        project.add_contributor(self.user)
        project.save()
        # Goes to homepage, already logged in
        res = self.app.get("/", auth=self.user.auth).follow(auth=self.user.auth)
        # Clicks Dashboard link in navbar
        res = res.click("My Dashboard", index=0, auth=self.user.auth)
        assert_in("Projects", res)  # Projects heading

    def test_does_not_see_osffiles_in_user_addon_settings(self):
        res = self.app.get("/settings/addons/", auth=self.auth, auto_follow=True)
        assert_not_in("OSF Storage", res)

    def test_sees_osffiles_in_project_addon_settings(self):
        project = ProjectFactory(creator=self.user)
        project.add_contributor(self.user, permissions=["read", "write", "admin"], save=True)
        res = self.app.get("/{0}/settings/".format(project._primary_key), auth=self.auth, auto_follow=True)
        assert_in("OSF Storage", res)

    @unittest.skip("Can't test this, since logs are dynamically loaded")
    def test_sees_log_events_on_watched_projects(self):
        # Another user has a public project
        u2 = UserFactory(username="[email protected]", fullname="Bono")
        project = ProjectFactory(creator=u2, is_public=True)
        project.add_contributor(u2)
        auth = Auth(user=u2)
        project.save()
        # User watches the project
        watch_config = WatchConfigFactory(node=project)
        self.user.watch(watch_config)
        self.user.save()
        # Goes to her dashboard, already logged in
        res = self.app.get("/dashboard/", auth=self.auth, auto_follow=True)
        # Sees logs for the watched project
        assert_in("Watched Projects", res)  # Watched Projects header
        # The log action is in the feed
        assert_in(project.title, res)

    def test_sees_correct_title_home_page(self):
        # User goes to homepage
        res = self.app.get("/", auto_follow=True)
        title = res.html.title.string
        # page title is correct
        assert_equal("OSF | Home", title)

    def test_sees_correct_title_on_dashboard(self):
        # User goes to dashboard
        res = self.app.get("/dashboard/", auth=self.auth, auto_follow=True)
        title = res.html.title.string
        assert_equal("OSF | Dashboard", title)

    def test_can_see_make_public_button_if_admin(self):
        # User is a contributor on a project
        project = ProjectFactory()
        project.add_contributor(self.user, permissions=["read", "write", "admin"], save=True)
        # User goes to the project page
        res = self.app.get(project.url, auth=self.auth).maybe_follow()
        assert_in("Make Public", res)

    def test_cant_see_make_public_button_if_not_admin(self):
        # User is a contributor on a project
        project = ProjectFactory()
        project.add_contributor(self.user, permissions=["read", "write"], save=True)
        # User goes to the project page
        res = self.app.get(project.url, auth=self.auth).maybe_follow()
        assert_not_in("Make Public", res)

    def test_can_see_make_private_button_if_admin(self):
        # User is a contributor on a project
        project = ProjectFactory(is_public=True)
        project.add_contributor(self.user, permissions=["read", "write", "admin"], save=True)
        # User goes to the project page
        res = self.app.get(project.url, auth=self.auth).maybe_follow()
        assert_in("Make Private", res)

    def test_cant_see_make_private_button_if_not_admin(self):
        # User is a contributor on a project
#.........这里部分代码省略.........
开发者ID:Alpani,项目名称:osf.io,代码行数:103,代码来源:webtest_tests.py

示例2: TestAUser

# 需要导入模块: from tests.factories import AuthUserFactory [as 别名]
# 或者: from tests.factories.AuthUserFactory import watch [as 别名]
class TestAUser(OsfTestCase):

    def setUp(self):
        super(TestAUser, self).setUp()
        self.user = AuthUserFactory()
        self.auth = self.user.auth

    def test_can_see_profile_url(self):
        res = self.app.get(self.user.url).maybe_follow()
        assert_in(self.user.url, res)

    def test_can_see_homepage(self):
        # Goes to homepage
        res = self.app.get('/').maybe_follow()  # Redirects
        assert_equal(res.status_code, 200)

    # `GET /login/` without parameters is redirected to `/dashboard/` page which has `@must_be_logged_in` decorator
    # if user is not logged in, she/he is further redirected to CAS login page
    def test_is_redirected_to_cas_if_not_logged_in_at_login_page(self):
        res = self.app.get('/login/').follow()
        assert_equal(res.status_code, 302)
        location = res.headers.get('Location')
        assert_in('login?service=', location)

    def test_is_redirected_to_dashboard_if_already_logged_in_at_login_page(self):
        res = self.app.get('/login/', auth=self.user.auth)
        assert_equal(res.status_code, 302)
        res = res.follow(auth=self.user.auth)
        assert_equal(res.request.path, '/dashboard/')

    def test_register_page(self):
        res = self.app.get('/register/')
        assert_equal(res.status_code, 200)

    def test_is_redirected_to_dashboard_if_already_logged_in_at_register_page(self):
        res = self.app.get('/register/', auth=self.user.auth)
        assert_equal(res.status_code, 302)
        res = res.follow(auth=self.user.auth)
        assert_equal(res.request.path, '/dashboard/')

    def test_sees_projects_in_her_dashboard(self):
        # the user already has a project
        project = ProjectFactory(creator=self.user)
        project.add_contributor(self.user)
        project.save()
        res = self.app.get('/myprojects/', auth=self.user.auth)
        assert_in('Projects', res)  # Projects heading

    def test_logged_in_index_route_renders_home_template(self):
        res = self.app.get('/', auth=self.user.auth)
        assert_equal(res.status_code, 200)
        assert_in('My Projects', res)  # Will change once home page populated

    def test_logged_out_index_route_renders_landing_page(self):
        res = self.app.get('/')
        assert_in('Simplified Scholarly Collaboration', res)

    def test_does_not_see_osffiles_in_user_addon_settings(self):
        res = self.app.get('/settings/addons/', auth=self.auth, auto_follow=True)
        assert_not_in('OSF Storage', res)

    def test_sees_osffiles_in_project_addon_settings(self):
        project = ProjectFactory(creator=self.user)
        project.add_contributor(
            self.user,
            permissions=['read', 'write', 'admin'],
            save=True)
        res = self.app.get('/{0}/settings/'.format(project._primary_key), auth=self.auth, auto_follow=True)
        assert_in('OSF Storage', res)

    @unittest.skip("Can't test this, since logs are dynamically loaded")
    def test_sees_log_events_on_watched_projects(self):
        # Another user has a public project
        u2 = UserFactory(username='[email protected]', fullname='Bono')
        project = ProjectFactory(creator=u2, is_public=True)
        project.add_contributor(u2)
        auth = Auth(user=u2)
        project.save()
        # User watches the project
        watch_config = WatchConfigFactory(node=project)
        self.user.watch(watch_config)
        self.user.save()
        # Goes to her dashboard, already logged in
        res = self.app.get('/dashboard/', auth=self.auth, auto_follow=True)
        # Sees logs for the watched project
        assert_in('Watched Projects', res)  # Watched Projects header
        # The log action is in the feed
        assert_in(project.title, res)

    def test_sees_correct_title_home_page(self):
        # User goes to homepage
        res = self.app.get('/', auto_follow=True)
        title = res.html.title.string
        # page title is correct
        assert_equal('OSF | Home', title)

    def test_sees_correct_title_on_dashboard(self):
        # User goes to dashboard
        res = self.app.get('/myprojects/', auth=self.auth, auto_follow=True)
        title = res.html.title.string
#.........这里部分代码省略.........
开发者ID:baylee-d,项目名称:osf.io,代码行数:103,代码来源:webtest_tests.py

示例3: TestAUser

# 需要导入模块: from tests.factories import AuthUserFactory [as 别名]
# 或者: from tests.factories.AuthUserFactory import watch [as 别名]
class TestAUser(OsfTestCase):

    def setUp(self):
        super(TestAUser, self).setUp()
        self.user = AuthUserFactory()
        self.auth = self.user.auth

    def test_can_see_profile_url(self):
        res = self.app.get(self.user.url).maybe_follow()
        assert_in(self.user.url, res)

    def test_can_see_homepage(self):
        # Goes to homepage
        res = self.app.get('/').maybe_follow()  # Redirects
        assert_equal(res.status_code, 200)

    def test_is_redirected_to_dashboard_already_logged_in_at_login_page(self):
        res = self.app.get('/login/', auth=self.user.auth)
        assert_equal(res.status_code, 302)
        res = res.follow(auth=self.user.auth)
        assert_equal(res.request.path, '/myprojects/')

    def test_sees_projects_in_her_dashboard(self):
        # the user already has a project
        project = ProjectFactory(creator=self.user)
        project.add_contributor(self.user)
        project.save()
        res = self.app.get('/myprojects/', auth=self.user.auth)
        assert_in('Projects', res)  # Projects heading

    def test_logged_in_index_route_renders_home_template(self):
        res = self.app.get('/', auth=self.user.auth)
        assert_equal(res.status_code, 200)
        assert_in('My Projects', res)  # Will change once home page populated

    def test_logged_out_index_route_renders_landing_page(self):
        res = self.app.get('/')
        assert_in('Simplified Scholarly Collaboration', res)

    def test_does_not_see_osffiles_in_user_addon_settings(self):
        res = self.app.get('/settings/addons/', auth=self.auth, auto_follow=True)
        assert_not_in('OSF Storage', res)

    def test_sees_osffiles_in_project_addon_settings(self):
        project = ProjectFactory(creator=self.user)
        project.add_contributor(
            self.user,
            permissions=['read', 'write', 'admin'],
            save=True)
        res = self.app.get('/{0}/settings/'.format(project._primary_key), auth=self.auth, auto_follow=True)
        assert_in('OSF Storage', res)

    @unittest.skip("Can't test this, since logs are dynamically loaded")
    def test_sees_log_events_on_watched_projects(self):
        # Another user has a public project
        u2 = UserFactory(username='[email protected]', fullname='Bono')
        project = ProjectFactory(creator=u2, is_public=True)
        project.add_contributor(u2)
        auth = Auth(user=u2)
        project.save()
        # User watches the project
        watch_config = WatchConfigFactory(node=project)
        self.user.watch(watch_config)
        self.user.save()
        # Goes to her dashboard, already logged in
        res = self.app.get('/dashboard/', auth=self.auth, auto_follow=True)
        # Sees logs for the watched project
        assert_in('Watched Projects', res)  # Watched Projects header
        # The log action is in the feed
        assert_in(project.title, res)

    def test_sees_correct_title_home_page(self):
        # User goes to homepage
        res = self.app.get('/', auto_follow=True)
        title = res.html.title.string
        # page title is correct
        assert_equal('OSF | Home', title)

    def test_sees_correct_title_on_dashboard(self):
        # User goes to dashboard
        res = self.app.get('/myprojects/', auth=self.auth, auto_follow=True)
        title = res.html.title.string
        assert_equal('OSF | My Projects', title)

    def test_can_see_make_public_button_if_admin(self):
        # User is a contributor on a project
        project = ProjectFactory()
        project.add_contributor(
            self.user,
            permissions=['read', 'write', 'admin'],
            save=True)
        # User goes to the project page
        res = self.app.get(project.url, auth=self.auth).maybe_follow()
        assert_in('Make Public', res)

    def test_cant_see_make_public_button_if_not_admin(self):
        # User is a contributor on a project
        project = ProjectFactory()
        project.add_contributor(
            self.user,
#.........这里部分代码省略.........
开发者ID:DanielSBrown,项目名称:osf.io,代码行数:103,代码来源:webtest_tests.py


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