diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..5ee2892 --- /dev/null +++ b/appveyor.yml @@ -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\* diff --git a/tests/modules/compare_configs/data/base_rules_win.yml b/tests/modules/compare_configs/data/base_rules_win.yml new file mode 100644 index 0000000..04e9f1a --- /dev/null +++ b/tests/modules/compare_configs/data/base_rules_win.yml @@ -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: '^ ' diff --git a/tests/modules/compare_configs/test_compare_configs.py b/tests/modules/compare_configs/test_compare_configs.py index 41671b2..d6ed2d1 100644 --- a/tests/modules/compare_configs/test_compare_configs.py +++ b/tests/modules/compare_configs/test_compare_configs.py @@ -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(): @@ -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] diff --git a/tests/parsing/yaml/test_parsing_yaml.py b/tests/parsing/yaml/test_parsing_yaml.py index bc2c4f6..20d39fa 100644 --- a/tests/parsing/yaml/test_parsing_yaml.py +++ b/tests/parsing/yaml/test_parsing_yaml.py @@ -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)