def test_electrical_calc_current_volt_volt(): test_obj_a = eb.Volt(10, 'V', 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_current() result = None assert power_obj == result
def test_electrical_calc_current_volts_ohms(): test_obj_a = eb.Volt(1000, 'V', 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_current() result = ((250 - 250j), 'Amps (V/Ohms)') assert (current_obj.amps, current_obj.amp_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_power_volts_ohms(): test_obj_a = eb.Volt(110, 'V', 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 = ((3025 - 3025j), 'V^2/Ohms') assert (power_obj.power, power_obj.power_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_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_volt_freq(): test_obj = eb.Volt(freq=40) result = 40 assert test_obj.frequency == result
def test_volt__mul__int_float(): test_obj_a = eb.Volt(120, 'volts', 50, 'hz') test_obj_b = 3 result = 360 test_obj_c = test_obj_a * test_obj_b assert test_obj_c.volts == result
def test_volt__sub__int_float(): test_obj_a = eb.Volt(240, 'v', 50, 'hz') test_obj_b = 60 result = 180 test_obj_c = test_obj_a - test_obj_b assert test_obj_c.volts == 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_volt__add__obj(): test_obj_a = eb.Volt(240, 'v', 50, 'hz') test_obj_b = eb.Volt(240, 'v', 50, 'hz') result = 480 test_obj_c = test_obj_a + test_obj_b assert test_obj_c.volts == result
def test_volt__init__(): test_obj = eb.Volt(550, 'V', 40, 'hz') result = (550, 'V', 40, 'hz') assert tuple([ test_obj._volt, test_obj._volt_unit, test_obj._freq, test_obj.freq_unit ]) == result
def test_volt_scalar(): test_obj = eb.Volt() 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_volt_freq_unit(): test_obj = eb.Volt(freq_unit='Hz') result = 'Hz' assert test_obj.freq_unit == result
def test_volt__sub__obj(): test_obj_a = eb.Volt(240, 'v', 50, 'hz') test_obj_b = eb.Volt(240, 'v', 50, 'hz') result = 0 test_obj_c = test_obj_a - test_obj_b assert test_obj_c.volts == 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_volt__mul__obj(): test_obj_a = eb.Volt(10, 'volts', 50, 'hz') test_obj_b = eb.Volt(24, 'volts', 50, 'hz') result = 240 test_obj_c = test_obj_a * test_obj_b assert test_obj_c.volts == result
def test_volt__add__int_float(): test_obj_a = eb.Volt(240, 'v', 50, 'hz') test_obj_b = 60 result = 300 test_obj_c = test_obj_a + test_obj_b assert test_obj_c.volts == result
def test_volt__truediv__obj(): test_obj_a = eb.Volt(240, 'volts', 50, 'hz') test_obj_b = eb.Volt(10, 'volts', 50, 'hz') result = 24 test_obj_c = test_obj_a / test_obj_b assert test_obj_c.volts == result
def test_volt__truediv__int_float(): test_obj_a = eb.Volt(360, 'volts', 50, 'hz') test_obj_b = 3 result = 120 test_obj_c = test_obj_a / test_obj_b assert test_obj_c.volts == result