Skip to content
Snippets Groups Projects
Commit 63bfbb2d authored by Erik Reid's avatar Erik Reid
Browse files

pep8

parent 0b815656
No related branches found
No related tags found
No related merge requests found
......@@ -21,6 +21,7 @@ sys.path.insert(0, os.path.abspath(
os.path.dirname(__file__),
'..', '..', 'resource_management')))
class RenderAsJSON(Directive):
# cf. https://stackoverflow.com/a/59883833
......@@ -65,8 +66,6 @@ extensions = [
templates_path = ['_templates']
exclude_patterns = []
# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
......@@ -81,4 +80,3 @@ autodoc_typehints = 'none'
# Display todos by setting to True
todo_include_todos = True
......@@ -31,7 +31,8 @@ import click
import logging
from jsonschema import validate, ValidationError
from resource_management.hardware.router import load_line_cards, LINE_CARDS_LIST_SCHEMA
from resource_management.hardware.router \
import load_line_cards, LINE_CARDS_LIST_SCHEMA
from resource_management import db, config, environment
environment.setup_logging()
......@@ -97,10 +98,11 @@ def cli(config, fqdn):
validate(line_cards, LINE_CARDS_LIST_SCHEMA)
mysql_config = config["mysql"]
dsn = db.mysql_dsn(mysql_config["username"],
mysql_config["password"],
mysql_config["hostname"],
mysql_config["dbname"])
dsn = db.mysql_dsn(
username=mysql_config["username"],
password=mysql_config["password"],
hostname=mysql_config["hostname"],
db_name=mysql_config["dbname"])
logger.info("MYSQL DSN is: {0}".format(dsn))
db.init_db_model(dsn)
......
import contextlib
import logging
from typing import Optional, Union, Callable, Iterator
from typing import Union, Iterator
from sqlalchemy import create_engine
from sqlalchemy.exc import SQLAlchemyError
......
......@@ -25,7 +25,11 @@ LINE_CARDS_LIST_SCHEMA = {
'items': {
'type': 'object',
'properties': {
'name': {'type': 'string', 'pattern': '^[a-z]{2}\\-[0-9]{1,2}\\/[0-9]{1,2}\\/[0-9]{1,3}'},
'name': {
'type': 'string',
'pattern':
'^[a-z]{2}\\-[0-9]{1,2}\\/[0-9]{1,2}\\/[0-9]{1,3}'
},
'speed': {'type': 'integer', 'minimum': 0}
},
'required': ['name', 'speed'],
......@@ -48,6 +52,7 @@ LINE_CARDS_LIST_SCHEMA = {
}
}
@contextlib.contextmanager
def device(hostname, ssh_config, port=830):
......
......@@ -19,10 +19,10 @@ depends_on = None
def upgrade() -> None:
with op.batch_alter_table('ports') as batch_op:
batch_op.add_column(
Column('speed', sa.Integer, nullable=False)),
sa.Column('speed', sa.Integer, nullable=False),
insert_after='name'
)
def downgrade() -> None:
op.drop_column('ports','speed')
op.drop_column('ports', 'speed')
......@@ -10,6 +10,7 @@ from sqlalchemy.pool import StaticPool
from resource_management.db import model
DATA_DIR = os.path.join(os.path.dirname(__file__), 'data')
HOSTNAMES = [
'vmx',
'mx1.lab.office.geant.net',
......@@ -86,10 +87,6 @@ def resources_db():
yield # wait until caller context ends
DATA_DIR = os.path.join(os.path.dirname(__file__), 'data')
def _load_pyez_json_table(router_name, table_name):
filename = f'{router_name}-{table_name}.json'
with open(os.path.join(DATA_DIR, filename)) as f:
......@@ -141,6 +138,7 @@ def mocked_router(router_name):
yield # stay in this block until caller context exits
@pytest.fixture
def mocked_router_input_tables(router_name):
# this is the mocked data used as input to pyez
......
......@@ -14,4 +14,3 @@ def test_cli_happy_flow(
'--config', config_filename,
'--fqdn', router_name])
assert result.exit_code == 0
......@@ -53,7 +53,8 @@ def test_save_router_info(resources_db, router_name, mocked_router):
assert expected_fpc_positions == fpc_positions
for fpc in node.line_cards:
expected_ports = {p['name'] for p in fpc_position_dict[fpc.position]}
expected_ports = {
p['name'] for p in fpc_position_dict[fpc.position]}
port_names = {p.name for p in fpc.ports}
assert expected_ports == port_names
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment