From aaf9c910f6e35b4c124c07f9728a7a504b1e71b6 Mon Sep 17 00:00:00 2001 From: Aldo Ortega Date: Wed, 6 Mar 2024 05:18:00 -0500 Subject: [PATCH 1/4] Updated test dependencies --- controllers/__init__.py | 4 +++- db/models/__init__.py | 8 ++++---- requirements/dev.in | 6 +++--- tests/unit/test_main.py | 17 +++++++++-------- tox.ini | 10 +++++----- 5 files changed, 24 insertions(+), 21 deletions(-) diff --git a/controllers/__init__.py b/controllers/__init__.py index c6eee80..a3bc02f 100644 --- a/controllers/__init__.py +++ b/controllers/__init__.py @@ -75,7 +75,9 @@ def upsert_interfaces( **{"_id": interface_id, "updated_at": utc_now}, } ) - payload = model.dict(exclude={"inserted_at"}, exclude_none=True) + payload = model.model_dump( + exclude={"inserted_at"}, exclude_none=True + ) ops.append( UpdateOne( {"_id": interface_id}, diff --git a/db/models/__init__.py b/db/models/__init__.py index c385123..897b153 100644 --- a/db/models/__init__.py +++ b/db/models/__init__.py @@ -12,12 +12,12 @@ class DocumentBaseModel(BaseModel): """DocumentBaseModel.""" id: str = Field(None, alias="_id") - inserted_at: Optional[datetime] - updated_at: Optional[datetime] + inserted_at: Optional[datetime] = None + updated_at: Optional[datetime] = None - def dict(self, **kwargs) -> dict: + def model_dump(self, **kwargs) -> dict: """Model to dict.""" - values = super().dict(**kwargs) + values = super().model_dump(**kwargs) if "id" in values and values["id"]: values["_id"] = values["id"] if "exclude" in kwargs and "_id" in kwargs["exclude"]: diff --git a/requirements/dev.in b/requirements/dev.in index 1754158..134ad69 100644 --- a/requirements/dev.in +++ b/requirements/dev.in @@ -1,4 +1,4 @@ --e git+https://github.com/kytos-ng/python-openflow.git#egg=python-openflow --e git+https://github.com/kytos-ng/kytos.git#egg=kytos[dev] --e git+https://github.com/kytos-ng/of_core.git#egg=kytos_of_core +-e git+https://github.com/kytos-ng/python-openflow.git@upgrade/python#egg=python-openflow +-e git+https://github.com/kytos-ng/kytos.git@upgrade/python#egg=kytos[dev] +-e git+https://github.com/kytos-ng/of_core.git@upgrade/python#egg=kytos_of_core -e . diff --git a/tests/unit/test_main.py b/tests/unit/test_main.py index 38174f3..dd024d7 100644 --- a/tests/unit/test_main.py +++ b/tests/unit/test_main.py @@ -1,4 +1,5 @@ """Test Main methods.""" +import asyncio from unittest.mock import AsyncMock, MagicMock, call, patch from httpx import Response @@ -416,13 +417,13 @@ async def test_rest_get_lldp_interfaces(self): assert response.status_code == 200 assert response.json() == expected_data - async def test_enable_disable_lldp_200(self, event_loop): + async def test_enable_disable_lldp_200(self): """Test 200 response for enable_lldp and disable_lldp methods.""" data = {"interfaces": ['00:00:00:00:00:00:00:01:1', '00:00:00:00:00:00:00:01:2', '00:00:00:00:00:00:00:02:1', '00:00:00:00:00:00:00:02:2']} - self.napp.controller.loop = event_loop + self.napp.controller.loop = asyncio.get_running_loop() self.napp.publish_liveness_status = MagicMock() endpoint = f"{self.base_endpoint}/interfaces/disable" response = await self.api_client.post(endpoint, json=data) @@ -444,7 +445,7 @@ async def test_enable_disable_lldp_404(self): response = await self.api_client.post(endpoint, json=data) assert response.status_code == 404 - async def test_enable_disable_lldp_400(self, event_loop): + async def test_enable_disable_lldp_400(self): """Test 400 response for enable_lldp and disable_lldp methods.""" data = {"interfaces": ['00:00:00:00:00:00:00:01:1', '00:00:00:00:00:00:00:01:2', @@ -453,7 +454,7 @@ async def test_enable_disable_lldp_400(self, event_loop): '00:00:00:00:00:00:00:03:1', '00:00:00:00:00:00:00:03:2', '00:00:00:00:00:00:00:04:1']} - self.napp.controller.loop = event_loop + self.napp.controller.loop = asyncio.get_running_loop() self.napp.publish_liveness_status = MagicMock() url = f'{self.base_endpoint}/interfaces/disable' response = await self.api_client.post(url, json=data) @@ -484,9 +485,9 @@ async def test_set_time_400(self): response = await self.api_client.post(url, json=data) assert response.status_code == 400 - async def test_endpoint_enable_liveness(self, event_loop): + async def test_endpoint_enable_liveness(self): """Test POST v1/liveness/enable.""" - self.napp.controller.loop = event_loop + self.napp.controller.loop = asyncio.get_running_loop() self.napp.liveness_manager.enable = MagicMock() self.napp.publish_liveness_status = MagicMock() url = f"{self.base_endpoint}/liveness/enable" @@ -498,9 +499,9 @@ async def test_endpoint_enable_liveness(self, event_loop): assert self.napp.liveness_manager.enable.call_count == 1 assert self.napp.publish_liveness_status.call_count == 1 - async def test_endpoint_disable_liveness(self, event_loop): + async def test_endpoint_disable_liveness(self): """Test POST v1/liveness/disable.""" - self.napp.controller.loop = event_loop + self.napp.controller.loop = asyncio.get_running_loop() self.napp.liveness_manager.disable = MagicMock() self.napp.publish_liveness_status = MagicMock() url = f"{self.base_endpoint}/liveness/disable" diff --git a/tox.ini b/tox.ini index e9a7b56..2caee15 100644 --- a/tox.ini +++ b/tox.ini @@ -3,20 +3,20 @@ envlist = coverage,lint [testenv] -whitelist_externals = rm -deps = -Urrequirements/dev.in +allowlist_externals = rm +deps = -rrequirements/dev.in setenv= - PYTHONPATH = {toxworkdir}/py39/var/lib/kytos/:{envdir} + PYTHONPATH = {toxworkdir}/py311/var/lib/kytos/:{envdir} [testenv:coverage] skip_install = true -envdir = {toxworkdir}/py39 +envdir = {toxworkdir}/py311 commands= python3 setup.py coverage {posargs} [testenv:lint] skip_install = true -envdir = {toxworkdir}/py39 +envdir = {toxworkdir}/py311 commands = python3 setup.py lint From ca58c145e194ea05629fef556ba89238fb8a444c Mon Sep 17 00:00:00 2001 From: Aldo Ortega Date: Thu, 14 Mar 2024 14:27:06 -0400 Subject: [PATCH 2/4] Upgraded changelog --- CHANGELOG.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index bcf270b..93efe54 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,6 +6,14 @@ All notable changes to the of_lldp NApp will be documented in this file. [UNRELEASED] - Under development ******************************** +Changed +======= +- Updated python environment installation from 3.9 to 3.11 +- Updated test dependencies + +[UNRELEASED] - Under development +******************************** + Changed ======= - ``FLOW_VLAN_VID`` from settings now is used or made available in all interfaces from the switch where a flow is created or deleted. From 4f417908b5d82348ae779d2d0ba16323e79d2b21 Mon Sep 17 00:00:00 2001 From: Aldo Ortega Date: Tue, 19 Mar 2024 14:54:44 -0400 Subject: [PATCH 3/4] Updated requirements --- CHANGELOG.rst | 4 ++-- requirements/dev.in | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 93efe54..06b31c1 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -11,8 +11,8 @@ Changed - Updated python environment installation from 3.9 to 3.11 - Updated test dependencies -[UNRELEASED] - Under development -******************************** +[2023.2.0] - 2024-02-16 +*********************** Changed ======= diff --git a/requirements/dev.in b/requirements/dev.in index 134ad69..1754158 100644 --- a/requirements/dev.in +++ b/requirements/dev.in @@ -1,4 +1,4 @@ --e git+https://github.com/kytos-ng/python-openflow.git@upgrade/python#egg=python-openflow --e git+https://github.com/kytos-ng/kytos.git@upgrade/python#egg=kytos[dev] --e git+https://github.com/kytos-ng/of_core.git@upgrade/python#egg=kytos_of_core +-e git+https://github.com/kytos-ng/python-openflow.git#egg=python-openflow +-e git+https://github.com/kytos-ng/kytos.git#egg=kytos[dev] +-e git+https://github.com/kytos-ng/of_core.git#egg=kytos_of_core -e . From 0d9e0aa467d2acf57f3783868c70a9fc118fdc19 Mon Sep 17 00:00:00 2001 From: Aldo Ortega Date: Thu, 28 Mar 2024 10:11:39 -0400 Subject: [PATCH 4/4] Updated readme --- README.rst | 4 +++- setup.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index daf03f4..3b2af60 100644 --- a/README.rst +++ b/README.rst @@ -78,8 +78,10 @@ To install this NApp, first, make sure to have the same venv activated as you ha $ git clone https://github.com/kytos-ng/of_lldp.git $ cd of_lldp - $ python setup.py develop + $ python3 -m pip install --editable . +To install the kytos environment, please follow our +`development environment setup `_. Requirements ============ diff --git a/setup.py b/setup.py index f8195a0..9f8b667 100644 --- a/setup.py +++ b/setup.py @@ -254,7 +254,7 @@ def read_requirements(path="requirements/run.txt"): author='Kytos Team', author_email='of-ng-dev@ncc.unesp.br', license='MIT', - install_requires=read_requirements() + ['setuptools >= 36.0.1'], + install_requires=read_requirements() + ['importlib_metadata'], packages=[], cmdclass={ 'clean': Cleaner,