tests package

Submodules

tests.lesson_1_test module

Test suite for lesson 1.

class tests.lesson_1_test.Lesson1TestCase(methodName='runTest')[source]

Bases: TestCase

Testing led functionality by mocking Pin methods

_classSetupFailed = False
_class_cleanups = []
test_check_toggle_val_0()[source]

Pass 0 as a parameter. No errors. Returns None. :return:

test_check_toggle_val_1()[source]

Pass 1 as a parameter. No errors. Returns None. :return:

test_check_toggle_val_type_error()[source]

Pass string as a parameter. Verify exception text. :return:

test_led_off()[source]

Mock the led.value() function and return 0 always :return:

test_toggle_is_on_0()[source]

Testing toggle_is_on function. Should return 1 when input param is 0. :return:

test_toggle_is_on_1()[source]

Testing toggle_is_on function. Should return 0 when input param is 1. :return:

test_toggle_is_on_error()[source]

Testing toggle_is_on function. Should return error when input param is invalid. :return:

test_toggle_led_error()[source]

Pass invalid param value. Verify error. :return:

test_toggle_led_off()[source]

Turn LED off. Check function return value is None. :return:

test_toggle_led_on()[source]

Turn LED on. Check function return value is None. :return:

tests.lesson_2_test module

Test suite for lesson 2.

class tests.lesson_2_test.Lesson2TestCase(methodName='runTest')[source]

Bases: TestCase

Testing led functionality by mocking Pin methods

_classSetupFailed = False
_class_cleanups = []
test_led_off()[source]

Mock the led.value() function and return 0 always :return:

test_led_on()[source]

Mock the led.value() function and return 1 always :return:

tests.lesson_3_4_test module

Unit testing lessons 3 and 4.

class tests.lesson_3_4_test.Lesson3and4TestCase(methodName='runTest')[source]

Bases: TestCase

Lessons 3 and 4 test case.

_classSetupFailed = False
_class_cleanups = []
test_get_val_false()[source]

Testing get_val function. False input should be converted into 0. :return:

test_get_val_return_type()[source]

Testing get_val function. Return type should be int. :return:

test_get_val_true()[source]

Testing get_val function. True input should be converted into 1. :return:

test_numbers_0()[source]

Testing numbers dictionary -> key 0 :return:

test_numbers_15()[source]

Testing numbers dictionary -> key 15 :return:

test_numbers_7()[source]

Testing numbers dictionary -> key 7 :return:

test_numbers_data_type()[source]

Testing numbers dictionary -> datatype should be dict :return:

test_set_all_pins_off()[source]

Testing set_all_pins function. Turn off all pins. :return:

test_set_all_pins_on()[source]

Testing set_all_pins function. Turn on all pins :return:

test_set_pin_value_off()[source]

Pin value should return 0 after it was updated by set_pin_value function :return:

test_set_pin_value_on()[source]

Pin value should return 1 after it was updated by set_pin_value function :return:

tests.lesson_5_test module

Unit testing for lesson 5

class tests.lesson_5_test.Lesson5TestCase(methodName='runTest')[source]

Bases: TestCase

Lesson 5 test case

_classSetupFailed = False
_class_cleanups = []
test_voltage_0()[source]

Reading Analog Voltage -> min value is 96 Should be converted to 0 volt :return:

test_voltage_3_3()[source]

Reading Analog Voltage -> max value is 65535 Should be converted to 3.3 volt :return:

test_voltage_mid_value()[source]

Reading Analog Voltage -> mid-value Should be converted to 1.65 volt :return:

tests.lesson_6_test module

Unit testing for lesson 6

class tests.lesson_6_test.MyTestCase(methodName='runTest')[source]

Bases: TestCase

Testing led functionality by mocking Pin methods

_classSetupFailed = False
_class_cleanups = []
test_led_on()[source]

Testing led on func by mocking PIN methods. :return:

test_pin_n_data_type()[source]

Verify data type (should be int). :return:

test_pin_n_value()[source]

This test exist only for code coverage purposes. Testing that PIN_N val is 14. :return:

tests.lesson_7and_8_test module

Test suite for lesson 7 and 8.

class tests.lesson_7and_8_test.Lesson7And8TestCase(methodName='runTest')[source]

Bases: TestCase

Test case for lesson 7 and 8.

_classSetupFailed = False
_class_cleanups = []
test_all_led_off()[source]

Verify that all_led_off returns None. :return:

test_converter_max()[source]

Converter output should be 100 for read pin value 65535. :return:

test_converter_mid_range_49()[source]

Converter output should be 49 for read pin value 32767. :return:

test_converter_mid_range_50()[source]

Converter output should be 50 for read pin value 32768. :return:

test_converter_min()[source]

Converter output should be 0 for read pin value 0. :return:

test_converter_return_type()[source]

Converter output type should be integer. :return:

test_value_to_color_green_max()[source]

79 should correspond to green color. :return:

test_value_to_color_green_mid()[source]

40 should correspond to green color. :return:

test_value_to_color_green_min()[source]

Zero should correspond to green color. :return:

test_value_to_color_red_max()[source]

100 should correspond to red color. :return:

test_value_to_color_red_mid()[source]

97 should correspond to red color. :return:

test_value_to_color_red_min()[source]

95 should correspond to red color. :return:

test_value_to_color_return_type()[source]

Return type should be string. :return:

test_value_to_color_yellow_max()[source]

94 should correspond to yellow color. :return:

test_value_to_color_yellow_mid()[source]

87 should correspond to yellow color. :return:

test_value_to_color_yellow_min()[source]

80 should correspond to yellow color. :return:

tests.lesson_9_and_10_test module

Test suite for lesson 9 and 10.

class tests.lesson_9_and_10_test.Lesson9And10TestCase(methodName='runTest')[source]

Bases: TestCase

Test case for lesson 9 and 10.

_classSetupFailed = False
_class_cleanups = []
test_analog_out_freq()[source]

Mocking and testing analogOut.freq() :return:

test_pin_num_data_type()[source]

PIN_NUM data type should be int. :return:

test_pin_num_value()[source]

PIN_NUM value should be 16. :return:

test_voltage_error()[source]

Verify VoltageError message. :return:

tests.lesson_11_test module

Test suite for lesson 11.

class tests.lesson_11_test.Lesson11TestCase(methodName='runTest')[source]

Bases: TestCase

Test case for lesson 11.

_classSetupFailed = False
_class_cleanups = []
test_analog_out_duty_u16()[source]

Mocking and testing analogOut.duty_u16() :return:

test_constant_data_type()[source]

CONSTANT data type should be float. :return:

test_constant_value()[source]

CONSTANT value should be equal to 1.248336. :return:

test_max_read_val_data_type()[source]

MAX_READ_VAL data type should be int. :return:

test_max_read_val_value()[source]

MAX_READ_VAL value should be equal to 65550. :return:

test_pin_num_data_type()[source]

PIN_NUM data type should be int. :return:

test_pin_num_value()[source]

PIN_NUM value should be equal to 16. :return:

test_steps_data_type()[source]

STEPS data type should be int. :return:

test_steps_value()[source]

STEPS value should be equal to 50. :return:

tests.lesson_12_test module

Test suite for lesson 12.

class tests.lesson_12_test.Lesson12TestCase(methodName='runTest')[source]

Bases: TestCase

Test case for lesson 12.

_classSetupFailed = False
_class_cleanups = []
test_calc_pwm_0()[source]

Pass 0 as color_value. Result should be 0. :return:

test_calc_pwm_165()[source]

Pass 165 as color_value. Result should be 42414. :return:

test_calc_pwm_255()[source]

Pass 255 as color_value. Result should be 65550. :return:

test_colors_data_type()[source]

colors data type should be dictionary. :return:

test_get_color_exit_mixed(mock_input)[source]

Verify that get_color returns exit on eXiT as user input :return:

test_get_color_invalid_input(mock_input)[source]

Verify that get_color returns error message on invalid input and white on wHitE as user input. Source: https://andressa.dev/2019-07-20-using-pach-to-test-inputs/ :return:

test_get_color_red_mixed(mock_input)[source]

Verify that get_color returns red on rEd as user input :return:

test_initial_setup_returns_none()[source]

initial_setup should return none. :return:

test_led_on_print_debug_red()[source]

Test that led_on prints proper debug line for red color. Source: https://stackoverflow.com/questions/69036159/how-to-write-python-unit-test-for-the-print-statement :return:

test_led_on_print_debug_white()[source]

Test that led_on prints proper debug line for white color. Source: https://stackoverflow.com/questions/69036159/how-to-write-python-unit-test-for-the-print-statement :return:

test_pins_data_type()[source]

pins data type should be dictionary. :return:

test_pwms_data_type()[source]

pwms data type should be tuple. :return:

test_pwms_off_returns_none()[source]

pwms_off should return none. :return:

tests.lesson_13_test module

Test suite for lesson 13.

class tests.lesson_13_test.Lesson13TestCase(methodName='runTest')[source]

Bases: TestCase

Test case for lesson 13.

_classSetupFailed = False
_class_cleanups = []
test_led_red_freq()[source]

Mocking and testing led_red.freq() :return:

Module contents