Пример #1
0
 def test_shorten_url(self):
     scheme = "http"
     netloc = "localhost"
     unique, short_url = UrlShorten.shorten_url("https://www.google.com",
                                                scheme, netloc)
     self.assertEqual(unique, "ZDYyMw")
     self.assertEqual(short_url, "http://localhost/ZDYyMw")
Пример #2
0
 def test_shorten_url(self):
     scheme = 'http'
     netloc = 'localhost' + ':' + str(8888)
     unique, short_url = UrlShorten.shorten_url('https://www.google.com',
                                                scheme, netloc)
     self.assertEqual(unique, 'ZDYyMw')
     self.assertEqual(short_url,
                      'http://localhost:8888/forward?unique=ZDYyMw')
Пример #3
0
 def test_md5(self):
     md5_text = UrlShorten.md5("https://www.google.com")
     self.assertEqual(md5_text, "8ffdefbdec956b595d257f0aaeefd623")
Пример #4
0
 def test_create_unique(self):
     unique = UrlShorten.create_unique("https://www.google.com")
     self.assertEqual(unique, "ZDYyMw")
Пример #5
0
 def test_encode_base64(self):
     base64_encoded = UrlShorten.encode_base64(b"axcv4")
     self.assertEqual(base64_encoded, "YXhjdjQ=")
Пример #6
0
 def test_string_from_bytes(self):
     bytes = [112, 52, 52]
     string = UrlShorten.string_from_bytes(bytes)
     self.assertEqual(string, "p44")
Пример #7
0
 def test_get_last_x_element(self):
     byte_array = UrlShorten.byte_array("https://www.google.com")
     last_four_element = UrlShorten.get_last_x_element(byte_array, 4)
     self.assertEqual(len(last_four_element), 4)
Пример #8
0
 def test_byte_array(self):
     byte_array = UrlShorten.byte_array("https://www.google.com")
     self.assertIsNotNone(byte_array)
Пример #9
0
 def __create_shorten_url(self, url: str):
     netloc = ip_address + ":" + str(port)
     unique, short_url = UrlShorten.shorten_url(url, scheme, netloc)
     store.keep(unique, url)
     return short_url
Пример #10
0
 def test_create_unique(self):
     unique = UrlShorten.create_unique('https://www.google.com')
     self.assertEqual(unique, 'ZDYyMw')
Пример #11
0
 def test_encode_base64(self):
     base64_encoded = UrlShorten.encode_base64(b'axcv4')
     self.assertEqual(base64_encoded, 'YXhjdjQ=')