Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
20 changes: 20 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
environment:

matrix:
- PYTHON: "C:\\Python27"
- PYTHON: "C:\\Python34"
- PYTHON: "C:\\Python35"

init:
- set PATH=%PYTHON%\Scripts;%PATH%

install:
- "%PYTHON%\\python.exe -m pip install tox"

build: off

test_script:
- tox

artifacts:
- path: dist\*
12 changes: 12 additions & 0 deletions tests/modules/compare_configs/data/base_rules_win.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
configs: 'tests\modules\compare_configs\data\configs\basic'

rules:
# Match SNMP Server
- match:
description: Match SNMP settings, ignore location
string: '^snmp-server'
exclude: '^snmp-server location'

- between:
start: '^ip access-list extended ACCESS-IN'
until_not: '^ '
10 changes: 8 additions & 2 deletions tests/modules/compare_configs/test_compare_configs.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
"""Tests for compare module."""
import pytest
import os
from nelkit.exceptions import NelkitException
from nelkit.modules.compare_configs.settings import CompareConfigs
s = os.sep


BASE_DIR = 'tests/modules/compare_configs/data/'
BASE_RULES = 'tests/modules/compare_configs/data/base_rules.yml'
if s == '/':
BASE_RULES = 'tests/modules/compare_configs/data/base_rules.yml'
else:
BASE_RULES = 'tests/modules/compare_configs/data/base_rules_win.yml'


def test_base_function():
Expand Down Expand Up @@ -36,4 +41,5 @@ def test_invalid_config_between_missing_start():
def test_basic_diff():
"""Basic basic diff of the compare module, and check that no exceptions are raised."""
run = CompareConfigs(settings_file=BASE_RULES)
assert basic_diff == run._diff['tests/modules/compare_configs/data/configs/basic/file_b.ios'][2]
assert basic_diff == run._diff['tests%smodules%scompare_configs%sdata%sconfigs%sbasic%sfile_b.ios' % (
s, s, s, s, s, s)][2]
14 changes: 9 additions & 5 deletions tests/parsing/yaml/test_parsing_yaml.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
"""Tests to validate yaml features."""
from nelkit.exceptions import FileNotFound, ParsingError
from nelkit.parsing.yaml.loader import YamlLoader
import os
import pytest
s = os.sep


def test_YamlLoader():
"""Test to see that the YamlLoader returns a dict."""
yl = YamlLoader(filename='tests/parsing/yaml/data/base.yml')
yl = YamlLoader(filename='tests%sparsing%syaml%sdata%sbase.yml' % (s, s, s, s))
assert isinstance(yl.data, dict)


def test_load_missing_file():
"""Test to verify that an exception is raised when trying to load a non-existing file."""
with pytest.raises(FileNotFound) as excinfo:
YamlLoader(filename='tests/parsing/yaml/data/file_that_does_not_exist.yml')
assert 'Unable to read: tests/parsing/yaml/data/file_that_does_not_exist.yml' == str(excinfo.value)
YamlLoader(filename='tests%sparsing%syaml%sdata%sfile_that_does_not_exist.yml' % (s, s, s, s))
assert 'Unable to read: tests%sparsing%syaml%sdata%sfile_that_does_not_exist.yml' % (
s, s, s, s) == str(excinfo.value)


def test_load_invalid_file():
"""Test to verify that an exception is raised when the yaml file is invalid."""
with pytest.raises(ParsingError) as excinfo:
YamlLoader(filename='tests/parsing/yaml/data/invalid_yaml.yml')
assert 'tests/parsing/yaml/data/invalid_yaml.yml is not a valid yaml file' == str(excinfo.value)
YamlLoader(filename='tests%sparsing%syaml%sdata%sinvalid_yaml.yml' % (s, s, s, s))
assert 'tests%sparsing%syaml%sdata%sinvalid_yaml.yml is not a valid yaml file' % (
s, s, s, s) == str(excinfo.value)