Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated test dependencies #135

Merged
merged 10 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions .travis.yml

This file was deleted.

5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ All notable changes to the of_core NApp will be documented in this file.
[UNRELEASED] - Under development
********************************

Changed
=======
- Updated python environment installation from 3.9 to 3.11
- Updated test dependencies

[2023.2.0] - 2024-02-16
***********************

Expand Down
7 changes: 6 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,12 @@ class Linter(SimpleCommand):
def run(self):
"""Run yala."""
print('Yala is running. It may take several seconds...')
check_call('yala *.py v0x?? tests', shell=True)
try:
check_call('yala *.py v0x?? tests', shell=True)
print('No linter error found.')
except CalledProcessError:
print('Linter check failed. Fix the error(s) above and try again.')
sys.exit(-1)


class InstallMode(install):
Expand Down
8 changes: 0 additions & 8 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
"""Pytest conftest."""
# pylint: disable=redefined-outer-name

import pytest

from kytos.lib.helpers import get_controller_mock, get_switch_mock
from napps.kytos.of_core.main import Main


@pytest.fixture(autouse=True)
def ev_loop(monkeypatch, event_loop) -> None:
"""asyncio event loop autouse fixture."""
monkeypatch.setattr("asyncio.get_running_loop", lambda: event_loop)
yield event_loop


@pytest.fixture
def controller():
"""Controller mock fixture."""
Expand Down
2 changes: 1 addition & 1 deletion tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def get_switch_mock(dpid="00:00:00:00:00:00:00:01"):

def get_connection_mock(of_version, target_switch, state=ConnectionState.NEW):
"""Return a connection mock."""
connection = Connection(Mock(), Mock(), Mock())
connection = Connection(Mock(), Mock(), Mock(), Mock())
connection.switch = target_switch
connection.state = state
connection.protocol.version = of_version
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def setup_method(self):
self.napp = Main(get_controller_mock())

@patch("time.sleep")
def test_execute(self, mock_sleep):
async def test_execute(self, mock_sleep):
"""Test 'execute' main method."""
self.napp.controller._buffers = KytosBuffers()
dpid_01 = "00:00:00:00:00:00:00:01"
Expand Down Expand Up @@ -317,7 +317,7 @@ def test_get_event_listeners(self):
for _event in expected_events:
assert _event in actual_events, str(_event)

def test_handle_04_features_reply(self):
async def test_handle_04_features_reply(self):
"""Test handling features reply message."""
self.napp.controller._buffers = KytosBuffers()
event_name = 'kytos/of_core.v0x04.messages.in.ofpt_features_reply'
Expand Down Expand Up @@ -374,7 +374,7 @@ def test_handle_features_request_sent(self):
assert event.destination.protocol.state == \
'waiting_features_reply'

def test_handle_echo_request(self):
async def test_handle_echo_request(self):
"""Test handling echo request message."""
self.napp.controller._buffers = KytosBuffers()
event_name = 'kytos/of_core.v0x04.messages.in.ofpt_echo_request'
Expand Down
13 changes: 7 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
[tox]
envlist = py39,coverage,lint
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
2 changes: 1 addition & 1 deletion utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""of_core utility functions and classes."""

# pylint: disable=broad-exception-raised
import struct
from collections import OrderedDict

Expand Down