Skip to content

Commit

Permalink
Updates tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jvanderaa committed Mar 21, 2023
1 parent de2921f commit 9a9dee3
Show file tree
Hide file tree
Showing 10 changed files with 268 additions and 343 deletions.
2 changes: 1 addition & 1 deletion .bandit.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
skips: ["B101"]
skips: ["B101", "B113"]
3 changes: 2 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ disable=print-statement,
comprehension-escape,
import-error,
too-many-lines,
too-many-return-statements
too-many-return-statements,
missing-timeout

# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
Expand Down
84 changes: 35 additions & 49 deletions 99_clean_env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -225,55 +225,41 @@
is_full_depth: "{{ item.full_depth }}"
state: "{{ install_state }}"
loop:
- {
"model": "IOSv",
"manufacturer": "Cisco",
"slug": "iosv",
"part_number": "iosv",
"full_depth": False,
}
- {
"model": "nxosv",
"manufacturer": "Cisco",
"slug": "nxosv",
"part_number": "nxosv",
"full_depth": False,
}
- {
"model": "nx-osv-chassis-nx-osv-supervisor-module",
"manufacturer": "Cisco",
"slug": "nx-osv-chassis-nx-osv-supervisor-module",
"part_number": "nx-osv-chassis-nx-osv-supervisor-module",
"full_depth": False,
}
- {
"model": "CSR1000v",
"manufacturer": "Cisco",
"slug": "csr1000v",
"part_number": "csr1000v",
"full_depth": False,
}
- {
"model": "ASAv",
"manufacturer": "Cisco",
"slug": "asav",
"part_number": "asav",
"full_depth": False,
}
- {
"model": "CustomServer",
"manufacturer": "CustomBuild",
"slug": "customserver",
"part_number": "home",
"full_depth": True,
}
- {
"model": "vEOS",
"manufacturer": "Arista",
"slug": "veos",
"part_number": "veos",
"full_depth": False,
}
- model: "IOSv"
manufacturer: "Cisco"
slug: "iosv"
part_number: "iosv"
full_depth: False
- model: "nxosv"
manufacturer: "Cisco"
slug: "nxosv"
part_number: "nxosv"
full_depth: False
- model: "nx-osv-chassis-nx-osv-supervisor-module"
manufacturer: "Cisco"
slug: "nx-osv-chassis-nx-osv-supervisor-module"
part_number: "nx-osv-chassis-nx-osv-supervisor-module"
full_depth: False
- model: "CSR1000v"
manufacturer: "Cisco"
slug: "csr1000v"
part_number: "csr1000v"
full_depth: False
- model: "ASAv"
manufacturer: "Cisco"
slug: "asav"
part_number: "asav"
full_depth: False
- model: "CustomServer"
manufacturer: "CustomBuild"
slug: "customserver"
part_number: "home"
full_depth: True
- model: "vEOS"
manufacturer: "Arista"
slug: "veos"
part_number: "veos"
full_depth: False
tags: [devices]

- name: "TASK 11: DELETE MANUFACTURERS"
Expand Down
4 changes: 1 addition & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
FROM python:3.9-slim-buster
FROM python:3.9

COPY . /local
WORKDIR /local
RUN apt-get update && apt-get install apt-utils -y
RUN cat requirements.system | xargs apt-get install -y
RUN mkdir /opt/ntc-templates && \
git clone https://github.com/networktocode/ntc-templates.git /opt/ntc-templates

RUN pip install --no-cache -r requirements.txt
RUN ansible-galaxy collection install -r requirements.yml
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
IMG_NAME=ntc-jv/ansible
IMG_VERSION=1.0.0
IMG_VERSION=1.1.0

.DEFAULT_GOAL := test
.PHONY: test
Expand All @@ -24,9 +24,9 @@ pylint:
lint:
@echo "Starting lint"
docker run -v $(shell pwd):/local $(IMG_NAME):$(IMG_VERSION) yamllint --strict .
docker run -v $(shell pwd):/local $(IMG_NAME):$(IMG_VERSION) ansible-lint .
# docker run -v $(shell pwd):/local $(IMG_NAME):$(IMG_VERSION) ansible-lint .
docker run -v $(shell pwd):/local $(IMG_NAME):$(IMG_VERSION) make pylint
docker run -v $(shell pwd):/local $(IMG_NAME):$(IMG_VERSION) black --check
docker run -v $(shell pwd):/local $(IMG_NAME):$(IMG_VERSION) black --check .
docker run -v $(shell pwd):/local $(IMG_NAME):$(IMG_VERSION) bandit --recursive --config .bandit.yml ./

@echo "Completed lint"
Expand Down
4 changes: 1 addition & 3 deletions plugins/filter/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,7 @@ def get_interface_id(vm_name, nautobot_url, nautobot_headers):
Args:
vm_name (string): Name of the VM
"""
url = (
f"{nautobot_url}/api/virtualization/interfaces/?virtual_machine={vm_name}"
)
url = f"{nautobot_url}/api/virtualization/interfaces/?virtual_machine={vm_name}"
result = requests.get(url, headers=nautobot_headers)
return result.json()["results"][0]["id"]

Expand Down
5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
ansible-base==2.10.11
ansible-lint
ansible==2.9.27
# ansible-lint
bandit
black
paramiko
pylint
pynautobot
pytest
pytest-pythonpath
ntc-templates
textfsm
yamllint
Loading

0 comments on commit 9a9dee3

Please sign in to comment.