-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add gh actions * pyupgrade, isort, black * flake8
- Loading branch information
Showing
9 changed files
with
126 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
name: tests | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
|
||
linting: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-python@v2 | ||
- uses: actions/cache@v2 | ||
with: | ||
path: ~/.cache/pip | ||
key: ${{ runner.os }}-pip | ||
restore-keys: ${{ runner.os }}-pip | ||
- name: Install Poetry | ||
uses: snok/[email protected] | ||
with: | ||
virtualenvs-create: true | ||
virtualenvs-in-project: true | ||
# virtualenvs-path: ~/.venv | ||
- name: Load cached venv | ||
id: cached-poetry-dependencies | ||
uses: actions/cache@v2 | ||
with: | ||
path: .venv | ||
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }} | ||
# install dependencies if cache does not exist | ||
- name: Check cache and install dependencies | ||
run: poetry install | ||
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' | ||
- name: Run linters | ||
run: | | ||
source .venv/bin/activate | ||
flake8 . | ||
black . --check | ||
isort . | ||
test: | ||
needs: linting | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
os: [ "ubuntu-latest", "macos-latest" ] | ||
python-version: [ "3.6", "3.7", "3.8", "3.9" ] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v2 | ||
- name: Set up python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install Poetry | ||
uses: snok/[email protected] | ||
with: | ||
virtualenvs-create: true | ||
virtualenvs-in-project: true | ||
# This approach appears to be cachign the repo source as well (e.g, | ||
# the library code that tests are supposed to test) | ||
# | ||
# FIXME | ||
# | ||
#- name: Load cached venv | ||
# id: cached-poetry-dependencies | ||
# uses: actions/cache@v2 | ||
# with: | ||
# path: .venv | ||
# key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }} | ||
# install dependencies if cache does not exist | ||
- name: Check cache and install dependencies | ||
run: poetry install | ||
- name: Run tests | ||
run: | | ||
source .venv/bin/activate | ||
poetry run pytest tests/ --cov="confu" --cov-report=xml --cov-report=term-missing | ||
poetry run coverage report | ||
# upload coverage stats | ||
- name: Upload coverage | ||
uses: codecov/codecov-action@v1 | ||
with: | ||
file: ./coverage.xml | ||
fail_ci_if_error: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
import sys | ||
|
||
|
||
if __name__ == "__main__": | ||
from .cli import main | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
|
||
class NetomException(Exception): | ||
"""Base exception used by this module.""" | ||
|
||
|
||
class NetomValidationError(NetomException): | ||
"""A validation error occurred.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,31 @@ | ||
|
||
import confu | ||
from confu import schema | ||
|
||
|
||
class BgpNeighbor(schema.Schema): | ||
""" | ||
Defines the BGP Neighbor model. | ||
""" | ||
|
||
name = schema.Str("name", help="name of the session") | ||
description = schema.Str("description", help="description of the session", default=None) | ||
description = schema.Str( | ||
"description", help="description of the session", default=None | ||
) | ||
enabled = schema.Bool("enabled", help="enabled", default=True) | ||
neighbor_address = schema.IpAddress("neighbor_address", help="neighbor IP address") | ||
peer_as = schema.Int("peer_as", help="neighbor AS number") | ||
peer_group = schema.Str("peer_group", help="peer group") | ||
peer_type = schema.Str("peer_type", help="peer type (internal or external)", default="external") | ||
max_prefixes = schema.Int("max_prefixes", help="maximum number of prefixes to accept") | ||
peer_type = schema.Str( | ||
"peer_type", help="peer type (internal or external)", default="external" | ||
) | ||
max_prefixes = schema.Int( | ||
"max_prefixes", help="maximum number of prefixes to accept" | ||
) | ||
import_policy = schema.Str("import_policy", help="Import policy to apply") | ||
export_policy = schema.Str("export_policy", help="Export policy to apply") | ||
auth_password = schema.Str("auth_password", help="MD5 session password", default=None) | ||
local_address = schema.IpAddress("local_address", help="local IP address", default=None) | ||
auth_password = schema.Str( | ||
"auth_password", help="MD5 session password", default=None | ||
) | ||
local_address = schema.IpAddress( | ||
"local_address", help="local IP address", default=None | ||
) | ||
local_as = schema.Int("peer_as", help="neighbor AS number", default=0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
|
||
import os | ||
|
||
import pytest | ||
import pytest | ||
|
||
|
||
@pytest.fixture | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
|
||
import pytest | ||
|
||
import netom | ||
|
||
|
||
def test_init(): | ||
pass | ||
assert netom.Render("test", "12") |