Beispiel #1
0
    def test_with(self):
        url = URL('http://www.example.com/path/to/file.exe?query?fragment')

        self.assertEqual(
            str(url.with_scheme('https')),
            'https://www.example.com/path/to/file.exe?query?fragment')
        self.assertEqual(str(url.with_netloc('localhost')),
                         'http://localhost/path/to/file.exe?query?fragment')
        self.assertEqual(
            str(url.with_userinfo('username', 'password')),
            'http://*****:*****@www.example.com/path/to/file.exe?query?fragment'
        )
        self.assertEqual(
            str(url.with_userinfo(None, None)),
            'http://www.example.com/path/to/file.exe?query?fragment')
        self.assertEqual(
            str(url.with_hostinfo('localhost', 8080)),
            'http://localhost:8080/path/to/file.exe?query?fragment')

        self.assertEqual(str(URL('http://example.com/base/') / 'path/to/file'),
                         'http://example.com/base/path/to/file')

        self.assertEqual(
            str(
                URL('http://example.com/path/?q') /
                URL('http://localhost/app/?q') / URL('to/content')),
            'http://localhost/app/to/content')
 def __init__(
     self,
     symbol,
     *,
     log_level=logging.INFO,
     test=True,
     api_key=None,
     api_secret=None,
 ) -> None:
     super().__init__(log_level=log_level)
     u = URL("https://testnet.bitmex.com/api/v1")
     host = str(u) if test else str(u.with_netloc("www.bitmex.com"))
     self.__reset()
     self.connect(host, symbol, shouldAuth=True)
Beispiel #3
0
    def test_with(self):
        url = URL('http://www.example.com/path/to/file.exe?query?fragment')

        self.assertEqual(str(url.with_scheme('https')), 'https://www.example.com/path/to/file.exe?query?fragment')
        self.assertEqual(str(url.with_netloc('localhost')), 'http://localhost/path/to/file.exe?query?fragment')
        self.assertEqual(str(url.with_userinfo('username', 'password')),
                         'http://*****:*****@www.example.com/path/to/file.exe?query?fragment')
        self.assertEqual(str(url.with_userinfo(None, None)), 'http://www.example.com/path/to/file.exe?query?fragment')
        self.assertEqual(str(url.with_hostinfo('localhost', 8080)),
                         'http://localhost:8080/path/to/file.exe?query?fragment')

        self.assertEqual(str(URL('http://example.com/base/') / 'path/to/file'), 'http://example.com/base/path/to/file')

        self.assertEqual(str(URL('http://example.com/path/?q') / URL('http://localhost/app/?q') / URL('to/content')),
                         'http://localhost/app/to/content')