Exemplo n.º 1
0
 def setUp(self) -> None:
     super().setUp()
     self.measurement = LatencyMeasurement("test", "validfakehost.com")
     self.valid_latency = LatencyMeasurementResult(
         id="test",
         host="validfakehost.com",
         minimum_latency=6.211,
         average_latency=6.617,
         maximum_latency=7.069,
         median_deviation=0.315,
         errors=[],
         packets_transmitted=4,
         packets_received=4,
         packets_lost=0.0,
         packets_lost_unit=RatioUnit.percentage,
         elapsed_time=7.0,
         elapsed_time_unit=TimeUnit.millisecond,
     )
     self.invalid_latency = LatencyMeasurementResult(
         id="test",
         host="validfakehost.com",
         minimum_latency=None,
         average_latency=None,
         maximum_latency=None,
         median_deviation=None,
         errors=[
             Error(
                 key="ping-err",
                 description=LATENCY_ERRORS.get("ping-err", ""),
                 traceback="the ping messed up!",
             )
         ],
         packets_transmitted=None,
         packets_received=None,
         packets_lost=None,
         packets_lost_unit=None,
         elapsed_time=None,
         elapsed_time_unit=None,
     )
     self.invalid_regex = LatencyMeasurementResult(
         id="test",
         host="validfakehost.com",
         minimum_latency=None,
         average_latency=None,
         maximum_latency=None,
         median_deviation=None,
         errors=[
             Error(
                 key="ping-regex",
                 description=LATENCY_ERRORS.get("ping-regex", ""),
                 traceback="\nrtt min/avg/max/mdev = [BAD REGEX] ms\n",
             )
         ],
         packets_transmitted=None,
         packets_received=None,
         packets_lost=None,
         packets_lost_unit=None,
         elapsed_time=None,
         elapsed_time_unit=None,
     )
 def test_netflix_token_regex_err(self, mock_get_session):
     mock_error_result = NetflixFastMeasurementResult(
         id=("1"),
         download_rate=None,
         download_rate_unit=None,
         download_size=None,
         download_size_unit=None,
         asn=None,
         ip=None,
         isp=None,
         city=None,
         country=None,
         urlcount=self.nft.urlcount,
         reason_terminated=None,
         errors=[
             Error(
                 key="netflix-token-regex",
                 description=NETFLIX_ERRORS.get("netflix-token-regex", ""),
                 traceback=
                 'This is an invalid script response, containing BRoken:"This is the token"',
             )
         ],
     )
     mock_session = mock.MagicMock()
     mock_resp = mock.MagicMock()
     mock_resp.text = '<script src="(This is the script)">'
     mock_script_resp = mock.MagicMock()
     mock_script_resp.text = (
         'This is an invalid script response, containing BRoken:"This is the token"'
     )
     mock_session.get.side_effect = [mock_resp, mock_script_resp]
     mock_get_session.return_value = mock_session
     assert self.nft._get_fast_result() == mock_error_result
 def test_netflix_regex_err(self, mock_get_session):
     mock_error_result = NetflixFastMeasurementResult(
         id=("1"),
         download_rate=None,
         download_rate_unit=None,
         download_size=None,
         download_size_unit=None,
         asn=None,
         ip=None,
         isp=None,
         city=None,
         country=None,
         urlcount=self.nft.urlcount,
         reason_terminated=None,
         errors=[
             Error(
                 key="netflix-script-regex",
                 description=NETFLIX_ERRORS.get("netflix-script-regex", ""),
                 traceback=
                 '<Bript Brc="(This should be impossible to find)">',
             )
         ],
     )
     mock_session = mock.MagicMock()
     mock_resp = mock.MagicMock()
     mock_resp.text = '<Bript Brc="(This should be impossible to find)">'
     mock_session.get.side_effect = [mock_resp]
     mock_get_session.return_value = mock_session
     assert self.nft._get_fast_result() == mock_error_result
Exemplo n.º 4
0
 def test_host_is_none_returns_error(self):
     self.assertEqual(
         self.measurement._get_latency_results(None),
         [
             LatencyMeasurementResult(
                 id="test",
                 errors=[
                     Error(
                         key="ping-no-server",
                         description="No closest server could be resolved.",
                         traceback=None,
                     )
                 ],
                 host=None,
                 minimum_latency=None,
                 average_latency=None,
                 maximum_latency=None,
                 median_deviation=None,
                 packets_transmitted=None,
                 packets_received=None,
                 packets_lost=None,
                 packets_lost_unit=None,
                 elapsed_time=None,
                 elapsed_time_unit=None,
             )
         ],
     )
 def test_netflix_script_response_err(self, mock_get_session):
     mock_error_result = NetflixFastMeasurementResult(
         id=("1"),
         download_rate=None,
         download_rate_unit=None,
         download_size=None,
         download_size_unit=None,
         asn=None,
         ip=None,
         isp=None,
         city=None,
         country=None,
         urlcount=self.nft.urlcount,
         reason_terminated=None,
         errors=[
             Error(
                 key="netflix-script-response",
                 description=NETFLIX_ERRORS.get("netflix-script-response",
                                                ""),
                 traceback="Failed to pretend to establish a new connection",
             )
         ],
     )
     mock_session = mock.MagicMock()
     mock_resp = mock.MagicMock()
     mock_resp.text = '<script src="(This is the script)">'
     mock_session.get.side_effect = [
         mock_resp,
         ConnectionError("Failed to pretend to establish a new connection"),
     ]
     mock_get_session.return_value = mock_session
     assert self.nft._get_fast_result() == mock_error_result
 def test_netflix_connection_err(self, mock_get_session):
     mock_error_result = NetflixFastMeasurementResult(
         id=("1"),
         download_rate=None,
         download_rate_unit=None,
         download_size=None,
         download_size_unit=None,
         asn=None,
         ip=None,
         isp=None,
         city=None,
         country=None,
         urlcount=self.nft.urlcount,
         reason_terminated=None,
         errors=[
             Error(
                 key="netflix-connection",
                 description=NETFLIX_ERRORS.get("netflix-connection", ""),
                 traceback="Failed to pretend to establish a new connection",
             )
         ],
     )
     mock_session = mock.MagicMock()
     mock_resp = mock.MagicMock()
     mock_resp.text = '<script src="(This is the script)">'
     mock_script_resp = mock.MagicMock()
     mock_script_resp.text = (
         'This is the script response, containing token:"This is the token"'
     )
     mock_api_resp = mock.MagicMock()
     mock_api_resp.json.side_effect = [{
         "client": {},
         "targets": [{
             "url": "https://afakeurl.1.notreal.net/speedtest",
             "location": {
                 "city": "Foreign City One",
                 "country": "Foreign Country One",
             },
         }],
     }]
     mock_session.get.side_effect = [
         mock_resp,
         mock_script_resp,
         mock_api_resp,
         ConnectionError("Failed to pretend to establish a new connection"),
     ]
     mock_get_session.return_value = mock_session
     self.nft.thread_results = [
         {
             "index": i,
             "elapsed_time": None,
             "download_size": 0,
             "download_rate": 0,
             "url": None,
             "location": None,
         } for i in range(
             self.nft.urlcount)  # Generate thread results dict structure
     ]
     assert self.nft._get_fast_result() == mock_error_result
 def _get_ip_route_error(self, key, traceback):
     return IPRouteMeasurementResult(
         id=self.id,
         host=None,
         ip=None,
         hop_count=None,
         route=None,
         errors=[
             Error(key=key,
                   description=ROUTE_ERRORS.get(key, ""),
                   traceback=traceback)
         ],
     )
 def _get_wget_error(self, key, url, traceback):
     return DownloadSpeedMeasurementResult(
         id=self.id,
         url=url,
         download_rate_unit=None,
         download_rate=None,
         download_size=None,
         download_size_unit=None,
         errors=[
             Error(key=key,
                   description=WGET_ERRORS.get(key, ""),
                   traceback=traceback)
         ],
     )
Exemplo n.º 9
0
 def _get_youtube_error(self, key, traceback):
     return YouTubeMeasurementResult(
         id=self.id,
         url=self.url,
         download_rate_unit=None,
         download_rate=None,
         download_size=None,
         download_size_unit=None,
         elapsed_time=None,
         elapsed_time_unit=None,
         errors=[
             Error(
                 key=key,
                 description=YOUTUBE_ERRORS.get(key, ""),
                 traceback=traceback,
             )
         ],
     )
Exemplo n.º 10
0
 def _get_webpage_error(self, key, traceback):
     return WebpageMeasurementResult(
         id=self.id,
         url=self.url,
         download_rate_unit=None,
         download_rate=None,
         download_size=None,
         download_size_unit=None,
         asset_count=None,
         failed_asset_downloads=None,
         elapsed_time=None,
         elapsed_time_unit=None,
         errors=[
             Error(key=key,
                   description=WEB_ERRORS.get(key, ""),
                   traceback=traceback)
         ],
     )
 def test_netflix_api_parse_targets_err(self, mock_get_session):
     mock_error_result = NetflixFastMeasurementResult(
         id=("1"),
         download_rate=None,
         download_rate_unit=None,
         download_size=None,
         download_size_unit=None,
         asn=None,
         ip=None,
         isp=None,
         city=None,
         country=None,
         urlcount=self.nft.urlcount,
         reason_terminated=None,
         errors=[
             Error(
                 key="netflix-api-parse",
                 description=NETFLIX_ERRORS.get("netflix-api-parse", ""),
                 traceback="0",
             )
         ],
     )
     mock_session = mock.MagicMock()
     mock_resp = mock.MagicMock()
     mock_resp.text = '<script src="(This is the script)">'
     mock_script_resp = mock.MagicMock()
     mock_script_resp.text = (
         'This is the script response, containing token:"This is the token"'
     )
     mock_api_resp = mock.MagicMock()
     mock_api_resp.json = mock.MagicMock()
     mock_api_resp.json.side_effect = [{
         "targets": {
             "correct_values": "are not in here >:)"
         }
     }]
     mock_session.get.side_effect = [
         mock_resp, mock_script_resp, mock_api_resp
     ]
     mock_get_session.return_value = mock_session
     assert self.nft._get_fast_result() == mock_error_result
 def setUp(self) -> None:
     super().setUp()
     self.wpm = WebpageMeasurement("test", "http://validfakehost.com/test")
     self.simple_webpage_output = WebpageMeasurementResult(
         id="test",
         url="http://validfakehost.com/test",
         download_rate=100 / 1.00 * 8,
         download_rate_unit=NetworkUnit("bit/s"),
         download_size=100,
         download_size_unit=StorageUnit("B"),
         asset_count=123,
         failed_asset_downloads=0,
         elapsed_time=1.00,
         elapsed_time_unit=TimeUnit("s"),
         errors=[],
     )
     self.simple_asset_download_metrics = {
         "asset_download_size": 90,
         "failed_asset_downloads": 0,
         "completion_time": 2.00,
     }
     self.get_error_result = WebpageMeasurementResult(
         id="test",
         url="http://validfakehost.com/test",
         download_rate_unit=None,
         download_rate=None,
         download_size=None,
         download_size_unit=None,
         asset_count=None,
         failed_asset_downloads=None,
         elapsed_time=None,
         elapsed_time_unit=None,
         errors=[
             Error(
                 key="web-get",
                 description=WEB_ERRORS.get("web-get", ""),
                 traceback="[Errno -2] Name or service not known",
             )
         ],
     )
Exemplo n.º 13
0
 def _get_latency_error(self, key, host, traceback):
     return LatencyMeasurementResult(
         id=self.id,
         host=host,
         minimum_latency=None,
         average_latency=None,
         maximum_latency=None,
         median_deviation=None,
         packets_transmitted=None,
         packets_received=None,
         packets_lost=None,
         packets_lost_unit=None,
         elapsed_time=None,
         elapsed_time_unit=None,
         errors=[
             Error(
                 key=key,
                 description=LATENCY_ERRORS.get(key, ""),
                 traceback=traceback,
             )
         ],
     )
Exemplo n.º 14
0
 def _get_netflix_error(self, key, traceback):
     return NetflixFastMeasurementResult(
         id=self.id,
         download_rate=None,
         download_rate_unit=None,
         download_size=None,
         download_size_unit=None,
         asn=None,
         ip=None,
         isp=None,
         city=None,
         country=None,
         urlcount=self.urlcount,
         reason_terminated=None,
         errors=[
             Error(
                 key=key,
                 description=NETFLIX_ERRORS.get(key, ""),
                 traceback=traceback,
             )
         ],
     )
 def _get_speedtest_error(self, key, traceback):
     return SpeedtestdotnetMeasurementResult(
         id=self.id,
         download_rate=None,
         download_rate_unit=None,
         upload_rate=None,
         upload_rate_unit=None,
         data_received=None,
         data_received_unit=None,
         latency=None,
         server_name=None,
         server_id=None,
         server_sponsor=None,
         server_host=None,
         errors=[
             Error(
                 key=key,
                 description=SPEEDTEST_ERRORS.get(key, ""),
                 traceback=traceback,
             )
         ],
     )
 def test_netflix_api_json_err(self, mock_get_session):
     mock_error_result = NetflixFastMeasurementResult(
         id=("1"),
         download_rate=None,
         download_rate_unit=None,
         download_size=None,
         download_size_unit=None,
         asn=None,
         ip=None,
         isp=None,
         city=None,
         country=None,
         urlcount=self.nft.urlcount,
         reason_terminated=None,
         errors=[
             Error(
                 key="netflix-api-json",
                 description=NETFLIX_ERRORS.get("netflix-api-json", ""),
                 traceback=
                 "Json Decode screwed up :(: line 1 column 1 (char 0)",
             )
         ],
     )
     mock_session = mock.MagicMock()
     mock_resp = mock.MagicMock()
     mock_resp.text = '<script src="(This is the script)">'
     mock_script_resp = mock.MagicMock()
     mock_script_resp.text = (
         'This is the script response, containing token:"This is the token"'
     )
     mock_api_resp = mock.MagicMock()
     mock_api_resp.json.side_effect = json.decoder.JSONDecodeError(
         "Json Decode screwed up :(", "{BuSTED_JSON ::: asdf}", 0)
     mock_session.get.side_effect = [
         mock_resp, mock_script_resp, mock_api_resp
     ]
     mock_get_session.return_value = mock_session
     assert self.nft._get_fast_result() == mock_error_result
Exemplo n.º 17
0
 def setUp(self) -> None:
     super().setUp()
     self.id = "1"
     self.test_url = "https://www.youtube.com/watch?v=1233zthJUf31MA"
     self.ytm = YouTubeMeasurement(self.id, self.test_url)
     self.mock_progress_dicts = [
         {
             "_eta_str": "Unknown ETA",
             "_percent_str": "  0.0%",
             "_speed_str": "Unknown speed",
             "_total_bytes_str": "123.4MiB",
             "downloaded_bytes": 1024,
             "elapsed": 0.13415765762329102,
             "eta": None,
             "filename":
             "/tmp/youtube-dl_7954/1596695025_Portland Protest.mp4",
             "speed": None,
             "status": "downloading",
             "tmpfilename":
             "/tmp/youtube-dl_31918/1234567890_Fake Video.mp4.part",
             "total_bytes": 163492702,
         },
         {
             "_eta_str": "00:00",
             "_percent_str": "100.0%",
             "_speed_str": "12.34MiB/s",
             "_total_bytes_str": "123.4MiB",
             "downloaded_bytes": 163492702,
             "elapsed": 13.792589902877808,
             "eta": 0,
             "filename":
             "/tmp/youtube-dl_31918/1596679305_Portland Protest.mp4",
             "speed": 12345678.012500000,
             "status": "downloading",
             "tmpfilename":
             "/tmp/youtube-dl_31918/1234567890_Fake Video.mp4.part",
             "total_bytes": 163492702,
         },
         {
             "_elapsed_str": "12:34",
             "_total_bytes_str": "123.4MiB",
             "downloaded_bytes": 123456789,
             "elapsed": 12.345678987654321,
             "filename": "/tmp/youtube-dl_31918/1234567890_Fake Video.mp4",
             "status": "finished",
             "total_bytes": 123456789,
         },
     ]
     self.mock_progress_dicts_missing_attribute = [
         {
             "_eta_str": "Unknown ETA",
             "_percent_str": "  0.0%",
             "_speed_str": "Unknown speed",
             "_total_bytes_str": "123.4MiB",
             "downloaded_bytes": 1024,
             "elapsed": 0.13415765762329102,
             "eta": None,
             "filename":
             "/tmp/youtube-dl_7954/1596695025_Portland Protest.mp4",
             "speed": None,
             "status": "downloading",
             "tmpfilename":
             "/tmp/youtube-dl_31918/1234567890_Fake Video.mp4.part",
             "total_bytes": 163492702,
         },
         {
             "_eta_str": "00:00",
             "_percent_str": "100.0%",
             "_speed_str": "12.34MiB/s",
             "_total_bytes_str": "123.4MiB",
             "downloaded_bytes": 163492702,
             "elapsed": 13.792589902877808,
             "eta": 0,
             "filename":
             "/tmp/youtube-dl_31918/1596679305_Portland Protest.mp4",
             "speed": 12345678.012500000,
             "status": "downloading",
             "tmpfilename":
             "/tmp/youtube-dl_31918/1234567890_Fake Video.mp4.part",
             "total_bytes": 163492702,
         },
         {
             "_elapsed_str": "12:34",
             "_total_bytes_str": "123.4MiB",
             "downloaded_bytes": 123456789,
             "elapsed": 12.345678987654321,
             "filename": "/tmp/youtube-dl_31918/1234567890_Fake Video.mp4",
             "status": "finished",
             "BADotal_bytes": 123456789,
         },
     ]
     self.mock_progress_dicts_only_final = [{
         "_elapsed_str": "12:34",
         "_total_bytes_str": "123.4MiB",
         "downloaded_bytes": 123456789,
         "elapsed": 12.345678987654321,
         "filename": "/tmp/youtube-dl_31918/1234567890_Fake Video.mp4",
         "status": "finished",
         "total_bytes": 123456789,
     }]
     self.mock_valid_youtube_result = YouTubeMeasurementResult(
         id=self.id,
         url=self.test_url,
         download_rate=98765424.1,
         download_rate_unit=NetworkUnit("bit/s"),
         download_size=123456789,
         download_size_unit=StorageUnit("B"),
         elapsed_time=12.345678987654321,
         elapsed_time_unit=TimeUnit("s"),
         errors=[],
     )
     self.mock_extraction_fail_result = YouTubeMeasurementResult(
         id=self.id,
         url=self.test_url,
         download_rate=None,
         download_rate_unit=None,
         download_size=None,
         download_size_unit=None,
         elapsed_time=None,
         elapsed_time_unit=None,
         errors=[
             Error(
                 key="youtube-extractor",
                 description=YOUTUBE_ERRORS.get("youtube-extractor", ""),
                 traceback=
                 "Extraction failed!; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see  https://yt-dl.org/update  on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.",
             )
         ],
     )
     self.mock_download_fail_result = YouTubeMeasurementResult(
         id=self.id,
         url=self.test_url,
         download_rate=None,
         download_rate_unit=None,
         download_size=None,
         download_size_unit=None,
         elapsed_time=None,
         elapsed_time_unit=None,
         errors=[
             Error(
                 key="youtube-download",
                 description=YOUTUBE_ERRORS.get("youtube-download", ""),
                 traceback="Download failed!",
             )
         ],
     )
     self.mock_missing_attribute_result = YouTubeMeasurementResult(
         id=self.id,
         url=self.test_url,
         download_rate=None,
         download_rate_unit=None,
         download_size=None,
         download_size_unit=None,
         elapsed_time=None,
         elapsed_time_unit=None,
         errors=[
             Error(
                 key="youtube-attribute",
                 description=YOUTUBE_ERRORS.get("youtube-attribute", ""),
                 traceback=str(self.mock_progress_dicts_missing_attribute),
             )
         ],
     )
     self.mock_final_only_result = (YouTubeMeasurementResult(
         id=self.id,
         url=self.test_url,
         download_rate=None,
         download_rate_unit=None,
         download_size=None,
         download_size_unit=None,
         elapsed_time=None,
         elapsed_time_unit=None,
         errors=[
             Error(
                 key="youtube-progress_length",
                 description=YOUTUBE_ERRORS.get("youtube-progress_length",
                                                ""),
                 traceback=str(self.mock_progress_dicts_only_final),
             )
         ],
     ), )
     self.mock_final_only_result = YouTubeMeasurementResult(
         id=self.id,
         url=self.test_url,
         download_rate=None,
         download_rate_unit=None,
         download_size=None,
         download_size_unit=None,
         elapsed_time=None,
         elapsed_time_unit=None,
         errors=[
             Error(
                 key="youtube-progress_length",
                 description=YOUTUBE_ERRORS.get("youtube-progress_length",
                                                ""),
                 traceback=str(self.mock_progress_dicts_only_final),
             )
         ],
     )
     self.mock_file_remove_result = YouTubeMeasurementResult(
         id=self.id,
         url=self.test_url,
         download_rate=None,
         download_rate_unit=None,
         download_size=None,
         download_size_unit=None,
         elapsed_time=None,
         elapsed_time_unit=None,
         errors=[
             Error(
                 key="youtube-file",
                 description=YOUTUBE_ERRORS.get("youtube-file", ""),
                 traceback=
                 "[Errno 2] No such file or directory: 'example_file'",
             )
         ],
     )
     self.mock_directory_remove_result = YouTubeMeasurementResult(
         id=self.id,
         url=self.test_url,
         download_rate=None,
         download_rate_unit=None,
         download_size=None,
         download_size_unit=None,
         elapsed_time=None,
         elapsed_time_unit=None,
         errors=[
             Error(
                 key="youtube-no_directory",
                 description=YOUTUBE_ERRORS.get("youtube-no_directory", ""),
                 traceback=
                 "[Errno 2] No such file or directory: 'example_dir'",
             )
         ],
     )
     self.mock_directory_remove_nonempty_result = YouTubeMeasurementResult(
         id=self.id,
         url=self.test_url,
         download_rate=None,
         download_rate_unit=None,
         download_size=None,
         download_size_unit=None,
         elapsed_time=None,
         elapsed_time_unit=None,
         errors=[
             Error(
                 key="youtube-directory_nonempty",
                 description=YOUTUBE_ERRORS.get(
                     "youtube-directory_nonempty", ""),
                 traceback="[Errno 39] Directory not empty: 'example_dir'",
             )
         ],
     )
 def setUp(self) -> None:
     super().setUp()
     self.measurement = DownloadSpeedMeasurement(
         "test", ["https://validfakehost.com/test"])
     self.valid_wget_kibit_sec = DownloadSpeedMeasurementResult(
         id="test",
         url="http://validfakehost.com/test",
         download_rate_unit=NetworkUnit("Kibit/s"),
         download_rate=133.6,
         download_size=11376,
         download_size_unit=StorageUnit.bit,
         errors=[],
     )
     self.valid_wget_mibit_sec = DownloadSpeedMeasurementResult(
         id="test",
         url="http://validfakehost.com/test",
         download_rate_unit=NetworkUnit("Mibit/s"),
         download_rate=133.6,
         download_size=11376,
         download_size_unit=StorageUnit.bit,
         errors=[],
     )
     self.invalid_wget_mibit_sec = DownloadSpeedMeasurementResult(
         id="test",
         url="http://validfakehost.com/test",
         download_rate_unit=None,
         download_rate=None,
         download_size=None,
         download_size_unit=None,
         errors=[
             Error(
                 key="wget-err",
                 description=WGET_ERRORS.get("wget-err", ""),
                 traceback=
                 "\n2019-08-07 09:12:08 (16.7 MB/s) - '/dev/null’ saved [11376]\n\n",
             )
         ],
     )
     self.invalid_wget_download_unit = DownloadSpeedMeasurementResult(
         id="test",
         url="http://validfakehost.com/test",
         download_rate_unit=None,
         download_rate=None,
         download_size=None,
         download_size_unit=None,
         errors=[
             Error(
                 key="wget-download-unit",
                 description=WGET_ERRORS.get("wget-download-unit", ""),
                 traceback=
                 "\n2019-08-07 09:12:08 (16.7 TB/s) - '/dev/null’ saved [11376]\n\n",
             )
         ],
     )
     self.invalid_regex = DownloadSpeedMeasurementResult(
         id="test",
         url="http://validfakehost.com/test",
         download_rate_unit=None,
         download_rate=None,
         download_size=None,
         download_size_unit=None,
         errors=[
             Error(
                 key="wget-regex",
                 description=WGET_ERRORS.get("wget-regex", ""),
                 traceback="\n2019-08-07 09:12:08 [BAD REGEX]\n\n",
             )
         ],
     )
 def setUp(self) -> None:
     super().setUp()
     self.id = "1"
     self.example_hosts_one = ["www.fakesitetwo.com"]
     self.example_hosts_three = [
         "www.fakesiteone.com",
         "www.fakesitetwo.com",
         "www.fakesitethree.com",
     ]
     self.iprm = IPRouteMeasurement(self.id,
                                    hosts=self.example_hosts_one,
                                    count=4)
     self.example_trace_five = {
         "final.ip": {
             1: ("first.ip", False),
             2: ("second.ip", False),
             3: ("third.ip", False),
             4: ("fourth.ip", False),
             5: ("final.ip", True),
         }
     }
     self.example_trace_five_list = [
         "first.ip",
         "second.ip",
         "third.ip",
         "fourth.ip",
         "final.ip",
     ]
     self.example_result_five = IPRouteMeasurementResult(
         id=self.id,
         host=self.example_hosts_one[0],
         hop_count=5,
         ip="final.ip",
         route=self.example_trace_five_list,
         errors=[],
     )
     self.example_result_permission_err = IPRouteMeasurementResult(
         id=self.id,
         host=None,
         hop_count=None,
         ip=None,
         route=None,
         errors=[
             Error(
                 key="route-permission",
                 description=ROUTE_ERRORS.get("route-permission", ""),
                 traceback="[Errno 1] Operation not permitted",
             )
         ],
     )
     self.example_result_address_err = IPRouteMeasurementResult(
         id=self.id,
         host=None,
         hop_count=None,
         ip=None,
         route=None,
         errors=[
             Error(
                 key="route-address",
                 description=ROUTE_ERRORS.get("route-address", ""),
                 traceback="[Errno -2] Name or service not known",
             )
         ],
     )
     self.example_latency_results_three = [
         (LatencyMeasurementResult(
             id=self.id,
             host="www.fakesiteone.com",
             minimum_latency=None,
             average_latency=None,
             maximum_latency=None,
             median_deviation=None,
             errors=[],
             packets_transmitted=None,
             packets_received=None,
             packets_lost=None,
             packets_lost_unit=None,
             elapsed_time=None,
             elapsed_time_unit=None,
         ), ),
         (LatencyMeasurementResult(
             id=self.id,
             host="www.fakesitetwo.com",
             minimum_latency=None,
             average_latency=25.0,
             maximum_latency=None,
             median_deviation=None,
             errors=[],
             packets_transmitted=None,
             packets_received=None,
             packets_lost=None,
             packets_lost_unit=None,
             elapsed_time=None,
             elapsed_time_unit=None,
         ), ),
         (LatencyMeasurementResult(
             id=self.id,
             host="www.fakesitethree.com",
             minimum_latency=None,
             average_latency=999.0,
             maximum_latency=None,
             median_deviation=None,
             errors=[],
             packets_transmitted=None,
             packets_received=None,
             packets_lost=None,
             packets_lost_unit=None,
             elapsed_time=None,
             elapsed_time_unit=None,
         ), ),
     ]
     self.example_least_latent_result = ((LatencyMeasurementResult(
         id=self.id,
         host="www.fakesitetwo.com",
         minimum_latency=None,
         average_latency=24.9,
         maximum_latency=None,
         median_deviation=None,
         errors=[],
         packets_transmitted=None,
         packets_received=None,
         packets_lost=None,
         packets_lost_unit=None,
         elapsed_time=None,
         elapsed_time_unit=None,
     ), ), )
 def setUp(self) -> None:
     super().setUp()
     self.id = "1"
     self.stdnm = SpeedtestdotnetMeasurement("1")
     self.sample_results_dict_valid = {
         "download": 93116804.64881887,
         "upload": 19256654.06593738,
         "ping": 17.054,
         "server": {
             "url": "http://fake.site:8080/speedtest/upload.php",
             "lat": "-33.8600",
             "lon": "151.2111",
             "name": "HonestyVille",
             "country": "Australia",
             "cc": "AU",
             "sponsor": "'Yes' HonestyBox",
             "id": "1267",
             "url2": "http://s1.fake.site:8080/speedtest/upload.php",
             "host": "fake.site:8080",
             "d": 53.70823411720704,
             "latency": 17.054,
         },
         "timestamp": "2020-03-11T07:09:52.890803Z",
         "bytes_sent": 25591808,
         "bytes_received": 116746522,
         "share": "http://www.faketest.net/result/9117363621.png",
         "client": {
             "ip": "101.166.54.134",
             "lat": "-33.4102",
             "lon": "151.4225",
             "isp": "HonestyBox Internet",
             "isprating": "3.7",
             "rating": "0",
             "ispdlavg": "0",
             "ispulavg": "0",
             "loggedin": "0",
             "country": "AU",
         },
     }
     self.sample_result_valid = SpeedtestdotnetMeasurementResult(
         id=self.id,
         download_rate=93116804.64881887,
         download_rate_unit=NetworkUnit("bit/s"),
         upload_rate=19256654.06593738,
         upload_rate_unit=NetworkUnit("bit/s"),
         data_received=116746522,
         data_received_unit=StorageUnit("B"),
         latency=17.054,
         server_name="HonestyVille",
         server_id="1267",
         server_sponsor="'Yes' HonestyBox",
         server_host="fake.site:8080",
         errors=[],
     )
     self.sample_result_configretrieval = SpeedtestdotnetMeasurementResult(
         id=self.id,
         download_rate=None,
         download_rate_unit=None,
         upload_rate=None,
         upload_rate_unit=None,
         data_received=None,
         data_received_unit=None,
         latency=None,
         server_name=None,
         server_id=None,
         server_sponsor=None,
         server_host=None,
         errors=[
             Error(
                 key="speedtest-config",
                 description=SPEEDTEST_ERRORS.get("speedtest-config", ""),
                 traceback="<urlopen error [Errno -3] Temporary failure in name resolution>",
             )
         ],
     )
     self.sample_result_bestserver = SpeedtestdotnetMeasurementResult(
         id=self.id,
         download_rate=None,
         download_rate_unit=None,
         upload_rate=None,
         upload_rate_unit=None,
         data_received=None,
         data_received_unit=None,
         latency=None,
         server_name=None,
         server_id=None,
         server_sponsor=None,
         server_host=None,
         errors=[
             Error(
                 key="speedtest-best-server",
                 description=SPEEDTEST_ERRORS.get("speedtest-best-server", ""),
                 traceback="Unable to connect to servers to test latency.",
             )
         ],
     )
     self.sample_result_share = SpeedtestdotnetMeasurementResult(
         id=self.id,
         download_rate=None,
         download_rate_unit=None,
         upload_rate=None,
         upload_rate_unit=None,
         data_received=None,
         data_received_unit=None,
         latency=None,
         server_name=None,
         server_id=None,
         server_sponsor=None,
         server_host=None,
         errors=[
             Error(
                 key="speedtest-share",
                 description=SPEEDTEST_ERRORS.get("speedtest-share", ""),
                 traceback="<urlopen error [Errno -3] Temporary failure in name resolution>",
             )
         ],
     )