Esempio n. 1
0
    def test_create_and_view(self):
        rv = self.client.get('/topic/1')
        assert rv.status_code == 404

        with self.app.test_request_context():
            node = Node(title='june', urlname='june')
            node.save()

        rv = self.client.get('/topic/create/june')
        assert '/account/signin' in rv.location
        self.prepare_login()
        rv = self.client.get('/topic/create/june')
        assert '</form>' in rv.data

        rv = self.client.post('/topic/create/june',
                              data={
                                  'title': 'june',
                                  'content': 'june'
                              })
        assert '/topic/1' in rv.location

        rv = self.client.get('/topic/1')
        assert b'june</h1>' in rv.data

        rv = self.client.get('/topic/1?page=s')
        assert rv.status_code == 404

        rv = self.client.post('/topic/1')
        assert b'hits' in rv.data
Esempio n. 2
0
    def test_create_and_view(self):
        rv = self.client.get("/topic/1")
        assert rv.status_code == 404

        with self.app.test_request_context():
            node = Node(title="june", urlname="june")
            node.save()

        rv = self.client.get("/topic/create/june")
        assert "/account/signin" in rv.location
        self.prepare_login()
        rv = self.client.get("/topic/create/june")
        assert "</form>" in rv.data

        rv = self.client.post("/topic/create/june", data={"title": "june", "content": "june"})
        assert "/topic/1" in rv.location

        rv = self.client.get("/topic/1")
        assert b"june</h1>" in rv.data

        rv = self.client.get("/topic/1?page=s")
        assert rv.status_code == 404

        rv = self.client.post("/topic/1")
        assert b"hits" in rv.data
Esempio n. 3
0
    def test_create_and_view(self):
        url_view = self.url_for("topic.view", uid=1)
        rv = self.client.get(url_view)
        assert rv.status_code == 404

        with self.app.test_request_context():
            node = Node(title="june", urlname="june")
            node.save()
        url_create = self.url_for("topic.create", urlname="june")

        rv = self.client.get(url_create)
        assert self.url_for("account.signin") in rv.location
        self.prepare_login()
        rv = self.client.get(url_create)
        assert "</form>" in rv.data

        rv = self.client.post(url_create, data={"title": "june", "content": "june"})
        assert url_view in rv.location

        rv = self.client.get(url_view)
        assert b"june</h1>" in rv.data

        rv = self.client.get(url_view + "?page=s")
        assert rv.status_code == 404

        rv = self.client.post(url_view)
        assert b"hits" in rv.data
Esempio n. 4
0
    def test_create_and_view(self):
        url_view = self.url_for('topic.view', uid=1)
        rv = self.client.get(url_view)
        assert rv.status_code == 404

        with self.app.test_request_context():
            node = Node(title='june', urlname='june')
            node.save()
        url_create = self.url_for('topic.create', urlname='june')

        rv = self.client.get(url_create)
        assert self.url_for('account.signin') in rv.location
        self.prepare_login()
        rv = self.client.get(url_create)
        assert '</form>' in rv.data

        rv = self.client.post(url_create,
                              data={
                                  'title': 'june',
                                  'content': 'june'
                              })
        assert url_view in rv.location

        rv = self.client.get(url_view)
        assert b'june</h1>' in rv.data

        rv = self.client.get(url_view + '?page=s')
        assert rv.status_code == 404

        rv = self.client.post(url_view)
        assert b'hits' in rv.data
Esempio n. 5
0
    def test_create_and_view(self):
        rv = self.client.get('/topic/1')
        assert rv.status_code == 404

        with self.app.test_request_context():
            node = Node(title='june', urlname='june')
            node.save()

        rv = self.client.get('/topic/create/june')
        assert '/account/signin' in rv.location
        self.prepare_login()
        rv = self.client.get('/topic/create/june')
        assert '</form>' in rv.data

        rv = self.client.post('/topic/create/june', data={
            'title': 'june',
            'content': 'june'
        })
        assert '/topic/1' in rv.location

        rv = self.client.get('/topic/1')
        assert '<h1>june</h1>' in rv.data

        rv = self.client.get('/topic/1?page=s')
        assert rv.status_code == 404

        rv = self.client.post('/topic/1')
        assert 'hits' in rv.data
Esempio n. 6
0
 def prepare_topic(self):
     node = Node(title='june', urlname='june')
     db.session.add(node)
     topic = Topic(title='june', content='june', account_id=1, node_id=1)
     db.session.add(topic)
     db.session.commit()
     return topic
Esempio n. 7
0
    def test_edit(self):
        self.prepare_login()
        with self.app.test_request_context():
            node = Node(title='june', urlname='june')
            node.save()

        rv = self.client.get('/node/june/edit')
        assert '</form>' in rv.data

        # re edit
        rv = self.client.post('/node/june/edit', data={
            'title': 'june',
            'urlname': 'june'
        })
        assert '/node/june' in rv.location

        rv = self.client.post('/node/june/edit', data={
            'title': 'june',
            'urlname': 'foo'
        })
        assert '/node/foo' in rv.location
Esempio n. 8
0
    def test_edit(self):
        self.prepare_login()
        with self.app.test_request_context():
            node = Node(title='june', urlname='june')
            node.save()
        url = self.url_for('node.edit', urlname='june')

        rv = self.client.get(url)
        assert '</form>' in rv.data

        # re edit
        rv = self.client.post(url, data={
            'title': 'june',
            'urlname': 'june'
        })
        assert self.url_for('node.view', urlname='june') in rv.location

        rv = self.client.post(url, data={
            'title': 'june',
            'urlname': 'foo'
        })
        assert self.url_for('node.view', urlname='foo') in rv.location
Esempio n. 9
0
    def test_edit(self):
        self.prepare_login()
        with self.app.test_request_context():
            node = Node(title='june', urlname='june')
            node.save()

        rv = self.client.get('/node/june/edit')
        assert '</form>' in rv.data

        # re edit
        rv = self.client.post('/node/june/edit',
                              data={
                                  'title': 'june',
                                  'urlname': 'june'
                              })
        assert '/node/june' in rv.location

        rv = self.client.post('/node/june/edit',
                              data={
                                  'title': 'june',
                                  'urlname': 'foo'
                              })
        assert '/node/foo' in rv.location
Esempio n. 10
0
    def test_view(self):
        rv = self.client.get('/node/june')
        assert rv.status_code == 404

        with self.app.test_request_context():
            node = Node(title='june', urlname='june')
            node.save()
            assert repr(node) == '<Node: june>'

        rv = self.client.get('/node/june')
        assert rv.status_code == 200

        rv = self.client.get('/node/june?page=s')
        assert rv.status_code == 404

        self.prepare_login()
        with self.app.test_request_context():
            node.description = 'june'
            node.save()
        rv = self.client.get('/node/june')
        assert rv.status_code == 200
Esempio n. 11
0
    def test_view(self):
        rv = self.client.get('/node/june')
        assert rv.status_code == 404

        with self.app.test_request_context():
            node = Node(title='june', urlname='june')
            node.save()
            assert repr(node) == '<Node: june>'

        rv = self.client.get('/node/june')
        assert rv.status_code == 200

        rv = self.client.get('/node/june?page=s')
        assert rv.status_code == 404

        self.prepare_login()
        with self.app.test_request_context():
            node.description = 'june'
            node.save()
        rv = self.client.get('/node/june')
        assert rv.status_code == 200