def test_electrical_calc_impedance_amp_power(): test_obj_a = eb.Amp(10, 'A', 50, 'Hz') test_obj_b = eb.Power(complex(100, 100), 'W', 50, 'Hz') test_obj_c = eb.ElectricalCalc(test_obj_b, test_obj_a) current_obj = test_obj_c.calc_impedance() result = ((1 + 1j), 'Ohms (W/A^2)') assert (current_obj.ohm, current_obj.ohm_unit) == result
def test_pwr__init__(): test_obj = eb.Power(complex(110, 10), 'VA', 50, 'hz') result = ((110 + 10j), 'VA', 50, 'hz') assert tuple([ test_obj.power, test_obj.power_unit, test_obj.frequency, test_obj.freq_unit ]) == result
def test_electrical_calc_current_power_volt(): test_obj_a = eb.Power(complex(1000, 2), 'W', 50, 'Hz') test_obj_b = eb.Volt(25, 'Ohms', 50, 'Hz') test_obj_c = eb.ElectricalCalc(test_obj_b, test_obj_a) current_obj = test_obj_c.calc_current() result = ((40 + 0.08j), 'Amps (W/Ohms)') assert (current_obj.amps, current_obj.amp_unit) == result
def test_electrical_calc_voltage_amp_power(): test_obj_a = eb.Amp(75, 'A', 50, 'Hz') test_obj_b = eb.Power(complex(75, 75), 'W', 50, 'Hz') test_obj_c = eb.ElectricalCalc(test_obj_b, test_obj_a) current_obj = test_obj_c.calc_voltage() result = ((1 + 1j), 'Volts (W/A)') assert (current_obj.volts, current_obj.volt_unit) == result
def test_pwr_s(): test_obj = eb.Power() test_obj.s = complex(0.3, 0.4) result = 0.5 assert test_obj.s == result
def test_pwr_q(): test_obj = eb.Power() test_obj.q = 1.5 result = 1.5 assert test_obj.q == result
def test_pwr_p(): test_obj = eb.Power() test_obj.p = 0.6 result = 0.6 assert test_obj.p == result
def test_pwr_freq_unit(): test_obj = eb.Power(freq_unit='Hz') result = 'Hz' assert test_obj.freq_unit == result
def test_pwr_freq(): test_obj = eb.Power(freq=50) result = 50 assert test_obj.frequency == result
def test_pwr__sub__obj(): test_obj_a = eb.Power(complex(150, 15), 'VA', 50, 'hz') test_obj_b = eb.Power(complex(50, 5), 'VA', 50, 'hz') result = (100 + 10j) test_obj_c = test_obj_a - test_obj_b assert test_obj_c.power == result
def test_pwr__add__obj(): test_obj_a = eb.Power(complex(100, 9), 'VA', 50, 'hz') test_obj_b = eb.Power(complex(50, 5), 'VA', 50, 'hz') result = (150 + 14j) test_obj_c = test_obj_a + test_obj_b assert test_obj_c.power == result
def test_pwr__truediv__int_float(): test_obj_a = eb.Power(complex(150, 30), 'VA', 50, 'hz') test_obj_b = 3 result = complex(50, 10) test_obj_c = test_obj_a / test_obj_b assert test_obj_c.power == result
def test_pwr__truediv__obj(): test_obj_a = eb.Power(complex(150, 50), 'VA', 50, 'hz') test_obj_b = eb.Power(complex(1, 1), 'VA', 50, 'hz') result = (100 - 50j) test_obj_c = test_obj_a / test_obj_b assert test_obj_c.power == result
def test_pwr__mul__complex(): test_obj_a = eb.Power(complex(20, 20), 'VA', 50, 'hz') test_obj_b = complex(3, 4) result = complex(-20, 140) test_obj_c = test_obj_a * test_obj_b assert test_obj_c.power == result
def test_pwr__mul__int_float(): test_obj_a = eb.Power(complex(20, 20), 'VA', 50, 'hz') test_obj_b = 3 result = complex(60, 60) test_obj_c = test_obj_a * test_obj_b assert test_obj_c.power == result
def test_pwr__mul__obj(): test_obj_a = eb.Power(complex(10, 20), 'VA', 50, 'hz') test_obj_b = eb.Power(complex(3, 4), 'VA', 50, 'hz') result = (-50 + 100j) test_obj_c = test_obj_a * test_obj_b assert test_obj_c.power == result
def test_pwr__sub__int_float(): test_obj_a = eb.Power(complex(150, 15), 'VA', 50, 'hz') test_obj_b = complex(20, 5) result = (130 + 10j) test_obj_c = test_obj_a - test_obj_b assert test_obj_c.power == result
def test_pwr_scalar_unit(): test_obj = eb.Power() test_obj.power_unit = 'VA' result = 'VA' assert test_obj.power_unit == result
def test_pwr__truediv__complex(): test_obj_a = eb.Power(complex(150, 50), 'VA', 50, 'hz') test_obj_b = complex(2, 2) result = complex(50, -25) test_obj_c = test_obj_a / test_obj_b assert test_obj_c.power == result
def test_pwr__add__complex(): test_obj_a = eb.Power(complex(10.5, 0.5), 'VA', 50, 'hz') test_obj_b = complex(1.5, 1.5) result = (12 + 2j) test_obj_c = test_obj_a + test_obj_b assert test_obj_c.power == result