# Path: wikitextparser/_externallink.py
# class ExternalLink(SubWikiText):
# 
#     __slots__ = ()
# 
#     @property
#     def url(self) -> str:
#         """URL of the current ExternalLink object.
# 
#         getter: Return the URL.
#         setter: Set a new value for URL. Convert add brackets for bare
#             external links.
#         """
#         if self(0) == '[':
#             return self(1, URL_MATCH(self._ext_link_shadow, 1).end())
#         return self.string
# 
#     @url.setter
#     def url(self, newurl: str) -> None:
#         if self(0) == '[':
#             self[1:len('[' + self.url)] = newurl
#         else:
#             self[0:len(self.url)] = newurl
# 
#     @property
#     def text(self) -> Optional[str]:
#         """The text part (the part after the url).
# 
#         getter: Return None if this is a bare link or has no associated text.
#         setter: Automatically put the ExternalLink in brackets if it's not
#             already.
#         deleter: Delete self.text, including the space before it.
#         """
#         string = self.string
#         if string[0] == '[':
#             url_end = URL_MATCH(self._ext_link_shadow, 1).end()
#             end_char = string[url_end]
#             if end_char == ']':
#                 return None
#             if end_char == ' ':
#                 return string[url_end + 1:-1]
#             return string[url_end:-1]
# 
#     @text.setter
#     def text(self, newtext: str) -> None:
#         string = self.string
#         if string[0] == '[':
#             text = self.text
#             if text:
#                 self[-len(text) - 1:-1] = newtext
#                 return
#             self.insert(-1, ' ' + newtext)
#             return
#         self.insert(len(string), ' ' + newtext + ']')
#         self.insert(0, '[')
# 
#     @text.deleter
#     def text(self) -> None:
#         string = self.string
#         if string[0] != '[':
#             return
#         text = self.text
#         if text:
#             del self[-len(text) - 2:-1]
# 
#     @property
#     def in_brackets(self) -> bool:
#         """Return true if the ExternalLink is in brackets. False otherwise."""
#         return self(0) == '['
# 
#     @property
#     def external_links(self) -> List['ExternalLink']:
#         return []


﻿from wikitextparser import ExternalLink


def test_externallinks():
    assert ExternalLink('http://example.org').external_links == []


def test_repr():
    assert repr(ExternalLink('HTTP://mediawiki.org')) == \
        "ExternalLink('HTTP://mediawiki.org')"


def test_numberedmailto_change_none_to_empty():
    s = (
        '[mailto:'
        'info@example.org?Subject=URL%20Encoded%20Subject&body='
        'Body%20Textinfo]')

# Path: wikitextparser/_externallink.py
# class ExternalLink(SubWikiText):
# 
#     __slots__ = ()
# 
#     @property
#     def url(self) -> str:
#         """URL of the current ExternalLink object.
# 
#         getter: Return the URL.
#         setter: Set a new value for URL. Convert add brackets for bare
#             external links.
#         """
#         if self(0) == '[':
#             return self(1, URL_MATCH(self._ext_link_shadow, 1).end())
#         return self.string
# 
#     @url.setter
#     def url(self, newurl: str) -> None:
#         if self(0) == '[':
#             self[1:len('[' + self.url)] = newurl
#         else:
#             self[0:len(self.url)] = newurl
# 
#     @property
#     def text(self) -> Optional[str]:
#         """The text part (the part after the url).
# 
#         getter: Return None if this is a bare link or has no associated text.
#         setter: Automatically put the ExternalLink in brackets if it's not
#             already.
#         deleter: Delete self.text, including the space before it.
#         """
#         string = self.string
#         if string[0] == '[':
#             url_end = URL_MATCH(self._ext_link_shadow, 1).end()
#             end_char = string[url_end]
#             if end_char == ']':
#                 return None
#             if end_char == ' ':
#                 return string[url_end + 1:-1]
#             return string[url_end:-1]
# 
#     @text.setter
#     def text(self, newtext: str) -> None:
#         string = self.string
#         if string[0] == '[':
#             text = self.text
#             if text:
#                 self[-len(text) - 1:-1] = newtext
#                 return
#             self.insert(-1, ' ' + newtext)
#             return
#         self.insert(len(string), ' ' + newtext + ']')
#         self.insert(0, '[')
# 
#     @text.deleter
#     def text(self) -> None:
#         string = self.string
#         if string[0] != '[':
#             return
#         text = self.text
#         if text:
#             del self[-len(text) - 2:-1]
# 
#     @property
#     def in_brackets(self) -> bool:
#         """Return true if the ExternalLink is in brackets. False otherwise."""
#         return self(0) == '['
# 
#     @property
#     def external_links(self) -> List['ExternalLink']:
#         return []


# Path: tests/test_externallink.py
﻿from wikitextparser import ExternalLink



def test_externallinks():
    assert ExternalLink('http://example.org').external_links == []


def test_repr():
    assert repr(ExternalLink('HTTP://mediawiki.org')) == \
        "ExternalLink('HTTP://mediawiki.org')"


def test_numberedmailto_change_none_to_empty():
    s = (
        '[mailto:'
        'info@example.org?Subject=URL%20Encoded%20Subject&body='
        'Body%20Textinfo]')

    el = ExternalLink(s)