def test_bit_versus_byte_awareness(self): speed_bit_measurement = timeleft.Measurement("10Mbps") speed_byte_measurement = timeleft.Measurement("10MBps") size_bit_measurement = timeleft.Measurement("10Mb") size_byte_measurement = timeleft.Measurement("10MB") assert speed_bit_measurement.get_base_amount() * 8.0 == speed_byte_measurement.get_base_amount() and \ size_bit_measurement.get_base_amount() * 8.0 == size_byte_measurement.get_base_amount()
def setup(self): """ CaseInsensitiveDict instance with "Accept" header. """ self.valid_speed_measurement = timeleft.Measurement(VALID_SPEED_MEASUREMENT_NUMBER + VALID_SPEED_MEASUREMENT_PREFIX + "Bps") self.valid_size_measurement = timeleft.Measurement(VALID_SIZE_MEASUREMENT_NUMBER + VALID_SIZE_MEASUREMENT_PREFIX + "B")
def test_get_duration_seconds(self): valid_speed_measurement = timeleft.Measurement(VALID_SPEED_MEASUREMENT_NUMBER + VALID_SPEED_MEASUREMENT_PREFIX + "Bps") valid_size_measurement = timeleft.Measurement(VALID_SIZE_MEASUREMENT_NUMBER + VALID_SIZE_MEASUREMENT_PREFIX + "B") assert timeleft.get_duration_seconds([valid_speed_measurement, valid_size_measurement]) == 1.0
def test_valid_get_measurements_input(self): args = ["100MBps", "100MB"] test_measurements = tuple(timeleft.get_measurements(args)) comparison_measurements = (timeleft.Measurement("100MBps"), timeleft.Measurement("100MB")) assert test_measurements == comparison_measurements
def test_invalid_measurement_input(self): with pytest.raises(RuntimeError): timeleft.Measurement("")
def test_speed_measurement_input_variations(self, input_string): speed_measurement = timeleft.Measurement(input_string) assert speed_measurement == self.valid_speed_measurement