Пример #1
0
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
Пример #2
0
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
Пример #3
0
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
Пример #4
0
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
Пример #5
0
def test_pwr_s():
    test_obj = eb.Power()
    test_obj.s = complex(0.3, 0.4)
    result = 0.5
    assert test_obj.s == result
Пример #6
0
def test_pwr_q():
    test_obj = eb.Power()
    test_obj.q = 1.5
    result = 1.5
    assert test_obj.q == result
Пример #7
0
def test_pwr_p():
    test_obj = eb.Power()
    test_obj.p = 0.6
    result = 0.6
    assert test_obj.p == result
Пример #8
0
def test_pwr_freq_unit():
    test_obj = eb.Power(freq_unit='Hz')
    result = 'Hz'
    assert test_obj.freq_unit == result
Пример #9
0
def test_pwr_freq():
    test_obj = eb.Power(freq=50)
    result = 50
    assert test_obj.frequency == result
Пример #10
0
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
Пример #11
0
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
Пример #12
0
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
Пример #13
0
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
Пример #14
0
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
Пример #15
0
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
Пример #16
0
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
Пример #17
0
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
Пример #18
0
def test_pwr_scalar_unit():
    test_obj = eb.Power()
    test_obj.power_unit = 'VA'
    result = 'VA'
    assert test_obj.power_unit == result
Пример #19
0
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
Пример #20
0
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