hitl_tester.test_cases.bms.test_hitl_issue74
A quick script to test issue 74. No longer works as it uses an old API.
1""" 2A quick script to test issue 74. 3No longer works as it uses an old API. 4""" 5 6import pytest 7 8from hitl_tester.modules.bms.bms_hw import BMSHardware 9 10bms_hardware = BMSHardware(pytest.flags) # type: ignore[arg-type] 11bms_hardware.init() 12 13 14def test_discharge_step_no_current(): 15 """Testing the case where the discharge current is not set.""" 16 # set and verify the other variables used by the run_discharge_step_cycle 17 bms_hardware.current = 0 # This is the case we're testing 18 assert bms_hardware.current == 0 # Verify the value 19 20 bms_hardware.sample_interval = 500 # Set to some value 21 assert bms_hardware.sample_interval == 500 # Verify the value 22 23 bms_hardware.uv_protection = 2.4 # set to some value 24 assert bms_hardware.uv_protection == 2.4 # Verify the value 25 26 bms_hardware.total_ah = 50 # set to some value 27 assert bms_hardware.total_ah == 50 # Verify the value 28 29 # Call the run_discharge_step_cycle and verify that an exception was raised 30 with pytest.raises(ValueError): 31 bms_hardware.run_discharge_step_cycle() 32 33 34def test_discharge_step_no_sample_interval(): 35 """Testing the case where the sample interval is not set.""" 36 # set and verify the other variables used by the run_discharge_step_cycle 37 bms_hardware.current = 1.2 # This is the case we're testing 38 assert bms_hardware.current == 1.2 # Verify the value 39 40 bms_hardware.sample_interval = 0 # Set to some value 41 assert bms_hardware.sample_interval == 0 # Verify the value 42 43 bms_hardware.uv_protection = 2.4 # set to some value 44 assert bms_hardware.uv_protection == 2.4 # Verify the value 45 46 bms_hardware.total_ah = 50 # set to some value 47 assert bms_hardware.total_ah == 50 # Verify the value 48 49 # Call the run_discharge_step_cycle and verify that an exception was raised 50 with pytest.raises(ValueError): 51 bms_hardware.run_discharge_step_cycle() 52 53 54def test_discharge_step_no_uv_protection(): 55 """Testing the case where the under-voltage protection is not set.""" 56 # set and verify the other variables used by the run_discharge_step_cycle 57 bms_hardware.current = 1.2 # This is the case we're testing 58 assert bms_hardware.current == 1.2 # Verify the value 59 60 bms_hardware.sample_interval = 500 # Set to some value 61 assert bms_hardware.sample_interval == 500 # Verify the value 62 63 bms_hardware.uv_protection = 0 # set to some value 64 assert bms_hardware.uv_protection == 0 # Verify the value 65 66 bms_hardware.total_ah = 50 # set to some value 67 assert bms_hardware.total_ah == 50 # Verify the value 68 69 # Call the run_discharge_step_cycle and verify that an exception was raised 70 with pytest.raises(ValueError): 71 bms_hardware.run_discharge_step_cycle() 72 73 74def test_discharge_step_no_final_capacity(): 75 """Testing the case where the final capacity is not set.""" 76 # set and verify the other variables used by the run_discharge_step_cycle 77 bms_hardware.current = 1.2 # This is the case we're testing 78 assert bms_hardware.current == 1.2 # Verify the value 79 80 bms_hardware.sample_interval = 500 # Set to some value 81 assert bms_hardware.sample_interval == 500 # Verify the value 82 83 bms_hardware.uv_protection = 2.4 # set to some value 84 assert bms_hardware.uv_protection == 2.4 # Verify the value 85 86 bms_hardware.total_ah = 0 # set to some value 87 assert bms_hardware.total_ah == 0 # Verify the value 88 89 # Call the run_discharge_step_cycle and verify that an exception was raised 90 with pytest.raises(ValueError): 91 bms_hardware.run_discharge_step_cycle() 92 93 94def test_discharge_step_function_completes(): 95 """Testing the case where the function works.""" 96 # set and verify the other variables used by the run_discharge_step_cycle 97 bms_hardware.current = 1.2 # This is the case we're testing 98 assert bms_hardware.current == 1.2 # Verify the value 99 100 bms_hardware.sample_interval = 500 # Set to some value 101 assert bms_hardware.sample_interval == 500 # Verify the value 102 103 bms_hardware.uv_protection = 2.4 # set to some value 104 assert bms_hardware.uv_protection == 2.4 # Verify the value 105 106 bms_hardware.total_ah = 50 # set to some value 107 assert bms_hardware.total_ah == 50 # Verify the value 108 109 # Call the run_discharge_step_cycle and verify that no exception was raised 110 bms_hardware.run_discharge_step_cycle()
bms_hardware =
<hitl_tester.modules.bms.bms_hw.BMSHardware object>
def
test_discharge_step_no_current():
15def test_discharge_step_no_current(): 16 """Testing the case where the discharge current is not set.""" 17 # set and verify the other variables used by the run_discharge_step_cycle 18 bms_hardware.current = 0 # This is the case we're testing 19 assert bms_hardware.current == 0 # Verify the value 20 21 bms_hardware.sample_interval = 500 # Set to some value 22 assert bms_hardware.sample_interval == 500 # Verify the value 23 24 bms_hardware.uv_protection = 2.4 # set to some value 25 assert bms_hardware.uv_protection == 2.4 # Verify the value 26 27 bms_hardware.total_ah = 50 # set to some value 28 assert bms_hardware.total_ah == 50 # Verify the value 29 30 # Call the run_discharge_step_cycle and verify that an exception was raised 31 with pytest.raises(ValueError): 32 bms_hardware.run_discharge_step_cycle()
Testing the case where the discharge current is not set.
def
test_discharge_step_no_sample_interval():
35def test_discharge_step_no_sample_interval(): 36 """Testing the case where the sample interval is not set.""" 37 # set and verify the other variables used by the run_discharge_step_cycle 38 bms_hardware.current = 1.2 # This is the case we're testing 39 assert bms_hardware.current == 1.2 # Verify the value 40 41 bms_hardware.sample_interval = 0 # Set to some value 42 assert bms_hardware.sample_interval == 0 # Verify the value 43 44 bms_hardware.uv_protection = 2.4 # set to some value 45 assert bms_hardware.uv_protection == 2.4 # Verify the value 46 47 bms_hardware.total_ah = 50 # set to some value 48 assert bms_hardware.total_ah == 50 # Verify the value 49 50 # Call the run_discharge_step_cycle and verify that an exception was raised 51 with pytest.raises(ValueError): 52 bms_hardware.run_discharge_step_cycle()
Testing the case where the sample interval is not set.
def
test_discharge_step_no_uv_protection():
55def test_discharge_step_no_uv_protection(): 56 """Testing the case where the under-voltage protection is not set.""" 57 # set and verify the other variables used by the run_discharge_step_cycle 58 bms_hardware.current = 1.2 # This is the case we're testing 59 assert bms_hardware.current == 1.2 # Verify the value 60 61 bms_hardware.sample_interval = 500 # Set to some value 62 assert bms_hardware.sample_interval == 500 # Verify the value 63 64 bms_hardware.uv_protection = 0 # set to some value 65 assert bms_hardware.uv_protection == 0 # Verify the value 66 67 bms_hardware.total_ah = 50 # set to some value 68 assert bms_hardware.total_ah == 50 # Verify the value 69 70 # Call the run_discharge_step_cycle and verify that an exception was raised 71 with pytest.raises(ValueError): 72 bms_hardware.run_discharge_step_cycle()
Testing the case where the under-voltage protection is not set.
def
test_discharge_step_no_final_capacity():
75def test_discharge_step_no_final_capacity(): 76 """Testing the case where the final capacity is not set.""" 77 # set and verify the other variables used by the run_discharge_step_cycle 78 bms_hardware.current = 1.2 # This is the case we're testing 79 assert bms_hardware.current == 1.2 # Verify the value 80 81 bms_hardware.sample_interval = 500 # Set to some value 82 assert bms_hardware.sample_interval == 500 # Verify the value 83 84 bms_hardware.uv_protection = 2.4 # set to some value 85 assert bms_hardware.uv_protection == 2.4 # Verify the value 86 87 bms_hardware.total_ah = 0 # set to some value 88 assert bms_hardware.total_ah == 0 # Verify the value 89 90 # Call the run_discharge_step_cycle and verify that an exception was raised 91 with pytest.raises(ValueError): 92 bms_hardware.run_discharge_step_cycle()
Testing the case where the final capacity is not set.
def
test_discharge_step_function_completes():
95def test_discharge_step_function_completes(): 96 """Testing the case where the function works.""" 97 # set and verify the other variables used by the run_discharge_step_cycle 98 bms_hardware.current = 1.2 # This is the case we're testing 99 assert bms_hardware.current == 1.2 # Verify the value 100 101 bms_hardware.sample_interval = 500 # Set to some value 102 assert bms_hardware.sample_interval == 500 # Verify the value 103 104 bms_hardware.uv_protection = 2.4 # set to some value 105 assert bms_hardware.uv_protection == 2.4 # Verify the value 106 107 bms_hardware.total_ah = 50 # set to some value 108 assert bms_hardware.total_ah == 50 # Verify the value 109 110 # Call the run_discharge_step_cycle and verify that no exception was raised 111 bms_hardware.run_discharge_step_cycle()
Testing the case where the function works.