Back to index

moin  1.9.0~rc2
test_groups.py
Go to the documentation of this file.
00001 # -*- coding: iso-8859-1 -*-
00002 """
00003     MoinMoin - MoinMoin.formatter.groups Tests
00004 
00005     @copyright: 2009 by MoinMoin:DmitrijsMilajevs
00006     @license: GNU GPL, see COPYING for details.
00007 """
00008 
00009 from  MoinMoin.formatter.groups import Formatter
00010 from MoinMoin.Page import Page
00011 from MoinMoin._tests import become_trusted, create_page, nuke_page
00012 
00013 class TestGroupFormatterWikiMarkup(object):
00014 
00015     def get_members(self, text):
00016         request = self.request
00017         formatter = Formatter(self.request)
00018 
00019         become_trusted(request)
00020         create_page(request, u'TestPageGroup', text)
00021         page = Page(request, 'TestPageGroup', formatter=formatter)
00022         page.send_page(content_only=True)
00023         nuke_page(request, u'TestPageGroup')
00024 
00025         return formatter.members
00026 
00027     def test_CamelCase(self):
00028         text = """
00029  * CamelCase
00030 """
00031         members = self.get_members(text)
00032         assert len(members) == 1
00033         assert u'CamelCase' in members
00034 
00035     def test_extended_name(self):
00036         text = """
00037  * extended name
00038 """
00039         members = self.get_members(text)
00040         assert len(members) == 1
00041         assert u'extended name' in members
00042 
00043     def test_extended_link(self):
00044         text = """
00045  * [[extended link]]
00046 """
00047         members = self.get_members(text)
00048         assert len(members) == 1
00049         assert u'extended link' in members
00050 
00051     def test_extended_link_with_label(self):
00052         text = """
00053  * [[extended link| label]]
00054 """
00055         members = self.get_members(text)
00056         assert len(members) == 1
00057         assert u'extended link' in members
00058 
00059     def test_extended_link_and_text(self):
00060         text = """
00061  * [[extended link]] other text
00062  * other text [[extended link]]
00063  * other text [[extended link]] other text
00064 
00065 """
00066         members = self.get_members(text)
00067         assert len(members) == 3
00068         assert u'extended link other text' in members
00069         assert u'other text extended link' in members
00070         assert u'other text extended link other text' in members
00071 
00072     def test_ignore_not_first_level_list(self):
00073         text = """
00074  * first level
00075   * second level
00076    * [[SomeLink]]
00077     * forth level
00078      * and then some...
00079  * again first level
00080 """
00081         members = self.get_members(text)
00082         assert len(members) == 2
00083         assert 'first level' in members
00084         assert 'again first level' in members
00085 
00086     def test_indented_list(self):
00087         text = """
00088     * first level
00089      * second level
00090       * [[SomeLink|label]]
00091        * forth level
00092         * and then some...
00093     * again first level
00094 """
00095         members = self.get_members(text)
00096         assert len(members) == 2
00097         assert 'first level' in members
00098         assert 'again first level' in members
00099 
00100     def test_ignore_other(self):
00101         text = """
00102 = ignore this =
00103  * take this
00104 
00105 Ignore previous line and this text.
00106 """
00107         members = self.get_members(text)
00108         assert len(members) == 1
00109         assert u'take this' in members
00110 
00111     def test_strip_whitespace(self):
00112         text = """
00113  *   take this
00114 """
00115         members = self.get_members(text)
00116         assert len(members) == 1
00117         assert u'take this' in members
00118 
00119 
00120 class TestGroupFormatterCreole(object):
00121 
00122     def get_members(self, text):
00123         request = self.request
00124         formatter = Formatter(self.request)
00125 
00126         become_trusted(request)
00127         create_page(request, u'TestPageGroup', "#FORMAT creole \n" + text)
00128         page = Page(request, 'TestPageGroup', formatter=formatter)
00129         page.send_page(content_only=True)
00130         nuke_page(request, u'TestPageGroup')
00131 
00132         return formatter.members
00133 
00134     def test_CamelCase(self):
00135         text = """
00136  * CamelCase
00137 """
00138         members = self.get_members(text)
00139         assert len(members) == 1
00140         assert u'CamelCase' in members
00141 
00142     def test_extended_name(self):
00143         text = """
00144  * extended name
00145 """
00146         members = self.get_members(text)
00147         assert len(members) == 1
00148         assert u'extended name' in members
00149 
00150     def test_extended_link(self):
00151         text = """
00152  * [[extended link]]
00153 """
00154         members = self.get_members(text)
00155         assert len(members) == 1
00156         assert u'extended link' in members
00157 
00158     def test_extended_link_with_label(self):
00159         text = """
00160  * [[FrontPage|named link]]
00161 """
00162         members = self.get_members(text)
00163         assert len(members) == 1
00164         assert u'FrontPage' in members
00165 
00166     def test_extended_link_and_text(self):
00167         text = """
00168  * [[extended link]] other text
00169  * other text [[extended link]]
00170  * other text [[extended link]] other text
00171 
00172 """
00173         members = self.get_members(text)
00174         assert len(members) == 3
00175         assert u'extended link other text' in members
00176         assert u'other text extended link' in members
00177         assert u'other text extended link other text' in members
00178 
00179     def test_ignore_not_first_level_list(self):
00180         text = """
00181 * first level
00182 ** second level
00183 *** [[SomeLink]]
00184 **** forth level
00185 ***** and then some...
00186 * again first level
00187 """
00188         members = self.get_members(text)
00189         assert len(members) == 2
00190         assert 'first level' in members
00191         assert 'again first level' in members
00192 
00193     def test_indented_list(self):
00194         text = """
00195     * first level
00196     ** second level
00197     *** [[SomeLink|label]]
00198     **** forth level
00199     ***** and then some...
00200     * again first level
00201 """
00202         members = self.get_members(text)
00203         assert len(members) == 2
00204         assert 'first level' in members
00205         assert 'again first level' in members
00206 
00207     def test_ignore_other(self):
00208         text = """
00209 = ignore this =
00210  * take this
00211 
00212 Ignore previous line and this text.
00213 """
00214         members = self.get_members(text)
00215         assert len(members) == 1
00216         assert u'take this' in members
00217 
00218     def test_strip_whitespace(self):
00219         text = """
00220  *   take this
00221 """
00222         members = self.get_members(text)
00223         assert len(members) == 1
00224         assert u'take this' in members
00225 
00226 
00227 coverage_modules = ['MoinMoin.formtter.groups']