You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.5 KiB

#!/usr/bin/env python
# TestScraper.py
import unittest
from scraper import Scraper
class KnownValues(unittest.TestCase):
scraper = Scraper()
def test_instance(self):
self.assertIsInstance(self.scraper, Scraper)
def test_bytes_to_multiples(self):
self.assertEqual(Scraper.bytes_to_multiples(8302.2049371), '8.3kb')
self.assertEqual(Scraper.bytes_to_multiples(8302.2049371), '8.3kb')
self.assertEqual(Scraper.bytes_to_multiples(10), '10b')
self.assertEqual(Scraper.bytes_to_multiples(10000), '10kb')
self.assertEqual(Scraper.bytes_to_multiples(20000), '20kb')
self.assertEqual(Scraper.bytes_to_multiples(10000000), '10mb')
self.assertEqual(Scraper.bytes_to_multiples(1000000000), '1gb')
self.assertEqual(Scraper.bytes_to_multiples(1250000000), '1.25gb')
self.assertEqual(Scraper.bytes_to_multiples(160000000), '160mb')
def test_get_speed_string(self):
self.assertEqual(Scraper.get_speed_string(768000), '768kb/s')
def test_get_completion(self):
self.assertEqual(Scraper.get_completion(10, 100), '10% - 10b/100b')
self.assertEqual(Scraper.get_completion(3, 10), '30% - 3b/10b')
self.assertEqual(Scraper.get_completion(24, 289), '8.3% - 24b/289b')
def test_calc_res(self):
self.assertEqual(Scraper.calc_res('800x600'), 800 * 600)
self.assertEqual(Scraper.calc_res('1920x1024'), 1920 * 1024)
if __name__ == '__main__':
unittest.main()