From aca91a33a234f592bcb3a9c372a82776e83122eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8Anio=20Viana?= Date: Tue, 19 Jul 2022 20:07:08 -0300 Subject: [PATCH 1/4] Removing Paulo's personal folder --- src/py_dss_interface/DSS.py | 4 ++-- tests/py_dss_interface/conftest.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/py_dss_interface/DSS.py b/src/py_dss_interface/DSS.py index dc7213ee..7d25f86d 100644 --- a/src/py_dss_interface/DSS.py +++ b/src/py_dss_interface/DSS.py @@ -61,8 +61,8 @@ def __init__(self, dll_folder_param=None, dll_by_user=None): self._allocate_memory() if self.check_started(): - print( - "OpenDSS Started successfully! \nOpenDSS {}\n\n".format(self.my_dss_version.value.decode('ascii'))) + print(f"OpenDSS Started successfully! \nOpenDSS {self.my_dss_version.value.decode('ascii')}\n\n") + else: print("OpenDSS Failed to Start") exit() diff --git a/tests/py_dss_interface/conftest.py b/tests/py_dss_interface/conftest.py index e923d560..d250d7a5 100644 --- a/tests/py_dss_interface/conftest.py +++ b/tests/py_dss_interface/conftest.py @@ -16,7 +16,7 @@ @pytest.fixture(scope='function') def solve_snap_13bus(): - dss = py_dss_interface.DSSDLL(r"C:\OpenDSS_rep\Version8\Source") + dss = py_dss_interface.DSSDLL() actual = dss.started expected = True From 810399b8d73fa717c20666cf4d5bc476012b627c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8Anio=20Viana?= Date: Tue, 19 Jul 2022 23:16:29 -0300 Subject: [PATCH 2/4] Adding more python versions to test --- setup.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/setup.py b/setup.py index 545f6145..d7573fd0 100644 --- a/setup.py +++ b/setup.py @@ -57,6 +57,8 @@ def read(*names, **kwargs): 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: Implementation :: CPython', 'Programming Language :: Python :: Implementation :: PyPy', 'Topic :: Utilities', From 918ff14dc2fc68ae89a2b2f8cf68d45470210876 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8Anio=20Viana?= Date: Tue, 19 Jul 2022 23:36:27 -0300 Subject: [PATCH 3/4] Refactoring tests --- tests/py_dss_interface/conftest.py | 11 +- tests/py_dss_interface/test_activeclass.py | 2 +- tests/py_dss_interface/test_cktelement.py | 2 +- tests/py_dss_interface/test_cmathlib.py | 3 +- tests/py_dss_interface/test_dssinterface.py | 9 +- tests/py_dss_interface/test_generators.py | 3 +- tests/py_dss_interface/test_lines.py | 41 +++-- tests/py_dss_interface/test_load.py | 41 +++-- tests/py_dss_interface/test_loadshapes.py | 13 +- tests/py_dss_interface/test_monitors.py | 7 +- tests/py_dss_interface/test_parallel.py | 2 +- tests/py_dss_interface/test_pvsystems.py | 89 +++++---- tests/py_dss_interface/test_reclosers.py | 192 ++++++++++---------- tests/py_dss_interface/test_relays.py | 16 +- tests/py_dss_interface/test_sensors.py | 32 ++-- tests/py_dss_interface/test_solution.py | 33 ++-- tests/py_dss_interface/test_swtcontrols.py | 1 + tests/py_dss_interface/test_topology.py | 2 +- tests/py_dss_interface/test_transformers.py | 2 +- tests/py_dss_interface/test_vsources.py | 1 + tests/py_dss_interface/utils.py | 1 - 21 files changed, 258 insertions(+), 245 deletions(-) diff --git a/tests/py_dss_interface/conftest.py b/tests/py_dss_interface/conftest.py index d250d7a5..91e1615c 100644 --- a/tests/py_dss_interface/conftest.py +++ b/tests/py_dss_interface/conftest.py @@ -5,11 +5,12 @@ # @File : conftest.py # @Software: PyCharm -import pytest -import pathlib import os +import pathlib + +import pytest + import py_dss_interface -import time script_path = os.path.dirname(os.path.abspath(__file__)) @@ -18,9 +19,9 @@ def solve_snap_13bus(): dss = py_dss_interface.DSSDLL() actual = dss.started - expected = True + # expected = True - message = f"OpenDSSDirectDLL has been loaded: {actual}" + # message = f"OpenDSSDirectDLL has been loaded: {actual}" # assert actual is expected, message diff --git a/tests/py_dss_interface/test_activeclass.py b/tests/py_dss_interface/test_activeclass.py index 003f2adc..2e3ed5c7 100644 --- a/tests/py_dss_interface/test_activeclass.py +++ b/tests/py_dss_interface/test_activeclass.py @@ -55,7 +55,7 @@ def test_active_class_get_name(self, dss): def test_active_class_write_name(self, dss): expected = '645646' - actual = dss.active_class_write_name(expected) + dss.active_class_write_name(expected) actual = dss.active_class_get_name() assert actual == expected diff --git a/tests/py_dss_interface/test_cktelement.py b/tests/py_dss_interface/test_cktelement.py index 4111f207..ba136109 100644 --- a/tests/py_dss_interface/test_cktelement.py +++ b/tests/py_dss_interface/test_cktelement.py @@ -170,7 +170,7 @@ def test_cktelement_energymeter(self, dss): def test_cktelement_controller(self, dss): # https://github.com/PauloRadatz/py_dss_interface/issues/2 - Issue solved =) dss.text("New 'Fuse.f1' MonitoredObj=Line.650632 MonitoredTerm=1 FuseCurve=Klink RatedCurrent=65") - # After include a new element it become the active element. So, we need activate another element to test the + # After include a new element it becomes the active element. So, we need activate another element to test the # methods below dss.circuit_set_active_element('Line.650632') expected = "Fuse.f1" diff --git a/tests/py_dss_interface/test_cmathlib.py b/tests/py_dss_interface/test_cmathlib.py index 2310838d..bab70ce2 100644 --- a/tests/py_dss_interface/test_cmathlib.py +++ b/tests/py_dss_interface/test_cmathlib.py @@ -26,7 +26,6 @@ def test_cmathlib_cabs(self, dss): assert actual == expected def test_cmathlib_cdang(self, dss): - real, imag = 1, 1 expected = 45 actual = dss.cmathlib_cdang(1, 1) assert actual == expected @@ -50,3 +49,5 @@ def test_cmathlib_pdegtocomplex(self, dss): real, imag = 3.1622776601683795, 1.2490457723982544 actual = dss.cmathlib_pdegtocomplex(real, imag) expected = complex(real, imag) + assert actual == expected + diff --git a/tests/py_dss_interface/test_dssinterface.py b/tests/py_dss_interface/test_dssinterface.py index 33a242a3..39d699e6 100644 --- a/tests/py_dss_interface/test_dssinterface.py +++ b/tests/py_dss_interface/test_dssinterface.py @@ -6,10 +6,11 @@ # @Software: PyCharm -import pytest import os import pathlib +import pytest + class TestDSSInterface13Bus: @@ -84,14 +85,16 @@ def test_dss_write_allow_forms(self, dss): def test_dss_read_datapath(self, dss): expected = r"C:\\PauloRadatz\\GitHub\\py-dss-interface\\tests\\py_dss_interface\\cases\\13Bus\\" actual = dss.dss_read_datapath() - assert actual.replace("\\", "").split("py-dss-interfacetests")[1] == expected.replace("\\", "").split("py-dss-interfacetests")[1] + assert actual.replace("\\", "").split("py-dss-interfacetests")[1] == \ + expected.replace("\\", "").split("py-dss-interfacetests")[1] def test_dss_write_datapath(self, dss): data_path = str(pathlib.Path(os.path.dirname(__file__)).joinpath("cases", "13Bus", "datapath")) dss.dss_write_datapath(data_path) expected = data_path actual = dss.dss_read_datapath() - assert actual.replace("\\", "").split("py-dss-interfacetests")[1] == expected.replace("\\", "").split("py-dss-interfacetests")[1] + assert actual.replace("\\", "").split("py-dss-interfacetests")[1] == \ + expected.replace("\\", "").split("py-dss-interfacetests")[1] def test_dss_default_editor(self, dss): expected = 'Notepad.exe' diff --git a/tests/py_dss_interface/test_generators.py b/tests/py_dss_interface/test_generators.py index 21ff0001..855df70b 100644 --- a/tests/py_dss_interface/test_generators.py +++ b/tests/py_dss_interface/test_generators.py @@ -20,7 +20,8 @@ def dss(self, solve_snap_13bus): return dss - def include_generator(self, dss): + @staticmethod + def include_generator(dss): dss.text( 'New Generator.G2 Bus1=645.1 phases=1 kV=2.4 kW=100 Model=3 Vpu=1 Maxkvar=500 Minkvar=-400' ) diff --git a/tests/py_dss_interface/test_lines.py b/tests/py_dss_interface/test_lines.py index 7bbef0d1..7cad88cd 100644 --- a/tests/py_dss_interface/test_lines.py +++ b/tests/py_dss_interface/test_lines.py @@ -123,11 +123,12 @@ def test_lines_read_geometry(self, dss): def test_lines_write_geometry(self, dss): dss.text( - "New WireData.1/0_ACSR Rac=0.646847 Runits=km GMRac=0.13589 GMRUnits=cm Radius=0.50546 Radunits=cm Normamps=260 Emergamps=260") + "New WireData.1/0_ACSR Rac=0.646847 Runits=km GMRac=0.13589 GMRUnits=cm Radius=0.50546 Radunits=cm " + "Normamps=260 Emergamps=260") dss.text("New LineGeometry.1PH-x4_ACSRx4_ACSR nconds=2 nphases=1 " - " cond=1 wire=1/0_ACSR x=-0.1524 h=10.5156 units=m " - " cond=2 wire=1/0_ACSR x=0.1524 h=8.2296 units=m " - " reduce=y ") + " cond=1 wire=1/0_ACSR x=-0.1524 h=10.5156 units=m " + " cond=2 wire=1/0_ACSR x=0.1524 h=8.2296 units=m " + " reduce=y ") expected = '1PH-x4_ACSRx4_ACSR'.lower() dss.lines_write_geometry(expected) @@ -163,10 +164,10 @@ def test_lines_write_length(self, dss): def test_lines_read_r1(self, dss): dss.text("New linecode.Sequences nphases=3 " - "r1=0.3489 x1=0.426198 r0=0.588811 x0=1.29612 " - "c1=10.4308823411236 c0=4.48501282215346 " - "units=km baseFreq=60 normamps=310 emergamps=310 " - "faultrate=0.1 pctperm=20 repair=3") + "r1=0.3489 x1=0.426198 r0=0.588811 x0=1.29612 " + "c1=10.4308823411236 c0=4.48501282215346 " + "units=km baseFreq=60 normamps=310 emergamps=310 " + "faultrate=0.1 pctperm=20 repair=3") dss.text("New line.MyLine linecode=Sequences length=1") dss.lines_write_name('MyLine') @@ -177,10 +178,10 @@ def test_lines_read_r1(self, dss): def test_lines_write_r1(self, dss): dss.text("New linecode.Sequences nphases=3 " - "r1=0.3489 x1=0.426198 r0=0.588811 x0=1.29612 " - "c1=10.4308823411236 c0=4.48501282215346 " - "units=km baseFreq=60 normamps=310 emergamps=310 " - "faultrate=0.1 pctperm=20 repair=3") + "r1=0.3489 x1=0.426198 r0=0.588811 x0=1.29612 " + "c1=10.4308823411236 c0=4.48501282215346 " + "units=km baseFreq=60 normamps=310 emergamps=310 " + "faultrate=0.1 pctperm=20 repair=3") dss.text("New line.MyLine linecode=Sequences length=1") dss.lines_write_name('MyLine') @@ -192,10 +193,10 @@ def test_lines_write_r1(self, dss): def test_lines_read_x1(self, dss): dss.text("New linecode.Sequences nphases=3 " - "r1=0.3489 x1=0.426198 r0=0.588811 x0=1.29612 " - "c1=10.4308823411236 c0=4.48501282215346 " - "units=km baseFreq=60 normamps=310 emergamps=310 " - "faultrate=0.1 pctperm=20 repair=3") + "r1=0.3489 x1=0.426198 r0=0.588811 x0=1.29612 " + "c1=10.4308823411236 c0=4.48501282215346 " + "units=km baseFreq=60 normamps=310 emergamps=310 " + "faultrate=0.1 pctperm=20 repair=3") dss.text("New line.MyLine linecode=Sequences length=1") dss.lines_write_name('MyLine') @@ -206,10 +207,10 @@ def test_lines_read_x1(self, dss): def test_lines_write_x1(self, dss): dss.text("New linecode.Sequences nphases=3 " - "r1=0.3489 x1=0.426198 r0=0.588811 x0=1.29612 " - "c1=10.4308823411236 c0=4.48501282215346 " - "units=km baseFreq=60 normamps=310 emergamps=310 " - "faultrate=0.1 pctperm=20 repair=3") + "r1=0.3489 x1=0.426198 r0=0.588811 x0=1.29612 " + "c1=10.4308823411236 c0=4.48501282215346 " + "units=km baseFreq=60 normamps=310 emergamps=310 " + "faultrate=0.1 pctperm=20 repair=3") dss.text("New line.MyLine linecode=Sequences length=1") dss.lines_write_name('MyLine') diff --git a/tests/py_dss_interface/test_load.py b/tests/py_dss_interface/test_load.py index 11f4c02d..f9b29e1c 100644 --- a/tests/py_dss_interface/test_load.py +++ b/tests/py_dss_interface/test_load.py @@ -5,9 +5,10 @@ # @File : test_load.py # @Software: PyCharm -import pytest import platform +import pytest + class TestLoad13Bus: @@ -123,11 +124,11 @@ def test_loads_read_cvr_curve(self, dss): def test_loads_write_cvr_curve(self, dss): dss.text("New Loadshape.Test npts=24 interval=1 " - "mult= " - "(0.18000001 0.19000000 0.23999999 0.33000001 0.38999999 0.41000000 " - "0.64999998 1.23000002 1.88999999 1.88999999 1.96000004 1.98000002 " - "1.45000005 1.62000000 1.88999999 1.79999995 1.78999996 1.19000006 " - "0.80000001 0.66000003 0.51999998 0.40000001 0.28000000 0.23000000)") + "mult= " + "(0.18000001 0.19000000 0.23999999 0.33000001 0.38999999 0.41000000 " + "0.64999998 1.23000002 1.88999999 1.88999999 1.96000004 1.98000002 " + "1.45000005 1.62000000 1.88999999 1.79999995 1.78999996 1.19000006 " + "0.80000001 0.66000003 0.51999998 0.40000001 0.28000000 0.23000000)") expected = 'Test' dss.loads_write_cvr_curve(expected) actual = dss.loads_read_cvr_curve() @@ -140,11 +141,11 @@ def test_loads_read_daily(self, dss): def test_loads_write_daily(self, dss): dss.text("New Loadshape.Test npts=24 interval=1 " - "mult= " - "(0.18000001 0.19000000 0.23999999 0.33000001 0.38999999 0.41000000 " - "0.64999998 1.23000002 1.88999999 1.88999999 1.96000004 1.98000002 " - "1.45000005 1.62000000 1.88999999 1.79999995 1.78999996 1.19000006 " - "0.80000001 0.66000003 0.51999998 0.40000001 0.28000000 0.23000000)") + "mult= " + "(0.18000001 0.19000000 0.23999999 0.33000001 0.38999999 0.41000000 " + "0.64999998 1.23000002 1.88999999 1.88999999 1.96000004 1.98000002 " + "1.45000005 1.62000000 1.88999999 1.79999995 1.78999996 1.19000006 " + "0.80000001 0.66000003 0.51999998 0.40000001 0.28000000 0.23000000)") expected = 'Test' dss.loads_write_daily(expected) actual = dss.loads_read_daily() @@ -162,10 +163,10 @@ def test_loads_read_spectrum(self, dss): def test_loads_write_spectrum(self, dss): dss.text("New Spectrum.Test " - "NumHarm=7 " - "harmonic=(1, 3, 5, 7, 9, 11, 13, ) " - "%mag=(100, 1.5, 20, 14, 1, 9, 7, ) " - "angle=(0, 180, 180, 180, 180, 180, 180, )") + "NumHarm=7 " + "harmonic=(1, 3, 5, 7, 9, 11, 13, ) " + "%mag=(100, 1.5, 20, 14, 1, 9, 7, ) " + "angle=(0, 180, 180, 180, 180, 180, 180, )") expected = 'Test' dss.loads_write_spectrum(expected) actual = dss.loads_read_spectrum() @@ -178,11 +179,11 @@ def test_loads_read_yearly(self, dss): def test_loads_write_yearly(self, dss): dss.text("New Loadshape.Test npts=24 interval=1 " - "mult= " - "(0.18000001 0.19000000 0.23999999 0.33000001 0.38999999 0.41000000 " - "0.64999998 1.23000002 1.88999999 1.88999999 1.96000004 1.98000002 " - "1.45000005 1.62000000 1.88999999 1.79999995 1.78999996 1.19000006 " - "0.80000001 0.66000003 0.51999998 0.40000001 0.28000000 0.23000000)") + "mult= " + "(0.18000001 0.19000000 0.23999999 0.33000001 0.38999999 0.41000000 " + "0.64999998 1.23000002 1.88999999 1.88999999 1.96000004 1.98000002 " + "1.45000005 1.62000000 1.88999999 1.79999995 1.78999996 1.19000006 " + "0.80000001 0.66000003 0.51999998 0.40000001 0.28000000 0.23000000)") expected = 'Test' dss.loads_write_yearly(expected) actual = dss.loads_read_yearly() diff --git a/tests/py_dss_interface/test_loadshapes.py b/tests/py_dss_interface/test_loadshapes.py index 226177c4..511dfa9e 100644 --- a/tests/py_dss_interface/test_loadshapes.py +++ b/tests/py_dss_interface/test_loadshapes.py @@ -17,13 +17,14 @@ def dss(self, solve_snap_13bus): return dss - def new_loadshape(self, dss, activate: bool = False): + @staticmethod + def new_loadshape(dss, activate: bool = False): dss.text("New Loadshape.Test npts=24 interval=1 Pbase=100 Qbase=50 " - "mult= " - "(0.18000001 0.19000000 0.23999999 0.33000001 0.38999999 0.41000000 " - "0.64999998 1.23000002 1.88999999 1.88999999 1.96000004 1.98000002 " - "1.45000005 1.62000000 1.88999999 1.79999995 1.78999996 1.19000006 " - "0.80000001 0.66000003 0.51999998 0.40000001 0.28000000 0.23000000)") + "mult= " + "(0.18000001 0.19000000 0.23999999 0.33000001 0.38999999 0.41000000 " + "0.64999998 1.23000002 1.88999999 1.88999999 1.96000004 1.98000002 " + "1.45000005 1.62000000 1.88999999 1.79999995 1.78999996 1.19000006 " + "0.80000001 0.66000003 0.51999998 0.40000001 0.28000000 0.23000000)") if activate: dss.loadshapes_write_name('test') diff --git a/tests/py_dss_interface/test_monitors.py b/tests/py_dss_interface/test_monitors.py index e006d2c9..7b8fd21f 100644 --- a/tests/py_dss_interface/test_monitors.py +++ b/tests/py_dss_interface/test_monitors.py @@ -19,7 +19,10 @@ class TestMonitors13Bus: def dss(self, solve_snap_13bus): dss = solve_snap_13bus dss.text( - "New Loadshape.1 npts=24 interval=1 mult=(0.18000001 0.19000000 0.23999999 0.33000001 0.38999999 0.41000000 0.64999998 1.23000002 1.88999999 1.88999999 1.96000004 1.98000002 1.45000005 1.62000000 1.88999999 1.79999995 1.78999996 1.19000006 0.80000001 0.66000003 0.51999998 0.40000001 0.28000000 0.23000000)") + "New Loadshape.1 npts=24 interval=1 mult=(0.18000001 0.19000000 0.23999999 0.33000001 0.38999999 " + "0.41000000 0.64999998 1.23000002 1.88999999 1.88999999 1.96000004 1.98000002 1.45000005 1.62000000 " + "1.88999999 1.79999995 1.78999996 1.19000006 0.80000001 0.66000003 0.51999998 0.40000001 0.28000000 " + "0.23000000)") dss.loads_write_daily("1") dss.text("New monitor.m1 element=Transformer.XFM1 terminal=1 mode=0") dss.text(f"Set DataPath={path}") @@ -91,7 +94,7 @@ def test_monitors_process_all(self, dss): assert actual == expected def test_monitors_file_version(self, dss): - # TODO: file_version returns diferent values each time + # TODO: file_version returns different values each time expected = 0 actual = dss.monitors_file_version() assert type(actual) == type(expected) diff --git a/tests/py_dss_interface/test_parallel.py b/tests/py_dss_interface/test_parallel.py index 746ac1f6..e6406f18 100644 --- a/tests/py_dss_interface/test_parallel.py +++ b/tests/py_dss_interface/test_parallel.py @@ -21,7 +21,7 @@ def dss(self, solve_snap_13bus): def test_parallel_num_cpus(self, dss): expected = 4 actual = dss.parallel_num_cpus() - #assert actual == expected + # assert actual == expected def test_parallel_num_cores(self, dss): expected = 2 diff --git a/tests/py_dss_interface/test_pvsystems.py b/tests/py_dss_interface/test_pvsystems.py index 2710607a..246635a0 100644 --- a/tests/py_dss_interface/test_pvsystems.py +++ b/tests/py_dss_interface/test_pvsystems.py @@ -6,7 +6,6 @@ # @Software: PyCharm import pytest -import platform class TestPVSystems13Bus: @@ -18,17 +17,17 @@ def dss(self, solve_snap_13bus): dss.text(r"New XYCurve.MyPvsT npts=4 xarray=[0 25 75 100] yarray=[1 1 1 1]") dss.text(r"New XYCurve.MyEff npts=4 xarray=[.1 .2 .4 1.0] yarray=[1 1 1 1]") dss.text(r"New PVSystem.PV1 phases=3 " - r"bus1=680 " - r"kV=4.16 " - r"kVA=600 " - r"irrad=1 " - r"Pmpp=500 " - r"temperature=25 " - r"PF=1 " - r"%cutin=0.1 " - r"%cutout=0.1 " - r"effcurve=Myeff " - r"P-TCurve=MyPvsT") + r"bus1=680 " + r"kV=4.16 " + r"kVA=600 " + r"irrad=1 " + r"Pmpp=500 " + r"temperature=25 " + r"PF=1 " + r"%cutin=0.1 " + r"%cutout=0.1 " + r"effcurve=Myeff " + r"P-TCurve=MyPvsT") dss.solution_solve() dss.pvsystems_write_name('PV1') @@ -46,17 +45,17 @@ def test_pvsystems_first(self, dss): def test_pvsystems_next(self, dss): dss.text(r"New PVSystem.PV2 phases=3 " - r"bus1=680 " - r"kV=4.16 " - r"kVA=600 " - r"irrad=1 " - r"Pmpp=500 " - r"temperature=25 " - r"PF=1 " - r"%cutin=0.1 " - r"%cutout=0.1 " - r"effcurve=Myeff " - r"P-TCurve=MyPvsT") + r"bus1=680 " + r"kV=4.16 " + r"kVA=600 " + r"irrad=1 " + r"Pmpp=500 " + r"temperature=25 " + r"PF=1 " + r"%cutin=0.1 " + r"%cutout=0.1 " + r"effcurve=Myeff " + r"P-TCurve=MyPvsT") expected = 2 dss.pvsystems_first() actual = dss.pvsystems_next() @@ -141,17 +140,17 @@ def test_pvsystems_read_name(self, dss): def test_pvsystems_write_name(self, dss): dss.text(r"New PVSystem.PV2 phases=3 " - r"bus1=680 " - r"kV=4.16 " - r"kVA=600 " - r"irrad=1 " - r"Pmpp=500 " - r"temperature=25 " - r"PF=1 " - r"%cutin=0.1 " - r"%cutout=0.1 " - r"effcurve=Myeff " - r"P-TCurve=MyPvsT") + r"bus1=680 " + r"kV=4.16 " + r"kVA=600 " + r"irrad=1 " + r"Pmpp=500 " + r"temperature=25 " + r"PF=1 " + r"%cutin=0.1 " + r"%cutout=0.1 " + r"effcurve=Myeff " + r"P-TCurve=MyPvsT") expected = "pv2" dss.pvsystems_write_name(expected) actual = dss.pvsystems_read_name() @@ -159,17 +158,17 @@ def test_pvsystems_write_name(self, dss): def test_pvsystems_all_names(self, dss): dss.text(r"New PVSystem.PV2 phases=3 " - r"bus1=680 " - r"kV=4.16 " - r"kVA=600 " - r"irrad=1 " - r"Pmpp=500 " - r"temperature=25 " - r"PF=1 " - r"%cutin=0.1 " - r"%cutout=0.1 " - r"effcurve=Myeff " - r"P-TCurve=MyPvsT") + r"bus1=680 " + r"kV=4.16 " + r"kVA=600 " + r"irrad=1 " + r"Pmpp=500 " + r"temperature=25 " + r"PF=1 " + r"%cutin=0.1 " + r"%cutout=0.1 " + r"effcurve=Myeff " + r"P-TCurve=MyPvsT") expected = ["pv1", "pv2"] actual = dss.pvsystems_all_names() assert actual == expected diff --git a/tests/py_dss_interface/test_reclosers.py b/tests/py_dss_interface/test_reclosers.py index 6fd980ce..9db61262 100644 --- a/tests/py_dss_interface/test_reclosers.py +++ b/tests/py_dss_interface/test_reclosers.py @@ -14,22 +14,22 @@ class TestReclosers13Bus: def dss(self, solve_snap_13bus): dss = solve_snap_13bus dss.text(r"New Recloser.cb1 MonitoredObj=Line.650632 " - r"MonitoredTerm=1 " - r"NumFast=4 " - r"PhaseFast=Ext_Inv " - r"PhaseDelayed=Ext_Inv " - r"PhaseTrip=800 " - r"TDPhFast=1 " - r"TDPhDelayed=1 " - r"PhaseInst=2400 " - r"GroundFast=Ext_Inv " - r"GroundDelayed=Ext_Inv " - r"GroundTrip=800 " - r"TDGrFast=1 " - r"TDGrDelayed=1 " - r"GroundInst=1200 " - r"Shots=4 " - r"RecloseIntervals=(0.5, 2, 2, )") + r"MonitoredTerm=1 " + r"NumFast=4 " + r"PhaseFast=Ext_Inv " + r"PhaseDelayed=Ext_Inv " + r"PhaseTrip=800 " + r"TDPhFast=1 " + r"TDPhDelayed=1 " + r"PhaseInst=2400 " + r"GroundFast=Ext_Inv " + r"GroundDelayed=Ext_Inv " + r"GroundTrip=800 " + r"TDGrFast=1 " + r"TDGrDelayed=1 " + r"GroundInst=1200 " + r"Shots=4 " + r"RecloseIntervals=(0.5, 2, 2, )") dss.solution_solve() dss.reclosers_write_name('cb1') @@ -40,22 +40,22 @@ def dss(self, solve_snap_13bus): # =================================================================== def test_reclosers_count(self, dss): dss.text(r"New 'Recloser.cb2' MonitoredObj=Line.684611 " - r"MonitoredTerm=2 " - r"NumFast=4 " - r"PhaseFast=Ext_Inv " - r"PhaseDelayed=Ext_Inv " - r"PhaseTrip=800 " - r"TDPhFast=1 " - r"TDPhDelayed=1 " - r"PhaseInst=2400 " - r"GroundFast=Ext_Inv " - r"GroundDelayed=Ext_Inv " - r"GroundTrip=800 " - r"TDGrFast=1 " - r"TDGrDelayed=1 " - r"GroundInst=1200 " - r"Shots=4 " - r"RecloseIntervals=(0.5, 2, 2, )") + r"MonitoredTerm=2 " + r"NumFast=4 " + r"PhaseFast=Ext_Inv " + r"PhaseDelayed=Ext_Inv " + r"PhaseTrip=800 " + r"TDPhFast=1 " + r"TDPhDelayed=1 " + r"PhaseInst=2400 " + r"GroundFast=Ext_Inv " + r"GroundDelayed=Ext_Inv " + r"GroundTrip=800 " + r"TDGrFast=1 " + r"TDGrDelayed=1 " + r"GroundInst=1200 " + r"Shots=4 " + r"RecloseIntervals=(0.5, 2, 2, )") expected = 2 actual = dss.reclosers_count() assert actual == expected @@ -67,22 +67,22 @@ def test_reclosers_first(self, dss): def test_reclosers_next(self, dss): dss.text(r"New 'Recloser.cb2' MonitoredObj=Line.684611 " - r"MonitoredTerm=2 " - r"NumFast=4 " - r"PhaseFast=Ext_Inv " - r"PhaseDelayed=Ext_Inv " - r"PhaseTrip=800 " - r"TDPhFast=1 " - r"TDPhDelayed=1 " - r"PhaseInst=2400 " - r"GroundFast=Ext_Inv " - r"GroundDelayed=Ext_Inv " - r"GroundTrip=800 " - r"TDGrFast=1 " - r"TDGrDelayed=1 " - r"GroundInst=1200 " - r"Shots=4 " - r"RecloseIntervals=(0.5, 2, 2, )") + r"MonitoredTerm=2 " + r"NumFast=4 " + r"PhaseFast=Ext_Inv " + r"PhaseDelayed=Ext_Inv " + r"PhaseTrip=800 " + r"TDPhFast=1 " + r"TDPhDelayed=1 " + r"PhaseInst=2400 " + r"GroundFast=Ext_Inv " + r"GroundDelayed=Ext_Inv " + r"GroundTrip=800 " + r"TDGrFast=1 " + r"TDGrDelayed=1 " + r"GroundInst=1200 " + r"Shots=4 " + r"RecloseIntervals=(0.5, 2, 2, )") expected = 2 dss.reclosers_first() actual = dss.reclosers_next() @@ -149,22 +149,22 @@ def test_reclosers_read_idx(self, dss): def test_reclosers_write_idx(self, dss): dss.text(r"New 'Recloser.cb2' MonitoredObj=Line.684611 " - r"MonitoredTerm=2 " - r"NumFast=4 " - r"PhaseFast=Ext_Inv " - r"PhaseDelayed=Ext_Inv " - r"PhaseTrip=800 " - r"TDPhFast=1 " - r"TDPhDelayed=1 " - r"PhaseInst=2400 " - r"GroundFast=Ext_Inv " - r"GroundDelayed=Ext_Inv " - r"GroundTrip=800 " - r"TDGrFast=1 " - r"TDGrDelayed=1 " - r"GroundInst=1200 " - r"Shots=4 " - r"RecloseIntervals=(0.5, 2, 2, )") + r"MonitoredTerm=2 " + r"NumFast=4 " + r"PhaseFast=Ext_Inv " + r"PhaseDelayed=Ext_Inv " + r"PhaseTrip=800 " + r"TDPhFast=1 " + r"TDPhDelayed=1 " + r"PhaseInst=2400 " + r"GroundFast=Ext_Inv " + r"GroundDelayed=Ext_Inv " + r"GroundTrip=800 " + r"TDGrFast=1 " + r"TDGrDelayed=1 " + r"GroundInst=1200 " + r"Shots=4 " + r"RecloseIntervals=(0.5, 2, 2, )") expected = 2 dss.reclosers_write_idx(expected) actual = dss.reclosers_read_idx() @@ -227,22 +227,22 @@ def test_reclosers_read_name(self, dss): def test_reclosers_write_name(self, dss): dss.text(r"New 'Recloser.cb2' MonitoredObj=Line.684611 " - r"MonitoredTerm=2 " - r"NumFast=4 " - r"PhaseFast=Ext_Inv " - r"PhaseDelayed=Ext_Inv " - r"PhaseTrip=800 " - r"TDPhFast=1 " - r"TDPhDelayed=1 " - r"PhaseInst=2400 " - r"GroundFast=Ext_Inv " - r"GroundDelayed=Ext_Inv " - r"GroundTrip=800 " - r"TDGrFast=1 " - r"TDGrDelayed=1 " - r"GroundInst=1200 " - r"Shots=4 " - r"RecloseIntervals=(0.5, 2, 2, )") + r"MonitoredTerm=2 " + r"NumFast=4 " + r"PhaseFast=Ext_Inv " + r"PhaseDelayed=Ext_Inv " + r"PhaseTrip=800 " + r"TDPhFast=1 " + r"TDPhDelayed=1 " + r"PhaseInst=2400 " + r"GroundFast=Ext_Inv " + r"GroundDelayed=Ext_Inv " + r"GroundTrip=800 " + r"TDGrFast=1 " + r"TDGrDelayed=1 " + r"GroundInst=1200 " + r"Shots=4 " + r"RecloseIntervals=(0.5, 2, 2, )") expected = 'cb2' dss.reclosers_write_name(expected) actual = dss.reclosers_read_name() @@ -275,22 +275,22 @@ def test_reclosers_write_switched_obj(self, dss): # =================================================================== def test_reclosers_all_names(self, dss): dss.text(r"New 'Recloser.cb2' MonitoredObj=Line.684611 " - r"MonitoredTerm=2 " - r"NumFast=4 " - r"PhaseFast=Ext_Inv " - r"PhaseDelayed=Ext_Inv " - r"PhaseTrip=800 " - r"TDPhFast=1 " - r"TDPhDelayed=1 " - r"PhaseInst=2400 " - r"GroundFast=Ext_Inv " - r"GroundDelayed=Ext_Inv " - r"GroundTrip=800 " - r"TDGrFast=1 " - r"TDGrDelayed=1 " - r"GroundInst=1200 " - r"Shots=4 " - r"RecloseIntervals=(0.5, 2, 2, )") + r"MonitoredTerm=2 " + r"NumFast=4 " + r"PhaseFast=Ext_Inv " + r"PhaseDelayed=Ext_Inv " + r"PhaseTrip=800 " + r"TDPhFast=1 " + r"TDPhDelayed=1 " + r"PhaseInst=2400 " + r"GroundFast=Ext_Inv " + r"GroundDelayed=Ext_Inv " + r"GroundTrip=800 " + r"TDGrFast=1 " + r"TDGrDelayed=1 " + r"GroundInst=1200 " + r"Shots=4 " + r"RecloseIntervals=(0.5, 2, 2, )") expected = ['cb1', 'cb2'] actual = dss.reclosers_all_names() assert actual == expected diff --git a/tests/py_dss_interface/test_relays.py b/tests/py_dss_interface/test_relays.py index 922579f7..ea55fcf0 100644 --- a/tests/py_dss_interface/test_relays.py +++ b/tests/py_dss_interface/test_relays.py @@ -14,15 +14,15 @@ class TestRelays13Bus: def dss(self, solve_snap_13bus): dss = solve_snap_13bus dss.text(r"New Relay.test1 MonitoredObj=Line.650632 " - r" MonitoredTerm=1 " - r" Type=Current " - r" PhaseTrip=800 " - r" GroundTrip=250") + r" MonitoredTerm=1 " + r" Type=Current " + r" PhaseTrip=800 " + r" GroundTrip=250") dss.text(r"New Relay.test2 MonitoredObj=Line.632645 " - r" MonitoredTerm=1 " - r" Type=Current " - r" PhaseTrip=800 " - r" GroundTrip=250") + r" MonitoredTerm=1 " + r" Type=Current " + r" PhaseTrip=800 " + r" GroundTrip=250") dss.solution_solve() dss.relays_write_name("test1") diff --git a/tests/py_dss_interface/test_sensors.py b/tests/py_dss_interface/test_sensors.py index abf7df40..eb3a1473 100644 --- a/tests/py_dss_interface/test_sensors.py +++ b/tests/py_dss_interface/test_sensors.py @@ -14,10 +14,10 @@ class TestSensors13Bus: def dss(self, solve_snap_13bus): dss = solve_snap_13bus dss.text("New Sensor.Sensor1 " - "element=Load.671 " - "terminal=1 " - "kVBase=4.16 " - "conn=delta ") + "element=Load.671 " + "terminal=1 " + "kVBase=4.16 " + "conn=delta ") dss.solution_solve() dss.sensors_write_name("Sensor1") @@ -38,10 +38,10 @@ def test_sensors_first(self, dss): def test_sensors_next(self, dss): dss.text("New Sensor.Sensor2 " - "element=Load.611 " - "terminal=1 " - "kVBase=4.16 " - "conn=wye ") + "element=Load.611 " + "terminal=1 " + "kVBase=4.16 " + "conn=wye ") expected = 2 dss.sensors_first() actual = dss.sensors_next() @@ -136,10 +136,10 @@ def test_sensors_read_name(self, dss): def test_sensors_write_name(self, dss): dss.text("New Sensor.Sensor2 " - "element=Load.611 " - "terminal=1 " - "kVBase=4.16 " - "conn=wye ") + "element=Load.611 " + "terminal=1 " + "kVBase=4.16 " + "conn=wye ") expected = "sensor2" dss.sensors_write_name(expected) actual = dss.sensors_read_name() @@ -161,10 +161,10 @@ def test_sensors_write_metered_element(self, dss): # =================================================================== def test_sensors_all_names(self, dss): dss.text("New Sensor.Sensor2 " - "element=Load.611 " - "terminal=1 " - "kVBase=4.16 " - "conn=wye ") + "element=Load.611 " + "terminal=1 " + "kVBase=4.16 " + "conn=wye ") expected = ["sensor1", "sensor2"] actual = dss.sensors_all_names() assert actual == expected diff --git a/tests/py_dss_interface/test_solution.py b/tests/py_dss_interface/test_solution.py index 7b17c983..6831b6e1 100644 --- a/tests/py_dss_interface/test_solution.py +++ b/tests/py_dss_interface/test_solution.py @@ -16,6 +16,7 @@ def dss(self, solve_snap_13bus): dss.solution_solve() return dss + # =================================================================== # Integer methods # =================================================================== @@ -405,7 +406,7 @@ def test_solution_step_size_min(self, dss): def test_solution_step_size_hr(self, dss): expected = 0 actual = dss.solution_step_size_hr() - assert expected == dss.solution_step_size_hr() + assert expected == actual def test_solution_process_time(self, dss): expected = -1 @@ -443,11 +444,11 @@ def test_solution_read_ld_curve(self, dss): def test_solution_write_ld_curve(self, dss): dss.text("New Loadshape.Test npts=24 interval=1 Pbase=100 Qbase=50 " - "mult= " - "(0.18000001 0.19000000 0.23999999 0.33000001 0.38999999 0.41000000 " - "0.64999998 1.23000002 1.88999999 1.88999999 1.96000004 1.98000002 " - "1.45000005 1.62000000 1.88999999 1.79999995 1.78999996 1.19000006 " - "0.80000001 0.66000003 0.51999998 0.40000001 0.28000000 0.23000000)") + "mult= " + "(0.18000001 0.19000000 0.23999999 0.33000001 0.38999999 0.41000000 " + "0.64999998 1.23000002 1.88999999 1.88999999 1.96000004 1.98000002 " + "1.45000005 1.62000000 1.88999999 1.79999995 1.78999996 1.19000006 " + "0.80000001 0.66000003 0.51999998 0.40000001 0.28000000 0.23000000)") expected = 'test' dss.solution_write_ld_curve(expected) actual = dss.solution_read_ld_curve() @@ -460,11 +461,11 @@ def test_solution_read_default_daily(self, dss): def test_solution_write_default_daily(self, dss): dss.text("New Loadshape.Test npts=24 interval=1 Pbase=100 Qbase=50 " - "mult= " - "(0.18000001 0.19000000 0.23999999 0.33000001 0.38999999 0.41000000 " - "0.64999998 1.23000002 1.88999999 1.88999999 1.96000004 1.98000002 " - "1.45000005 1.62000000 1.88999999 1.79999995 1.78999996 1.19000006 " - "0.80000001 0.66000003 0.51999998 0.40000001 0.28000000 0.23000000)") + "mult= " + "(0.18000001 0.19000000 0.23999999 0.33000001 0.38999999 0.41000000 " + "0.64999998 1.23000002 1.88999999 1.88999999 1.96000004 1.98000002 " + "1.45000005 1.62000000 1.88999999 1.79999995 1.78999996 1.19000006 " + "0.80000001 0.66000003 0.51999998 0.40000001 0.28000000 0.23000000)") expected = 'test' dss.solution_write_default_daily(expected) actual = dss.solution_read_default_daily() @@ -477,11 +478,11 @@ def test_solution_read_default_yearly(self, dss): def test_solution_write_default_yearly(self, dss): dss.text("New Loadshape.Test npts=24 interval=1 Pbase=100 Qbase=50 " - "mult= " - "(0.18000001 0.19000000 0.23999999 0.33000001 0.38999999 0.41000000 " - "0.64999998 1.23000002 1.88999999 1.88999999 1.96000004 1.98000002 " - "1.45000005 1.62000000 1.88999999 1.79999995 1.78999996 1.19000006 " - "0.80000001 0.66000003 0.51999998 0.40000001 0.28000000 0.23000000)") + "mult= " + "(0.18000001 0.19000000 0.23999999 0.33000001 0.38999999 0.41000000 " + "0.64999998 1.23000002 1.88999999 1.88999999 1.96000004 1.98000002 " + "1.45000005 1.62000000 1.88999999 1.79999995 1.78999996 1.19000006 " + "0.80000001 0.66000003 0.51999998 0.40000001 0.28000000 0.23000000)") expected = 'test' dss.solution_write_default_yearly(expected) actual = dss.solution_read_default_yearly() diff --git a/tests/py_dss_interface/test_swtcontrols.py b/tests/py_dss_interface/test_swtcontrols.py index d9fb531d..7b8f3530 100644 --- a/tests/py_dss_interface/test_swtcontrols.py +++ b/tests/py_dss_interface/test_swtcontrols.py @@ -116,3 +116,4 @@ def test_swtcontrols_write_switched_obj(self, dss): def test_swtcontrols_all_names(self, dss): expected = ['1', '2'] actual = dss.swtcontrols_all_names() + assert actual == expected diff --git a/tests/py_dss_interface/test_topology.py b/tests/py_dss_interface/test_topology.py index c21056fb..13b7f189 100644 --- a/tests/py_dss_interface/test_topology.py +++ b/tests/py_dss_interface/test_topology.py @@ -153,7 +153,7 @@ def test_topology_write_branch_name(self, dss): def test_topology_read_bus_name(self, dss): dss.topology_write_branch_name('Transformer.sub') - expected = 'sourcebus' + expected = "sourcebus" actual = dss.topology_read_bus_name() assert actual == expected diff --git a/tests/py_dss_interface/test_transformers.py b/tests/py_dss_interface/test_transformers.py index 1a47b706..7327254c 100644 --- a/tests/py_dss_interface/test_transformers.py +++ b/tests/py_dss_interface/test_transformers.py @@ -238,7 +238,7 @@ def test_transformers_str_wdg_voltages(self, dss): # =================================================================== # Variant methods # =================================================================== - def test_transformers_all_Names(self, dss): + def test_transformers_all_names(self, dss): expected = ['sub', 'reg1', 'reg2', 'reg3', 'xfm1'] actual = dss.transformers_all_Names() assert actual == expected diff --git a/tests/py_dss_interface/test_vsources.py b/tests/py_dss_interface/test_vsources.py index fc77bf28..76209a82 100644 --- a/tests/py_dss_interface/test_vsources.py +++ b/tests/py_dss_interface/test_vsources.py @@ -61,6 +61,7 @@ def test_vsources_write_base_kv(self, dss): expected = 13.8 dss.vsources_write_base_kv(expected) actual = dss.vsources_read_base_kv() + assert actual == expected def test_vsources_read_pu(self, dss): expected = 1.0001 diff --git a/tests/py_dss_interface/utils.py b/tests/py_dss_interface/utils.py index 2537dee5..0fd3f251 100644 --- a/tests/py_dss_interface/utils.py +++ b/tests/py_dss_interface/utils.py @@ -39,4 +39,3 @@ def format_matrix_str(expected_list): if i in [2, 5]: matrix_str += ' | ' return f'{matrix_str[:-1]}]' - From 72919feef6025a35e9b0cacbe2710fa2008c3f09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8Anio=20Viana?= Date: Tue, 19 Jul 2022 23:37:19 -0300 Subject: [PATCH 4/4] Removing unecessary imports --- src/py_dss_interface/models/Lines/LinesF.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/py_dss_interface/models/Lines/LinesF.py b/src/py_dss_interface/models/Lines/LinesF.py index 03e297bb..467788f0 100644 --- a/src/py_dss_interface/models/Lines/LinesF.py +++ b/src/py_dss_interface/models/Lines/LinesF.py @@ -5,8 +5,6 @@ import ctypes from py_dss_interface.models.Base import Base -from py_dss_interface.models.Lines import LinesS -from py_dss_interface.models.Text.Text import Text class LinesF(Base): @@ -105,7 +103,7 @@ def lines_write_emerg_amps(self, argument: float) -> float: return float(self.dss_obj.LinesF(ctypes.c_int32(17), ctypes.c_double(argument))) def lines_read_rg(self) -> float: - """Gets the earth return value used to compute line impedances at power frequency.""" + """Gets the earth return value used to compute line impedance's at power frequency.""" return float(self.dss_obj.LinesF(ctypes.c_int32(18), ctypes.c_double(0))) def lines_write_rg(self, argument: float) -> float: