Ejemplo n.º 1
0
    def test_save_page(self):
        page = Page.get(1)
        assert page.struct == '1 '
        assert struct_to_set(page.struct) == set([1])

        struct = '2 [ 3 [ 4 ] ] '
        rv = self.post('save_page', data=dict(struct=struct), page_id=1)
        assert rv.status_code == HTTP_OK

        assert struct_to_set(struct) == set([2,3,4])
        assert Page.get(1).struct == struct

        session = Session()
        assert session.query(Idea).get(1).reference_count == 0
        assert session.query(Idea).get(2).reference_count == 2

        # malformed
        rv = self.post('save_page', data=dict(struct=struct[:-2]), page_id=1)
        assert rv.status_code == HTTP_OK
        assert Page.get(1).struct == struct

        # invalid token
        rv = self.post('save_page', data=dict(struct='hello world'), page_id=1)
        assert rv.status_code == HTTP_OK
        assert Page.get(1).struct == struct
Ejemplo n.º 2
0
    def test_new_page(self):
        before = Page.count()
        rv = self.post('new_page')
        after = Page.count()

        assert rv.status_code == HTTP_REDIRECT
        assert before + 1 == after
Ejemplo n.º 3
0
 def setup_method(self, method):
     super(TestGet, self).setup_method(method)
     Page.new()
     Page.new()
     Idea.new(1, 'hello')
     Idea.new(2, 'hello')
     Idea.new(2, 'hello')
     Idea.new(2, 'hello')
Ejemplo n.º 4
0
    def test_import_text(self):
        text = """
        the first paragraph. a sentence. ellipsis.. end.

        the second paragraph. another sentence."""

        before_page = Page.count()
        before_idea = Idea.count()

        rv = self.post('import_text', data=dict(text=text))
        assert rv.status_code == HTTP_REDIRECT

        after_page = Page.count()
        after_idea = Idea.count()

        assert before_page + 1 == after_page
        assert before_idea + 5 == after_idea
        assert Page.get(after_page).struct == '5 [ 6 7 ] 8 [ 9 ] '
Ejemplo n.º 5
0
 def test_page_title(self):
     title = 'new_title'
     rv = self.post('page_title', data=dict(title=title), page_id=1)
     assert rv.status_code == HTTP_OK
     assert rv.data == title
     assert Page.get(1).title == title