示例#1
0
    def setUp(self):
        super(PageHandlerTest, self).setUp()
        self.oauth_stub = OAuthStub(self.testbed)
        self.login('*****@*****.**', 'ak')

        self.fixtures = [
            [u'Home', u'Home'],
            [u'A', u'Goto [[Home]]'],
            [u'Post A', u'.pub\nHello'],
            [u'Post B', u'.pub\nHello'],
            [u'Post C', u'.pub BBS\nHello'],
            [u'BBS', u'.schema Blog\nBlog'],
        ]

        for title, body in self.fixtures:
            self.update_page(body, title)

        self.browser = Browser()
示例#2
0
    def setUp(self):
        cache.prc.flush_all()

        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_memcache_stub()
        self.testbed.init_taskqueue_stub()
        self.testbed.init_user_stub()
        self.oauth_stub = OAuthStub(self.testbed, logout=True)
        self.browser = Browser()
示例#3
0
    def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_memcache_stub()
        self.testbed.init_taskqueue_stub()
        self.testbed.init_user_stub()
        self.oauth_stub = OAuthStub(self.testbed, logout=True)

        self.fixtures = [
            [u'Home', u'Home'],
            [u'A', u'Goto [[Home]]'],
            [u'Post A', u'.pub\nHello'],
            [u'Post B', u'.pub\nHello'],
            [u'Post C', u'.pub BBS\nHello'],
            [u'BBS', u'.schema Blog\nBlog'],
        ]

        for title, body in self.fixtures:
            page = WikiPage.get_by_title(title)
            page.update_content(body, 0, None)

        self.browser = Browser()
示例#4
0
    def setUp(self):
        super(PageHandlerTest, self).setUp()
        self.oauth_stub = OAuthStub(self.testbed)
        self.login('*****@*****.**', 'ak')

        self.fixtures = [
            [u'Home', u'Home'],
            [u'A', u'Goto [[Home]]'],
            [u'Post A', u'.pub\nHello'],
            [u'Post B', u'.pub\nHello'],
            [u'Post C', u'.pub BBS\nHello'],
            [u'BBS', u'.schema Blog\nBlog'],
        ]

        for title, body in self.fixtures:
            self.update_page(body, title)

        self.browser = Browser()
示例#5
0
    def setUp(self):
        super(PageHandlerTest, self).setUp()
        self.oauth_stub = OAuthStub(self.testbed)
        self.login("*****@*****.**", "ak")

        self.fixtures = [
            [u"Home", u"Home"],
            [u"A", u"Goto [[Home]]"],
            [u"Post A", u".pub\nHello"],
            [u"Post B", u".pub\nHello"],
            [u"Post C", u".pub BBS\nHello"],
            [u"BBS", u".schema Blog\nBlog"],
        ]

        for title, body in self.fixtures:
            self.update_page(body, title)

        self.browser = Browser()
示例#6
0
class PageHandlerTest(AppEngineTestCase):
    def setUp(self):
        super(PageHandlerTest, self).setUp()
        self.oauth_stub = OAuthStub(self.testbed)
        self.login('*****@*****.**', 'ak')

        self.fixtures = [
            [u'Home', u'Home'],
            [u'A', u'Goto [[Home]]'],
            [u'Post A', u'.pub\nHello'],
            [u'Post B', u'.pub\nHello'],
            [u'Post C', u'.pub BBS\nHello'],
            [u'BBS', u'.schema Blog\nBlog'],
        ]

        for title, body in self.fixtures:
            self.update_page(body, title)

        self.browser = Browser()

    def test_get_sp_chages(self):
        self.browser.get('/sp.changes')
        links = self.browser.query('.//table//a')
        link_texts = [link.text for link in links]
        self.assertEqual([u'BBS', u'Post C', u'Post B', u'Post A', u'A', u'Home'], link_texts)

    def test_get_sp_changes_with_paging(self):
        self.browser.get('/sp.changes?index=1&count=2')
        links = self.browser.query('.//table//a')
        link_texts = [link.text for link in links]
        self.assertEqual([u'Post B', u'Post A'], link_texts)

    def test_get_sp_index(self):
        self.browser.get('/sp.index')
        links = self.browser.query('.//table//a')
        link_texts = [link.text for link in links]
        self.assertEqual([u'A', u'BBS', u'Home', u'Post A', u'Post B', u'Post C'], link_texts)

    def test_get_sp_posts(self):
        self.browser.get('/sp.posts')
        links = self.browser.query('.//table//a')
        link_texts = [link.text for link in links]
        self.assertEqual([u'Post B', u'Post A'], link_texts)

    def test_get_sp_posts_with_paging(self):
        self.browser.get('/sp.posts?index=1&count=1')
        links = self.browser.query('.//table//a')
        link_texts = [link.text for link in links]
        self.assertEqual([u'Post A'], link_texts)

    def test_get_posts_to_page(self):
        self.browser.get('/BBS')
        links = self.browser.query('.//table//a')
        link_texts = [link.text for link in links]
        self.assertEqual([u'Post C'], link_texts)

    def test_get_wikipage(self):
        self.browser.get('/A')
        links = self.browser.query('.//article//a[@class=\'wikipage\']')
        link_texts = [link.text for link in links]
        self.assertEqual(['Home'], link_texts)

    def test_post_in_json(self):
        self.oauth_stub.login('*****@*****.**', 'jh')

        self.browser.post('/New_page?_type=json', 'body=[[Link!]]&revision=0')
        if self.browser.res.status_code % 100 == 3:
            self.browser.get(self.browser.res.location)
        self.assertEqual(self.browser.res.status_code, 200)
        self.assertEqual('application/json; charset=utf-8', self.browser.res.headers['Content-type'])

    def test_put_without_permission(self):
        self.logout()
        self.browser.post('/New_page?_method=PUT', 'body=[[Link!]]&revision=0')
        self.assertEqual(403, self.browser.res.status_code)

    def test_put_in_json(self):
        self.oauth_stub.login('*****@*****.**', 'jh')

        self.browser.post('/New_page?_method=PUT&_type=json', 'body=[[Link!]]&revision=0')
        if self.browser.res.status_code % 100 == 3:
            self.browser.get(self.browser.res.location)
        self.assertEqual(self.browser.res.status_code, 200)
        self.assertEqual('application/json; charset=utf-8', self.browser.res.headers['Content-type'])

    def test_new_page_should_be_shown_in_sp_changes(self):
        self.login('*****@*****.**', 'ak')
        self.browser.post('/New_page?_method=PUT', 'body=[[Link!]]&revision=0')

        self.browser.get('/sp.changes')
        links = self.browser.query('.//table//a')
        link_texts = [link.text for link in links]
        self.assertEqual([u'New page', u'BBS', u'Post C', u'Post B', u'Post A', u'A', u'Home'],
                         link_texts)

    def test_new_page_should_be_shown_in_sp_index(self):
        self.login('*****@*****.**', 'ak')
        self.browser.post('/New_page?_method=PUT', 'body=[[Link!]]&revision=0')

        self.browser.get('/sp.index')
        links = self.browser.query('.//table//a')
        link_texts = [link.text for link in links]
        self.assertEqual([u'A', u'BBS', u'Home', u'New page', u'Post A', u'Post B', u'Post C'],
                         link_texts)

    def test_redirect_metadata(self):
        self.update_page(u'.redirect Hello World', u'Hi')
        self.browser.get('/Hi', follow_redir=False)
        self.assertEqual(303, self.browser.res.status_code)
        self.assertEqual('http://localhost/Hello_World',
                         self.browser.res.location)

    def test_delete_page_without_permission(self):
        self.browser.post('/New_page?_method=PUT', 'body=[[Link!]]&revision=0')
        self.browser.post('/New_page?_method=DELETE')

        self.assertEqual(403, self.browser.res.status_code)

        self.browser.get('/sp.index')
        links = self.browser.query('.//table//a')
        link_texts = [link.text for link in links]
        self.assertTrue(u'New page' in link_texts)
示例#7
0
class PageHandlerTest(AppEngineTestCase):
    def setUp(self):
        super(PageHandlerTest, self).setUp()
        self.oauth_stub = OAuthStub(self.testbed)
        self.login("*****@*****.**", "ak")

        self.fixtures = [
            [u"Home", u"Home"],
            [u"A", u"Goto [[Home]]"],
            [u"Post A", u".pub\nHello"],
            [u"Post B", u".pub\nHello"],
            [u"Post C", u".pub BBS\nHello"],
            [u"BBS", u".schema Blog\nBlog"],
        ]

        for title, body in self.fixtures:
            self.update_page(body, title)

        self.browser = Browser()

    def test_get_sp_chages(self):
        self.browser.get("/sp.changes")
        links = self.browser.query(".//table//a")
        link_texts = [link.text for link in links]
        self.assertEqual([u"BBS", u"Post C", u"Post B", u"Post A", u"A", u"Home"], link_texts)

    def test_get_sp_changes_with_paging(self):
        self.browser.get("/sp.changes?index=1&count=2")
        links = self.browser.query(".//table//a")
        link_texts = [link.text for link in links]
        self.assertEqual([u"Post B", u"Post A"], link_texts)

    def test_get_sp_index(self):
        self.browser.get("/sp.index")
        links = self.browser.query(".//table//a")
        link_texts = [link.text for link in links]
        self.assertEqual([u"A", u"BBS", u"Home", u"Post A", u"Post B", u"Post C"], link_texts)

    def test_get_sp_posts(self):
        self.browser.get("/sp.posts")
        links = self.browser.query(".//table//a")
        link_texts = [link.text for link in links]
        self.assertEqual([u"Post B", u"Post A"], link_texts)

    def test_get_sp_posts_with_paging(self):
        self.browser.get("/sp.posts?index=1&count=1")
        links = self.browser.query(".//table//a")
        link_texts = [link.text for link in links]
        self.assertEqual([u"Post A"], link_texts)

    def test_get_posts_to_page(self):
        self.browser.get("/BBS")
        links = self.browser.query(".//table//a")
        link_texts = [link.text for link in links]
        self.assertEqual([u"Post C"], link_texts)

    def test_get_wikipage(self):
        self.browser.get("/A")
        links = self.browser.query(".//article//a[@class='wikipage']")
        link_texts = [link.text for link in links]
        self.assertEqual(["Home"], link_texts)

    def test_post_in_json(self):
        self.oauth_stub.login("*****@*****.**", "jh")

        self.browser.post("/New_page?_type=json", "body=[[Link!]]&revision=0")
        if self.browser.res.status_code % 100 == 3:
            self.browser.get(self.browser.res.location)
        self.assertEqual(self.browser.res.status_code, 200)
        self.assertEqual("application/json; charset=utf-8", self.browser.res.headers["Content-type"])

    def test_put_without_permission(self):
        self.logout()
        self.browser.post("/New_page?_method=PUT", "body=[[Link!]]&revision=0")
        self.assertEqual(403, self.browser.res.status_code)

    def test_put_in_json(self):
        self.oauth_stub.login("*****@*****.**", "jh")

        self.browser.post("/New_page?_method=PUT&_type=json", "body=[[Link!]]&revision=0")
        if self.browser.res.status_code % 100 == 3:
            self.browser.get(self.browser.res.location)
        self.assertEqual(self.browser.res.status_code, 200)
        self.assertEqual("application/json; charset=utf-8", self.browser.res.headers["Content-type"])

    def test_new_page_should_be_shown_in_sp_changes(self):
        self.login("*****@*****.**", "ak")
        self.browser.post("/New_page?_method=PUT", "body=[[Link!]]&revision=0")

        self.browser.get("/sp.changes")
        links = self.browser.query(".//table//a")
        link_texts = [link.text for link in links]
        self.assertEqual([u"New page", u"BBS", u"Post C", u"Post B", u"Post A", u"A", u"Home"], link_texts)

    def test_new_page_should_be_shown_in_sp_index(self):
        self.login("*****@*****.**", "ak")
        self.browser.post("/New_page?_method=PUT", "body=[[Link!]]&revision=0")

        self.browser.get("/sp.index")
        links = self.browser.query(".//table//a")
        link_texts = [link.text for link in links]
        self.assertEqual([u"A", u"BBS", u"Home", u"New page", u"Post A", u"Post B", u"Post C"], link_texts)

    def test_redirect_metadata(self):
        self.update_page(u".redirect Hello World", u"Hi")
        self.browser.get("/Hi", follow_redir=False)
        self.assertEqual(303, self.browser.res.status_code)
        self.assertEqual("http://localhost/Hello_World", self.browser.res.location)

    def test_delete_page_without_permission(self):
        self.browser.post("/New_page?_method=PUT", "body=[[Link!]]&revision=0")
        self.browser.post("/New_page?_method=DELETE")

        self.assertEqual(403, self.browser.res.status_code)

        self.browser.get("/sp.index")
        links = self.browser.query(".//table//a")
        link_texts = [link.text for link in links]
        self.assertTrue(u"New page" in link_texts)
示例#8
0
class PageHandlerTest(unittest.TestCase):
    def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_memcache_stub()
        self.testbed.init_taskqueue_stub()
        self.testbed.init_user_stub()
        self.oauth_stub = OAuthStub(self.testbed, logout=True)

        self.fixtures = [
            [u'Home', u'Home'],
            [u'A', u'Goto [[Home]]'],
            [u'Post A', u'.pub\nHello'],
            [u'Post B', u'.pub\nHello'],
            [u'Post C', u'.pub BBS\nHello'],
            [u'BBS', u'.schema Blog\nBlog'],
        ]

        for title, body in self.fixtures:
            page = WikiPage.get_by_title(title)
            page.update_content(body, 0, None)

        self.browser = Browser()

    def tearDown(self):
        self.testbed.deactivate()
        self.browser.logout()

    def test_get_sp_chages(self):
        for _ in range(2):
            self.browser.get('/sp.changes')
            links = self.browser.query('.//table//a')
            link_texts = [link.text for link in links]
            self.assertEqual([u'BBS', u'Post C', u'Post B', u'Post A', u'A', u'Home'], link_texts)

    def test_get_sp_index(self):
        for _ in range(2):
            self.browser.get('/sp.index')
            links = self.browser.query('.//table//a')
            link_texts = [link.text for link in links]
            self.assertEqual([u'A', u'BBS', u'Home', u'Post A', u'Post B', u'Post C'], link_texts)

    def test_get_sp_posts(self):
        for _ in range(2):
            self.browser.get('/sp.posts')
            links = self.browser.query('.//table//a')
            link_texts = [link.text for link in links]
            self.assertEqual([u'Post B', u'Post A'], link_texts)

    def test_get_posts_to_page(self):
        for _ in range(2):
            self.browser.get('/BBS')
            links = self.browser.query('.//table//a')
            link_texts = [link.text for link in links]
            self.assertEqual([u'Post C'], link_texts)

    def test_get_wikipage(self):
        for _ in range(2):
            self.browser.get('/A')
            links = self.browser.query('.//article//a[@class=\'wikipage\']')
            link_texts = [link.text for link in links]
            self.assertEqual(['Home'], link_texts)

    def test_post_in_json(self):
        self.browser.logout()
        self.oauth_stub.login('*****@*****.**', 'jh')

        self.browser.post('/New_page?_type=json', 'body=[[Link!]]&revision=0')
        if self.browser.res.status_code % 100 == 3:
            self.browser.get(self.browser.res.location)
        self.assertEqual(self.browser.res.status_code, 200)
        self.assertEqual('application/json; charset=utf-8', self.browser.res.headers['Content-type'])

    def test_put_without_permission(self):
        self.browser.post('/New_page?_method=PUT', 'body=[[Link!]]&revision=0')
        self.assertEqual(403, self.browser.res.status_code)

    def test_put_in_json(self):
        self.browser.logout()
        self.oauth_stub.login('*****@*****.**', 'jh')

        self.browser.post('/New_page?_method=PUT&_type=json', 'body=[[Link!]]&revision=0')
        if self.browser.res.status_code % 100 == 3:
            self.browser.get(self.browser.res.location)
        self.assertEqual(self.browser.res.status_code, 200)
        self.assertEqual('application/json; charset=utf-8', self.browser.res.headers['Content-type'])

    def test_new_page_should_be_shown_in_sp_changes(self):
        self.browser.login('*****@*****.**', 'ak')
        self.browser.post('/New_page?_method=PUT', 'body=[[Link!]]&revision=0')

        for _ in range(2):
            self.browser.get('/sp.changes')
            links = self.browser.query('.//table//a')
            link_texts = [link.text for link in links]
            self.assertEqual([u'New page', u'BBS', u'Post C', u'Post B', u'Post A', u'A', u'Home'],
                             link_texts)

    def test_new_page_should_be_shown_in_sp_index(self):
        self.browser.login('*****@*****.**', 'ak')
        self.browser.post('/New_page?_method=PUT', 'body=[[Link!]]&revision=0')

        for _ in range(2):
            self.browser.get('/sp.index')
            links = self.browser.query('.//table//a')
            link_texts = [link.text for link in links]
            self.assertEqual([u'A', u'BBS', u'Home', u'New page', u'Post A', u'Post B', u'Post C'],
                             link_texts)

    def test_redirect_metadata(self):
        page = WikiPage.get_by_title(u'Hi')
        page.update_content(u'.redirect Hello World', 0)

        self.browser.get('/Hi', follow_redir=False)
        self.assertEqual(303, self.browser.res.status_code)
        self.assertEqual('http://localhost/Hello_World',
                         self.browser.res.location)

    def test_delete_page_without_permission(self):
        self.browser.login('*****@*****.**', 'ak', is_admin=False)
        self.browser.post('/New_page?_method=PUT', 'body=[[Link!]]&revision=0')
        self.browser.post('/New_page?_method=DELETE')

        self.assertEqual(403, self.browser.res.status_code)

        self.browser.get('/sp.index')
        links = self.browser.query('.//table//a')
        link_texts = [link.text for link in links]
        self.assertTrue(u'New page' in link_texts)
示例#9
0
class PageHandlerTest(AppEngineTestCase):
    def setUp(self):
        super(PageHandlerTest, self).setUp()
        self.oauth_stub = OAuthStub(self.testbed)
        self.login('*****@*****.**', 'ak')

        self.fixtures = [
            [u'Home', u'Home'],
            [u'A', u'Goto [[Home]]'],
            [u'Post A', u'.pub\nHello'],
            [u'Post B', u'.pub\nHello'],
            [u'Post C', u'.pub BBS\nHello'],
            [u'BBS', u'.schema Blog\nBlog'],
        ]

        for title, body in self.fixtures:
            self.update_page(body, title)

        self.browser = Browser()

    def test_get_sp_chages(self):
        self.browser.get('/sp.changes')
        links = self.browser.query('.//table//a')
        link_texts = [link.text for link in links]
        self.assertEqual([u'BBS', u'Post C', u'Post B', u'Post A', u'A', u'Home'], link_texts)

    def test_get_sp_changes_with_paging(self):
        self.browser.get('/sp.changes?index=1&count=2')
        links = self.browser.query('.//table//a')
        link_texts = [link.text for link in links]
        self.assertEqual([u'Post B', u'Post A'], link_texts)

    def test_get_sp_index(self):
        self.browser.get('/sp.index')
        links = self.browser.query('.//table//a')
        link_texts = [link.text for link in links]
        self.assertEqual([u'A', u'BBS', u'Home', u'Post A', u'Post B', u'Post C'], link_texts)

    def test_get_sp_posts(self):
        self.browser.get('/sp.posts')
        links = self.browser.query('.//table//a')
        link_texts = [link.text for link in links]
        self.assertEqual([u'Post B', u'Post A'], link_texts)

    def test_get_sp_posts_with_paging(self):
        self.browser.get('/sp.posts?index=1&count=1')
        links = self.browser.query('.//table//a')
        link_texts = [link.text for link in links]
        self.assertEqual([u'Post A'], link_texts)

    def test_get_posts_to_page(self):
        self.browser.get('/BBS')
        links = self.browser.query('.//table//a')
        link_texts = [link.text for link in links]
        self.assertEqual([u'Post C'], link_texts)

    def test_get_wikipage(self):
        self.browser.get('/A')
        links = self.browser.query('.//article//a[@class=\'wikipage\']')
        link_texts = [link.text for link in links]
        self.assertEqual(['Home'], link_texts)

    def test_post_in_json(self):
        self.oauth_stub.login('*****@*****.**', 'jh')

        self.browser.post('/New_page?_type=json', 'body=[[Link!]]&revision=0')
        if self.browser.res.status_code % 100 == 3:
            self.browser.get(self.browser.res.location)
        self.assertEqual(self.browser.res.status_code, 200)
        self.assertEqual('application/json; charset=utf-8', self.browser.res.headers['Content-type'])

    def test_put_without_permission(self):
        self.logout()
        self.browser.post('/New_page?_method=PUT', 'body=[[Link!]]&revision=0')
        self.assertEqual(403, self.browser.res.status_code)

    def test_put_in_json(self):
        self.oauth_stub.login('*****@*****.**', 'jh')

        self.browser.post('/New_page?_method=PUT&_type=json', 'body=[[Link!]]&revision=0')
        if self.browser.res.status_code % 100 == 3:
            self.browser.get(self.browser.res.location)
        self.assertEqual(self.browser.res.status_code, 200)
        self.assertEqual('application/json; charset=utf-8', self.browser.res.headers['Content-type'])

    def test_new_page_should_be_shown_in_sp_changes(self):
        self.login('*****@*****.**', 'ak')
        self.browser.post('/New_page?_method=PUT', 'body=[[Link!]]&revision=0')

        self.browser.get('/sp.changes')
        links = self.browser.query('.//table//a')
        link_texts = [link.text for link in links]
        self.assertEqual([u'New page', u'BBS', u'Post C', u'Post B', u'Post A', u'A', u'Home'],
                         link_texts)

    def test_new_page_should_be_shown_in_sp_index(self):
        self.login('*****@*****.**', 'ak')
        self.browser.post('/New_page?_method=PUT', 'body=[[Link!]]&revision=0')

        self.browser.get('/sp.index')
        links = self.browser.query('.//table//a')
        link_texts = [link.text for link in links]
        self.assertEqual([u'A', u'BBS', u'Home', u'New page', u'Post A', u'Post B', u'Post C'],
                         link_texts)

    def test_redirect_metadata(self):
        self.update_page(u'.redirect Hello World', u'Hi')
        self.browser.get('/Hi', follow_redir=False)
        self.assertEqual(303, self.browser.res.status_code)
        self.assertEqual('http://localhost/Hello_World',
                         self.browser.res.location)

    def test_delete_page_without_permission(self):
        self.browser.post('/New_page?_method=PUT', 'body=[[Link!]]&revision=0')
        self.browser.post('/New_page?_method=DELETE')

        self.assertEqual(403, self.browser.res.status_code)

        self.browser.get('/sp.index')
        links = self.browser.query('.//table//a')
        link_texts = [link.text for link in links]
        self.assertTrue(u'New page' in link_texts)

    def test_try_to_get_edit_page_without_permission(self):
        self.logout()
        self.browser.get('/A?view=edit')
        self.assertEqual(403, self.browser.res.status_code)