def test_electrical_calc_power_volt_amp(): test_obj_a = eb.Amp(10, 'A', 50, 'Hz') test_obj_b = eb.Amp(240, 'A', 50, 'Hz') test_obj_c = eb.ElectricalCalc(test_obj_b, test_obj_a) power_obj = test_obj_c.calc_power() result = None assert power_obj == 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_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_electrical_calc_impedance_volt_amp(): test_obj_a = eb.Amp(110, 'A', 50, 'Hz') test_obj_b = eb.Volt(110, 'V', 50, 'Hz') test_obj_c = eb.ElectricalCalc(test_obj_b, test_obj_a) current_obj = test_obj_c.calc_impedance() result = (1.0, 'Ohms (V/A)') assert (current_obj.ohm, current_obj.ohm_unit) == result
def test_electrical_calc_power_amp_ohms(): test_obj_a = eb.Amp(10, 'A', 50, 'Hz') test_obj_b = eb.Ohm(complex(2, 2), 'Ohms', 50, 'Hz') test_obj_c = eb.ElectricalCalc(test_obj_b, test_obj_a) power_obj = test_obj_c.calc_power() result = ((200 + 200j), 'A^2*Ohms') assert (power_obj.power, power_obj.power_unit) == result
def test_electrical_calc_power_volt_amp(): test_obj_a = eb.Amp(10, 'A', 50, 'Hz') test_obj_b = eb.Volt(240, 'V', 50, 'Hz') test_obj_c = eb.ElectricalCalc(test_obj_b, test_obj_a) power_obj = test_obj_c.calc_power() result = (2400, 'V*A') assert (power_obj.power, power_obj.power_unit) == result
def test_electrical_calc_voltage_amp_ohms(): test_obj_a = eb.Amp(100, 'A', 50, 'Hz') test_obj_b = eb.Ohm(complex(2, 2), 'Ohms', 50, 'Hz') test_obj_c = eb.ElectricalCalc(test_obj_b, test_obj_a) current_obj = test_obj_c.calc_voltage() result = ((200 + 200j), 'Volts (A*Ohms)') assert (current_obj.volts, current_obj.volt_unit) == result
def test_amp__add__obj(): test_obj_a = eb.Amp(0.3, 'amps', 50, 'hz') test_obj_b = eb.Amp(0.7, 'amps', 50, 'hz') result = 1 test_obj_c = test_obj_a + test_obj_b assert test_obj_c.amps == result
def test_amp__add__int_float(): test_obj_a = eb.Amp(1.3, 'amps', 50, 'hz') test_obj_b = 0.7 result = 2 test_obj_c = test_obj_a + test_obj_b assert test_obj_c.amps == result
def test_electrical_calc_compare_bases(): test_obj_a = eb.Amp(10, 'A', 50, 'Hz') test_obj_b = eb.Volt(240, 'V', 50, 'Hz') test_obj_c = eb.ElectricalCalc(test_obj_a, test_obj_b) result = True assert test_obj_c._freq_equal == result
def test_electrical_calc_determine_same_obj(): test_obj_a = eb.Amp() test_obj_b = eb.Amp() test_obj_c = eb.ElectricalCalc(test_obj_a, test_obj_b) result = False assert test_obj_c._amp_exists == result
def test_electrical_calc_determine_diff_obj(): test_obj_a = eb.Amp() test_obj_b = eb.Volt() test_obj_c = eb.ElectricalCalc(test_obj_a, test_obj_b) result = True assert test_obj_c._amp_exists == result
def test_electrical_calc__init__(): test_obj_a = eb.Amp() test_obj_b = eb.Volt() test_obj_c = eb.ElectricalCalc(test_obj_a, test_obj_b) result = False assert test_obj_c._ohm_exists == result
def test_amp__sub__int_float(): test_obj_a = eb.Amp(1.3, 'amps', 50, 'hz') test_obj_b = 0.3 result = 1 test_obj_c = test_obj_a - test_obj_b assert test_obj_c.amps == result
def test_amp_freq(): test_obj = eb.Amp(freq=40) result = 40 assert test_obj.frequency == result
def test_amp_scalar_unit(): test_obj = eb.Amp() test_obj.amp_unit = 'A' result = 'A' assert test_obj.amp_unit == result
def test_amp__truediv__int_float(): test_obj_a = eb.Amp(240.0, 'amps', 50, 'hz') test_obj_b = 6 result = 40 test_obj_c = test_obj_a / test_obj_b assert test_obj_c.amps == result
def test_truediv__mul__obj(): test_obj_a = eb.Amp(4, 'amps', 50, 'hz') test_obj_b = eb.Amp(2, 'amps', 50, 'hz') result = 2 test_obj_c = test_obj_a / test_obj_b assert test_obj_c.amps == result
def test_amp__mul__int_float(): test_obj_a = eb.Amp(60.0, 'amps', 50, 'hz') test_obj_b = 4 result = 240 test_obj_c = test_obj_a * test_obj_b assert test_obj_c.amps == result
def test_amp__mul__obj(): test_obj_a = eb.Amp(2, 'amps', 50, 'hz') test_obj_b = eb.Amp(4, 'amps', 50, 'hz') result = 8 test_obj_c = test_obj_a * test_obj_b assert test_obj_c.amps == result
def test_amp_freq_unit(): test_obj = eb.Amp(freq_unit='Hz') result = 'Hz' assert test_obj.freq_unit == result
def test_amp__sub__obj(): test_obj_a = eb.Amp(3, 'amps', 50, 'hz') test_obj_b = eb.Amp(7, 'amps', 50, 'hz') result = -4 test_obj_c = test_obj_a - test_obj_b assert test_obj_c.amps == result
def test_amp_scalar(): test_obj = eb.Amp() test_obj.magnitude = 275 test_obj.scalar_unit = 'Turns per inch' result = (275, 'Turns per inch') assert tuple([test_obj.magnitude, test_obj.scalar_unit]) == result
def test_amp__init__(): test_obj = eb.Amp(10, 'A', 40, 'A') result = (10, 'A', 40, 'A') assert tuple([ test_obj._amp, test_obj._amp_unit, test_obj._freq, test_obj.freq_unit ]) == result