def test_indirect_non_local(self):
     """Test en:translatewiki:Main Page on English Wikipedia."""
     link = Link('en:translatewiki:Main Page', self.get_site('wp'))
     link.parse()
     self.assertEqual(link.site, self.get_site('tw'))
     self.assertEqual(link.title, 'Main Page')
     self.assertEqual(link.namespace, 0)
Example #2
0
 def test_interwiki_mainpage(self):
     """Test that Link allow links without a title to the main page."""
     link = Link('en:', self.get_site())
     link.parse()
     self.assertEqual(link.site, self.get_site())
     self.assertEqual(link.title, '')
     self.assertEqual(link.namespace, 0)
Example #3
0
 def test_fully_qualified_NS1_family(self):
     """Test ':wikidata:testwiki:Talk:Q6' on enwp is namespace 1."""
     config.mylang = 'en'
     config.family = 'wikipedia'
     link = Link(':wikidata:testwiki:Talk:Q6')
     link.parse()
     self.assertEqual(link.site, self.get_site('test.wp'))
     self.assertEqual(link.title, 'Q6')
     self.assertEqual(link.namespace, 1)
Example #4
0
 def test_fully_qualified_NS0_code(self):
     """Test ':testwiki:wikidata:Q6' on enwp is namespace 0."""
     config.mylang = 'en'
     config.family = 'wikipedia'
     link = Link(':testwiki:wikidata:Q6')
     link.parse()
     self.assertEqual(link.site, self.get_site('wikidata'))
     self.assertEqual(link.title, 'Q6')
     self.assertEqual(link.namespace, 0)
Example #5
0
 def test_fully_qualified_NS1_family(self):
     """Test ':wikipedia:en:Talk:Main Page' on wikidata is namespace 1."""
     config.mylang = 'wikidata'
     config.family = 'wikidata'
     link = Link(':wikipedia:en:Talk:Main Page')
     link.parse()
     self.assertEqual(link.site, self.get_site('enwp'))
     self.assertEqual(link.title, 'Main Page')
     self.assertEqual(link.namespace, 1)
Example #6
0
 def test_fully_qualified_NS0_family(self):
     """Test ':wikipedia:en:Main Page' on enws is namespace 0."""
     config.mylang = 'en'
     config.family = 'wikisource'
     link = Link(':wikipedia:en:Main Page')
     link.parse()
     self.assertEqual(link.site, self.get_site('enwp'))
     self.assertEqual(link.title, 'Main Page')
     self.assertEqual(link.namespace, 0)
Example #7
0
 def test_fully_qualified_NS1_code(self):
     """Test ':en:wikipedia:Talk:Main Page' on enwp is namespace 4."""
     config.mylang = 'en'
     config.family = 'wikipedia'
     link = Link(':en:wikipedia:Talk:Main Page')
     link.parse()
     self.assertEqual(link.site, self.get_site())
     self.assertEqual(link.title, 'Talk:Main Page')
     self.assertEqual(link.namespace, 4)
Example #8
0
 def test_partially_qualified_NS1_code(self):
     """Test ':wikipedia:Talk:Main Page' on enws is ns 1."""
     config.mylang = 'en'
     config.family = 'wikisource'
     link = Link(':wikipedia:Talk:Main Page')
     link.parse()
     self.assertEqual(link.site, self.get_site())
     self.assertEqual(link.title, 'Main Page')
     self.assertEqual(link.namespace, 1)
Example #9
0
 def test_partially_qualified_NS1_family(self):
     """Test ':en:Talk:Main Page' on dewp is namespace 1."""
     config.mylang = 'de'
     config.family = 'wikipedia'
     link = Link(':en:Talk:Main Page')
     link.parse()
     self.assertEqual(link.site, self.get_site())
     self.assertEqual(link.title, 'Main Page')
     self.assertEqual(link.namespace, 1)
 def test_partially_qualified_NS0_family(self):
     """Test that Link uses config.family for namespace 0."""
     config.mylang = 'de'
     config.family = 'wikipedia'
     link = Link('en:Main Page')
     link.parse()
     self.assertEqual(link.site, self.get_site())
     self.assertEqual(link.title, 'Main Page')
     self.assertEqual(link.namespace, 0)
Example #11
0
 def test_fully_qualified_NS0_code(self):
     """Test 'species:Main Page' on enwp is namespace 0."""
     config.mylang = 'en'
     config.family = 'wikipedia'
     link = Link('species:Main Page')
     link.parse()
     self.assertEqual(link.site, self.get_site())
     self.assertEqual(link.title, 'Main Page')
     self.assertEqual(link.namespace, 0)
Example #12
0
 def test_fully_qualified_NS0_family(self):
     """Test 'wikidata:testwiki:Q6' on enwp is namespace 0."""
     config.mylang = 'en'
     config.family = 'wikipedia'
     link = Link('wikidata:testwiki:Q6')
     link.parse()
     self.assertEqual(link.site, pywikibot.Site('test', 'wikipedia'))
     self.assertEqual(link.title, 'Q6')
     self.assertEqual(link.namespace, 0)
Example #13
0
 def test_partially_qualified_NS0_family(self):
     """Test 'en:Main Page' on dewp  is namespace 0."""
     config.mylang = 'de'
     config.family = 'wikipedia'
     link = Link('en:Main Page')
     link.parse()
     self.assertEqual(link.site, self.get_site())
     self.assertEqual(link.title, 'Main Page')
     self.assertEqual(link.namespace, 0)
 def test_partially_qualified_NS1_family(self):
     """Test that Link uses config.family for namespace 1."""
     config.mylang = 'de'
     config.family = 'wikipedia'
     link = Link('en:Talk:Main Page')
     link.parse()
     self.assertEqual(link.site, self.get_site())
     self.assertEqual(link.title, 'Main Page')
     self.assertEqual(link.namespace, 1)
Example #15
0
 def test_fully_qualified_NS1_family(self):
     """Test 'wikipedia:en:Talk:Main Page' on wikidata is namespace 1."""
     config.mylang = 'wikidata'
     config.family = 'wikidata'
     link = Link('wikipedia:en:Talk:Main Page')
     link.parse()
     self.assertEqual(link.site, self.get_site('enwp'))
     self.assertEqual(link.title, 'Main Page')
     self.assertEqual(link.namespace, 1)
Example #16
0
 def test_fully_qualified_NS0_family(self):
     """Test 'wikipedia:en:Main Page' on enws is namespace 0."""
     config.mylang = 'en'
     config.family = 'wikisource'
     link = Link('wikipedia:en:Main Page')
     link.parse()
     self.assertEqual(link.site, self.get_site('enwp'))
     self.assertEqual(link.title, 'Main Page')
     self.assertEqual(link.namespace, 0)
Example #17
0
 def test_via_local_non_local(self):
     """Test de:translatewiki:Main Page on English Wikipedia."""
     link = Link('de:translatewiki:Main Page', self.get_site('wp'))
     with self.assertRaisesRegex(
             InvalidTitleError,
             'de:translatewiki:Main Page links to a non local '
             'site i18n:i18n '
             'via an interwiki link to wikipedia:de'):
         link.parse()
Example #18
0
 def test_partially_qualified_NS0_code(self):
     """Test ':wikipedia:Main Page' on enwp is namespace 4."""
     config.mylang = 'en'
     config.family = 'wikipedia'
     link = Link(':wikipedia:Main Page')
     link.parse()
     self.assertEqual(link.site, self.get_site())
     self.assertEqual(link.title, 'Main Page')
     self.assertEqual(link.namespace, 4)
Example #19
0
 def test_partially_qualified_NS1_code(self):
     """Test 'wikipedia:Talk:Main Page' on enws is ns 1."""
     config.mylang = 'en'
     config.family = 'wikisource'
     link = Link('wikipedia:Talk:Main Page')
     link.parse()
     self.assertEqual(link.site, self.get_site())
     self.assertEqual(link.title, 'Main Page')
     self.assertEqual(link.namespace, 1)
Example #20
0
 def test_fully_qualified_NS1_code(self):
     """Test ':testwiki:wikidata:Talk:Q6' on enwp is namespace 1."""
     config.mylang = 'en'
     config.family = 'wikipedia'
     link = Link(':testwiki:wikidata:Talk:Q6')
     link.parse()
     self.assertEqual(link.site, self.get_site('wikidata'))
     self.assertEqual(link.title, 'Q6')
     self.assertEqual(link.namespace, 1)
Example #21
0
 def test_fully_qualified_NS0_family(self):
     """Test ':wikidata:testwiki:Q6' on enwp is namespace 0."""
     config.mylang = 'en'
     config.family = 'wikipedia'
     link = Link(':wikidata:testwiki:Q6')
     link.parse()
     self.assertEqual(link.site, self.get_site('test.wp'))
     self.assertEqual(link.title, 'Q6')
     self.assertEqual(link.namespace, 0)
Example #22
0
 def test_fully_qualified_NS1_code(self):
     """Test 'species:Talk:Main Page' on enwp is namespace 1."""
     config.mylang = 'en'
     config.family = 'wikipedia'
     link = Link('species:Talk:Main Page')
     link.parse()
     self.assertEqual(link.site, self.get_site())
     self.assertEqual(link.title, 'Main Page')
     self.assertEqual(link.namespace, 1)
Example #23
0
 def test_fully_qualified_NS1_family(self):
     """Test 'wikidata:testwiki:Talk:Q6' on enwp is namespace 1."""
     config.mylang = 'en'
     config.family = 'wikipedia'
     link = Link('wikidata:testwiki:Talk:Q6')
     link.parse()
     self.assertEqual(link.site, pywikibot.Site('test', 'wikipedia'))
     self.assertEqual(link.title, 'Q6')
     self.assertEqual(link.namespace, 1)
 def test(self):
     """Test combinations of parameters."""
     self._test_link(Link.create_separated('Foo', self.site), 'Foo', None,
                     None)
     self._test_link(Link.create_separated('Foo', self.site, section='Bar'),
                     'Foo', 'Bar', None)
     self._test_link(Link.create_separated('Foo', self.site, label='Baz'),
                     'Foo', None, 'Baz')
     self._test_link(
         Link.create_separated('Foo', self.site, section='Bar',
                               label='Baz'), 'Foo', 'Bar', 'Baz')
Example #25
0
 def test(self):
     """Test combinations of parameters."""
     self._test_link(Link.create_separated('Foo', self.site),
                     'Foo', None, None)
     self._test_link(Link.create_separated('Foo', self.site, section='Bar'),
                     'Foo', 'Bar', None)
     self._test_link(Link.create_separated('Foo', self.site, label='Baz'),
                     'Foo', None, 'Baz')
     self._test_link(Link.create_separated('Foo', self.site, section='Bar',
                                           label='Baz'),
                     'Foo', 'Bar', 'Baz')
Example #26
0
 def test_fully_qualified_NS1(self):
     """Test prefixed links with 'Talk:Q6' on enwp is namespace 1."""
     test = [('testwiki:wikidata', 'wikidata:wikidata'),
             ('wikidata:testwiki', 'wikipedia:test')]
     for linkprefix, sitetitle in test:
         with self.subTest(pattern=linkprefix):
             link = Link(linkprefix + ':Talk:Q6')
             link.parse()
             self.assertEqual(link.site, pywikibot.Site(sitetitle))
             self.assertEqual(link.title, 'Q6')
             self.assertEqual(link.namespace, 1)
Example #27
0
 def test_fully_qualified_NS1_family(self):
     """Test ':wikidata:testwiki:Talk:Q6' on enwp is namespace 1."""
     config.mylang = 'en'
     config.family = 'wikipedia'
     link = Link(':wikidata:testwiki:Talk:Q6')
     link.parse()
     if show_failures:
         self.assertEqual(link.site, self.get_site('test.wp'))
         self.assertEqual(link.title, 'Q6')
         self.assertEqual(link.namespace, 1)
     else:
         self.assertEqual(link.site, self.get_site('enwp'))
         self.assertEqual(link.title, 'Wikidata:testwiki:Talk:Q6')
         self.assertEqual(link.namespace, 0)
Example #28
0
 def test_fully_qualified_NS1_family(self):
     """Test 'wikidata:testwiki:Talk:Q6' on enwp is namespace 1."""
     config.mylang = 'en'
     config.family = 'wikipedia'
     link = Link('wikidata:testwiki:Talk:Q6')
     link.parse()
     if show_failures:
         self.assertEqual(link.site, pywikibot.Site('test', 'wikipedia'))
         self.assertEqual(link.title, 'Q6')
         self.assertEqual(link.namespace, 1)
     else:
         self.assertEqual(link.site, pywikibot.Site('en', 'wikipedia'))
         self.assertEqual(link.title, 'Wikidata:testwiki:Talk:Q6')
         self.assertEqual(link.namespace, 0)
Example #29
0
 def test_fully_qualified_NS0_family(self):
     """Test 'wikidata:testwiki:Q6' on enwp is namespace 0."""
     config.mylang = 'en'
     config.family = 'wikipedia'
     link = Link('wikidata:testwiki:Q6')
     link.parse()
     if show_failures:
         self.assertEqual(link.site, pywikibot.Site('test', 'wikipedia'))
         self.assertEqual(link.title, 'Q6')
         self.assertEqual(link.namespace, 0)
     else:
         self.assertEqual(link.site, pywikibot.Site('en', 'wikipedia'))
         self.assertEqual(link.title, 'Wikidata:testwiki:Q6')
         self.assertEqual(link.namespace, 0)
Example #30
0
 def test_fully_qualified_NS0_family(self):
     """Test ':wikidata:testwiki:Q6' on enwp is namespace 0."""
     config.mylang = 'en'
     config.family = 'wikipedia'
     link = Link(':wikidata:testwiki:Q6')
     link.parse()
     if show_failures:
         self.assertEqual(link.site, self.get_site('test.wp'))
         self.assertEqual(link.title, 'Q6')
         self.assertEqual(link.namespace, 0)
     else:
         self.assertEqual(link.site, self.get_site('enwp'))
         self.assertEqual(link.title, 'Wikidata:testwiki:Q6')
         self.assertEqual(link.namespace, 0)
Example #31
0
 def test_fully_qualified_NS1_code(self):
     """Test 'testwiki:wikidata:Talk:Q6' on enwp is namespace 1."""
     config.mylang = 'en'
     config.family = 'wikipedia'
     link = Link('testwiki:wikidata:Talk:Q6')
     if show_failures:
         link.parse()
         self.assertEqual(link.site, pywikibot.Site('wikidata', 'wikidata'))
         self.assertEqual(link.title, 'Q6')
         self.assertEqual(link.namespace, 1)
     else:
         self.assertRaisesRegex(
             pywikibot.Error,
             'Family testwiki does not exist',
             link.parse)  # very bad
Example #32
0
 def test_fully_qualified_NS0_family(self):
     """Test 'wikipedia:en:Main Page' on wikidata is namespace 0."""
     config.mylang = 'wikidata'
     config.family = 'wikidata'
     link = Link('wikipedia:en:Main Page')
     if show_failures:
         link.parse()
         self.assertEqual(link.site, self.get_site('enwp'))
         self.assertEqual(link.namespace, 0)
         self.assertEqual(link.title, 'Main Page')
     else:
         self.assertRaisesRegex(
             pywikibot.NoSuchSite,
             'Language wikidata does not exist in family wikipedia',
             link.parse)  # very bad
 def test_relative(self):
     """Test that relative links are handled properly."""
     # Subpage
     page = Page(self.get_site(), 'Foo')
     rel_link = Link('/bar', page)
     self.assertEqual(rel_link.title, 'Foo/bar')
     self.assertEqual(rel_link.site, self.get_site())
     # Subpage of Page with section
     page = Page(self.get_site(), 'Foo#Baz')
     rel_link = Link('/bar', page)
     self.assertEqual(rel_link.title, 'Foo/bar')
     self.assertEqual(rel_link.site, self.get_site())
     # Non-subpage link text beginning with slash
     abs_link = Link('/bar', self.get_site())
     self.assertEqual(abs_link.title, '/bar')
 def test_via_local_non_local(self):
     """Test de:translatewiki:Main Page on English Wikipedia."""
     link = Link('de:translatewiki:Main Page', self.get_site('wp'))
     self.assertRaisesRegex(
         InvalidTitle,
         "de:translatewiki:Main Page links to a non local site i18n:i18n "
         "via an interwiki link to wikipedia:de", link.parse)
Example #35
0
 def test_fully_qualified_NS1_code(self):
     """Test 'en:wikipedia:Talk:Main Page' on wikidata is not namespace 1."""
     config.mylang = 'wikidata'
     config.family = 'wikidata'
     link = Link('en:wikipedia:Talk:Main Page')
     link.parse()
     if show_failures:
         self.assertEqual(link.site, self.get_site('enwp'))
     else:
         self.assertEqual(link.site, self.get_site('wikidata'))
     if show_failures:
         self.assertEqual(link.title, 'Talk:Main Page')
         self.assertEqual(link.namespace, 4)
     else:
         self.assertEqual(link.title, 'En:wikipedia:Talk:Main Page')
         self.assertEqual(link.namespace, 0)
Example #36
0
 def test_invalid_wiki_prefix(self):
     """Test that Link with prefix not listed in InterwikiMap."""
     title = 'Unknownprefix:This title'
     link = Link(title, source=self.site)
     self.assertEqual(link.title, title)
     self.assertEqual(link.site, self.site)
     self.assertFalse(link._is_interwiki)
Example #37
0
 def test_fully_qualified_NS1(self):
     """Test that fully qualified link is in namespace 1."""
     family, code = 'wikipedia:en'.split(':')
     for colon in ('', ':'):  # with or without preleading colon
         # switch code:family sequence en:wikipedia or wikipedia:en
         for first, second in [(family, code), (code, family)]:
             with self.subTest(colon=colon,
                               site='{}:{}'.format(first, second)):
                 link_title = self.PATTERN.format(colon=colon,
                                                  first=first,
                                                  second=second,
                                                  title='Talk:Main Page')
                 link = Link(link_title)
                 link.parse()
                 self.assertEqual(link.site, self.get_site('enwp'))
                 self.assertEqual(link.title, 'Main Page')
                 self.assertEqual(link.namespace, 1)
 def test_other_wiki_prefix(self):
     """Test that Link fails if the interwiki prefix is a unknown family."""
     link = Link('bulba:this-will-never-work', source=self.site)
     self.assertRaisesRegex(
         Error,
         'bulba:this-will-never-work is not a local page on wikipedia:en, '
         'and the interwiki prefix bulba is not supported by Pywikibot!',
         link.parse)
 def test_non_wiki_prefix(self):
     """Test that Link fails if the interwiki prefix is not a wiki."""
     link = Link('bugzilla:1337', source=self.site)
     self.assertRaisesRegex(
         Error,
         'bugzilla:1337 is not a local page on wikipedia:en, and the '
         'interwiki prefix bugzilla is not supported by Pywikibot!',
         link.parse)
    def test_namespace_lookalike(self):
        """Test that Link does only detect valid namespaces."""
        link = Link('CAT:', self.get_site())
        link.parse()
        self.assertEqual(link.site, self.get_site())
        self.assertEqual(link.title, 'CAT:')
        self.assertEqual(link.namespace, 0)

        link = Link('en:CAT:', self.get_site())
        link.parse()
        self.assertEqual(link.site, self.get_site())
        self.assertEqual(link.title, 'CAT:')
        self.assertEqual(link.namespace, 0)
Example #41
0
 def test_py266_bug_exception(self):
     """Test Python issue 10254 causes an exception."""
     pywikibot.page.unicodedata = __import__('unicodedata')
     title = 'Li̍t-sṳ́'
     with self.assertRaisesRegex(
             UnicodeError,
             re.escape('Link(%r, %s): combining characters detected, which '
                       'are not supported by Pywikibot on Python 2.6.6. '
                       'See https://phabricator.wikimedia.org/T102461' %
                       (title, self.site))):
         Link(title, self.site)
Example #42
0
 def test_non_wiki_prefix(self):
     """Test that Link fails if the interwiki prefix is not a wiki."""
     link = Link('bugzilla:1337', source=self.site)
     # bugzilla does not return a json content but redirects to phab.
     # api.Request._json_loads cannot detect this problem and raises
     # a SiteDefinitionError. The site is created anyway but the title
     # cannot be parsed
     with self.assertRaises(SiteDefinitionError):
         link.site
     self.assertEqual(link.site.sitename, 'wikimedia:wikimedia')
     self.assertTrue(link._is_interwiki)
    def test_namespace_vs_family(self):
        """Test namespace is selected before family."""
        config.mylang = 'en'
        config.family = 'wikipedia'
        link = Link(':wikipedia:en:Main Page')
        link.parse()
        self.assertEqual(link.title, 'En:Main Page')
        self.assertEqual(link.namespace, 4)

        link = Link(':wikipedia:en:Talk:Main Page')
        link.parse()
        self.assertEqual(link.site, self.get_site())
        self.assertEqual(link.title, 'En:Talk:Main Page')
        self.assertEqual(link.namespace, 4)
    def test_valid(self):
        """Test that valid titles are correctly normalized."""
        title_tests = [
            'Sandbox', 'A "B"', "A 'B'", '.com', '~', '"', "'",
            'Foo/.../Sandbox', 'Sandbox/...', 'A~~', 'X' * 252
        ]

        extended_title_tests = [
            ('Talk:Sandbox', 'Sandbox'),
            ('Talk:Foo:Sandbox', 'Foo:Sandbox'),
            ('File:Example.svg', 'Example.svg'),
            ('File_talk:Example.svg', 'Example.svg'),
            (':A', 'A'),
            # Length is 256 total, but only title part matters
            ('Category:' + 'X' * 248, 'X' * 248),
            ('A%20B', 'A B'),
            ('A é B', 'A é B'),
            ('A é B', 'A é B'),
            ('A é B', 'A é B'),
            ('A   B', 'A B'),
            ('A   B', 'A B'),
        ]

        site = self.get_site()

        for title in title_tests:
            with self.subTest(title=title):
                self.assertEqual(Link(title, site).title, title)

        for link, title in extended_title_tests:
            with self.subTest(link=link, title=title):
                self.assertEqual(Link(link, site).title, title)

        anchor_link = Link('A | B', site)
        self.assertEqual(anchor_link.title, 'A')
        self.assertEqual(anchor_link.anchor, ' B')

        section_link = Link('A%23B', site)
        self.assertEqual(section_link.title, 'A')
        self.assertEqual(section_link.section, 'B')
Example #45
0
    def test_non_wiki_prefix(self):
        """Test that Link fails if the interwiki prefix is not a wiki."""
        link = Link('bugzilla:1337', source=self.site)
        # bugzilla does not return a json content but redirects to phab.
        # api.Request._json_loads cannot detect this problem and retries
        # reloading due to 'the server may be down'

        # ignore Timeout when trying to load siteninfo;
        # the site is created anyway but the title cannot be parsed
        with suppress(TimeoutError):
            link.site
        self.assertEqual(link.site.sitename, 'wikimedia:wikimedia')
        self.assertTrue(link._is_interwiki)
Example #46
0
 def test_fully_qualified_NS1_code(self):
     """Test 'en:wikipedia:Main Page' on enws is namespace 1."""
     config.mylang = 'en'
     config.family = 'wikisource'
     link = Link('en:wikipedia:Talk:Main Page')
     if show_failures:
         link.parse()
     else:
         self.assertRaisesRegex(
             pywikibot.Error,
             "Improperly formatted interwiki link 'en:wikipedia:Talk:Main Page'",
             link.parse)
     if show_failures:
         self.assertEqual(link.site, self.get_site('enwp'))
     else:
         self.assertEqual(link.site, self.get_site('enws'))
     if show_failures:
         self.assertEqual(link.title, 'Main Page')
         self.assertEqual(link.namespace, 1)
     else:
         try:
             link.title
         except pywikibot.Error as e:
             self.assertEqual(str(e), "Improperly formatted interwiki link 'en:wikipedia:Talk:Main Page'")
Example #47
0
    def test_namespace_lookalike(self):
        """Test that Link does only detect valid namespaces."""
        link = Link('CAT:', self.get_site())
        link.parse()
        self.assertEqual(link.site, self.get_site())
        self.assertEqual(link.title, 'CAT:')
        self.assertEqual(link.namespace, 0)

        link = Link('en:CAT:', self.get_site())
        link.parse()
        self.assertEqual(link.site, self.get_site())
        self.assertEqual(link.title, 'CAT:')
        self.assertEqual(link.namespace, 0)
Example #48
0
    def test_namespace_vs_family(self):
        """Test namespace is selected before family."""
        config.mylang = 'en'
        config.family = 'wikipedia'
        link = Link(':wikipedia:en:Main Page')
        link.parse()
        self.assertEqual(link.title, 'En:Main Page')
        self.assertEqual(link.namespace, 4)

        link = Link(':wikipedia:en:Talk:Main Page')
        link.parse()
        self.assertEqual(link.site, self.get_site())
        self.assertEqual(link.title, 'En:Talk:Main Page')
        self.assertEqual(link.namespace, 4)
 def test_direct_non_local(self):
     link = Link('translatewiki:Main Page', self.get_site('wp'))
     link.parse()
     self.assertEqual(link.site, self.get_site('tw'))
     self.assertEqual(link.title, 'Main Page')
     self.assertEqual(link.namespace, 0)