-
Notifications
You must be signed in to change notification settings - Fork 18
[qa] Add mocks to unit tests #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
2675672
[qa] Add mocks in base SSH unit tests
purhan 68fa3ce
[qa] Add mocks in OpenWRT SSH unit tests
purhan 6421847
[qa] Add mocks in OpenWRT SSH tests
purhan 3c20fd8
[qa] Format json files
purhan a87cc39
[qa] Add back negative results test
purhan 6a9095a
[qa] Mock testcases for OpenWRT SNMP backend
purhan f73205f
[qa] Mock testcases for AirOS SSH backend
purhan dece4a0
[qa] Mock tests for airos snmp backend
purhan bd30ed4
[chores] Remove redundant lines
purhan 2a3e444
[qa] Mock remaining tests for SNMP AirOS
purhan 4485d43
[chores] Rename function for clarity
purhan 6a000db
[change] Remove the requirement of test-settings.json from unittests
purhan 26c4f52
[chores] Include http tests in __init__.py
purhan f6f4eb5
[qa] Allow disabling mocks to use real devices in tests
purhan d4298bf
Revert "[qa] Allow disabling mocks to use real devices in tests"
purhan ea5398c
[qa] Allow running tests on real devices
purhan 873b6dc
[chores] Add newline at the end of the file
purhan 4e240ec
[change] Mock only external libraries
purhan 7cddc92
[chores/requested-changes] Improvements to SNMP tests
purhan edf1ace
[chores] Merge branch master
purhan 74b1646
[qa] Create spy mocks
purhan 5fd4ab4
[chores] Change exception test
purhan 6fddaff
[chores] Remove redundant lines
purhan 87de032
Merge branch 'master' into mock-ssh-base
purhan 740b7ef
[chores] Fix failing test
purhan eeac44e
[chores] Move logic to utils.py
purhan bba187c
[chores] Fix default settings file name
purhan 7a40cf1
[chores/docs] Add file extension in docs
purhan 61fc7ae
[chores/docs] Add file extension in docs
purhan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,2 @@ | ||
| nose | ||
| coverage |
This file contains hidden or 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,4 +1,5 @@ | ||
| netaddr | ||
| pysnmp | ||
| ipaddress | ||
| argparse | ||
| argparse | ||
| mock |
This file contains hidden or 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,23 @@ | ||
| #!/usr/bin/env python | ||
| # -*- coding: utf-8 -*- | ||
|
|
||
| import os | ||
| try: | ||
| import nose | ||
| except: | ||
| message = """nose package not installed, install test requirements with: | ||
| pip install -r requirements-test.txt | ||
| """ | ||
| raise ImportError(message) | ||
|
|
||
| if __name__ == "__main__": | ||
| file_path = os.path.abspath(__file__) | ||
| tests_path = os.path.join(os.path.abspath(os.path.dirname(file_path)), "tests") | ||
| result = nose.run( | ||
| argv=[ | ||
| os.path.abspath(__file__), | ||
| "--with-cov", | ||
| "--cover-package=netengine", | ||
| tests_path | ||
| ] | ||
| ) |
This file contains hidden or 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,17 +1,17 @@ | ||
| { | ||
| "base-snmp": { | ||
| "host": "yourhost", | ||
| "host": "0.0.0.0", | ||
| "community": "public", | ||
| "port": 161 | ||
| }, | ||
| "airos-snmp": { | ||
| "host": "your_airos_device", | ||
| "host": "0.0.0.0", | ||
| "community": "public", | ||
| "port": 161 | ||
| }, | ||
| "openwrt-snmp": { | ||
| "host": "your_openwrt_device", | ||
| "host": "0.0.0.0", | ||
| "community": "public", | ||
| "port": 161 | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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,3 +1,6 @@ | ||
| import json | ||
| import os | ||
|
|
||
| settings = json.loads(open('./test-settings.json').read()) | ||
| settings_file = os.getenv('TEST_SETTINGS_FILE', './test-settings.example.json') | ||
| settings = json.loads(open(settings_file).read()) | ||
| settings['disable_mocks'] = os.getenv('DISABLE_MOCKS', '0') is '1' |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@purhan this should not be necessary, please double check