Beispiel #1
0
 def test_set_target_to_none(self):
     # If the link is piped:
     wl = WikiLink('[[a|b]]')
     wl.text = None
     self.assertEqual('[[a]]', wl.string)
     # Without a pipe:
     wl = WikiLink('[[a]]')
     wl.text = None
     self.assertEqual('[[a]]', wl.string)
Beispiel #2
0
 def test_text_settter(self):
     ae = self.assertEqual
     wl = WikiLink('[[A | B]]')
     wl.text = ' C '
     ae('[[A | C ]]', wl.string)
     with self.assertWarns(DeprecationWarning):
         wl.text = None
     ae('[[A ]]', wl.string)
     with self.assertWarns(DeprecationWarning):
         wl.text = None
     ae('[[A ]]', wl.string)
def test_title_and_fragment_setters():
    # no frag, no pipe
    wl = WikiLink('[[a]]')
    wl.title = 'b'
    assert wl.string == '[[b]]'
    wl.fragment = 'c'
    assert wl.string == '[[b#c]]'

    # frag, no pipe
    wl.fragment = 'c'
    assert wl.string == '[[b#c]]'
    wl.title = 'a'
    assert wl.string == '[[a#c]]'

    # frag, pipe
    wl.text = ''  # [[d#c|]]
    wl.fragment = 'e'
    assert wl.string == '[[a#e|]]'
    wl.title = 'b'
    assert wl.string == '[[b#e|]]'

    # no frag, pipe
    del wl.fragment
    wl.fragment = 'e'
    assert wl.string == '[[b#e|]]'
    del wl.fragment
    wl.title = 'a'
    assert wl.string == '[[a|]]'

    # no frag after pipe
    wl = WikiLink('[[a|#]]')
    wl.title = 'b'
    assert wl.string == '[[b|#]]'
    wl.fragment = 'f'
    assert wl.string == '[[b#f|#]]'
def test_text_settter():
    wl = WikiLink('[[A | B]]')
    wl.text = ' C '
    assert '[[A | C ]]' == wl.string
    del wl.text
    assert '[[A ]]' == wl.string
    del wl.text
    assert '[[A ]]' == wl.string
Beispiel #5
0
    def test_title_and_fragment_setters(self):
        ae = self.assertEqual

        # no frag, no pipe
        wl = WikiLink('[[a]]')
        wl.title = 'b'
        ae(wl.string, '[[b]]')
        wl.fragment = 'c'
        ae(wl.string, '[[b#c]]')

        # frag, no pipe
        wl.fragment = 'c'
        ae(wl.string, '[[b#c]]')
        wl.title = 'a'
        ae(wl.string, '[[a#c]]')

        # frag, pipe
        wl.text = ''  # [[d#c|]]
        wl.fragment = 'e'
        ae(wl.string, '[[a#e|]]')
        wl.title = 'b'
        ae(wl.string, '[[b#e|]]')

        # no frag, pipe
        del wl.fragment
        wl.fragment = 'e'
        ae(wl.string, '[[b#e|]]')
        del wl.fragment
        wl.title = 'a'
        ae(wl.string, '[[a|]]')

        # no frag after pipe
        wl = WikiLink('[[a|#]]')
        wl.title = 'b'
        ae(wl.string, '[[b|#]]')
        wl.fragment = 'f'
        ae(wl.string, '[[b#f|#]]')
Beispiel #6
0
 def test_set_text_when_there_is_no_text(self):
     wl = WikiLink('[[ A ]]')
     self.assertEqual(wl.text, None)
     wl.text = ' C '
     self.assertEqual('[[ A | C ]]', wl.string)
Beispiel #7
0
 def test_set_text(self):
     wl = WikiLink('[[A | B]]')
     wl.text = ' C '
     self.assertEqual('[[A | C ]]', wl.string)
def test_set_text_when_there_is_no_text():
    wl = WikiLink('[[ A ]]')
    assert wl.text is None
    wl.text = ' C '
    assert '[[ A | C ]]' == wl.string