Files
napalm-s350/test/unit/conftest.py
T
4d86beea46 Update interface_counters from develop (#96)
* adding read_timeout_override netmiko option

* adding netmiko option session_log

* Bump black from 20.8b1 to 24.3.0

Bumps [black](https://github.com/psf/black) from 20.8b1 to 24.3.0.
- [Release notes](https://github.com/psf/black/releases)
- [Changelog](https://github.com/psf/black/blob/main/CHANGES.md)
- [Commits](https://github.com/psf/black/commits/24.3.0)

---
updated-dependencies:
- dependency-name: black
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>

* remove demjson - blocking tests

* FIX minor formating fixes raised by pylama

* FIX limit napalm and netmiko o version 3.*, soften version requirements

* FIX minor formating fixes raised by pylama

* Allow testing on all supported Py versions

* FIX add platform name to driver s350

* FIX force interface speed as a float

* Update information about required versions to Py3.8+ and napalm 3

* Add scheduled check on develop branch

* Update pkg version in setup.py

* Update PublishToPIP.yml for manual run

* Napalm 4 compatibility, newer dependencies

* Full tox testing on "develop" and "master" branch.

* Remove Py13 - too early

* Do not test on PyPy, local test with local Py version only

* CI ThoroughTest for branches develop and master

* CI FastTest for all other branches.

* CI rename legacy jobs

* CI renaname job

* Updata docs

* Shorten name of publish workflow

* Check syntax for Py3.12

* use netmiko_args

* Add changes for 4.1.0 (#89)

* Update requirements.txt

* Typpo in requirements

* _send_command has only two parameters

* Adapt to stricter Unit tests

---------

Co-authored-by: Anton Gridnev <anton@gridnev.pro>

* Remove s350_base_interfaces custom map - it is allready in napalm base

* Adapt Unit tests to canonical_interface_name()

* Add format parameter to get_config()

* Add badges

* Tests for push are enought

* update CD actions

* add tests for device SG500-52

* Merge CI to develop (#95)

* Simplify CI

* CI update

* CI update

* Update CI from develop (#94)

* Add format parameter to get_config()

* Add badges

* Tests for push are enought

* update CD actions

* add tests for device SG500-52

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Dave <davama@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Anton Gridnev <anton@gridnev.pro>
2024-04-23 12:45:29 +02:00

63 lines
1.5 KiB
Python

"""Test fixtures."""
from builtins import super
import pytest
from napalm.base.test import conftest as parent_conftest
from napalm.base.test.double import BaseTestDouble
from napalm_s350 import s350
@pytest.fixture(scope="class")
def set_device_parameters(request):
"""Set up the class."""
def fin():
request.cls.device.close()
request.addfinalizer(fin)
request.cls.driver = s350.S350Driver
request.cls.patched_driver = PatchedS350Driver
request.cls.vendor = "s350"
parent_conftest.set_device_parameters(request)
def pytest_generate_tests(metafunc):
"""Generate test cases dynamically."""
parent_conftest.pytest_generate_tests(metafunc, __file__)
class PatchedS350Driver(s350.S350Driver):
"""Patched IOS Driver."""
def __init__(self, hostname, username, password, timeout=60, optional_args=None):
super().__init__(hostname, username, password, timeout, optional_args)
self.patched_attrs = ["device"]
self.device = FakeS350Device()
def disconnect(self):
pass
def is_alive(self):
return {"is_alive": True} # In testing everything works..
def open(self):
pass
class FakeS350Device(BaseTestDouble):
"""IOS device test double."""
def send_command(self, command, **kwargs):
filename = "{}.txt".format(self.sanitize_text(command))
full_path = self.find_file(filename)
result = self.read_txt_file(full_path)
return str(result)
def disconnect(self):
pass