Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
routersploit
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
czos-dpend
routersploit
Commits
0b4784e1
Commit
0b4784e1
authored
May 09, 2016
by
fwkz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring unit tests to utilize RoutersploitTestCase class.
parent
960f60e1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
18 deletions
+13
-18
test_completer.py
routersploit/test/test_completer.py
+3
-1
test_interpreter.py
routersploit/test/test_interpreter.py
+2
-14
test_modules.py
routersploit/test/test_modules.py
+8
-3
No files found.
routersploit/test/test_completer.py
View file @
0b4784e1
...
...
@@ -3,8 +3,10 @@ import os
import
pexpect
from
routersploit.test
import
RoutersploitTestCase
class
RoutersploitCompleterTest
(
unittest
.
TestCase
):
class
RoutersploitCompleterTest
(
RoutersploitTestCase
):
def
__init__
(
self
,
methodName
=
'runTest'
):
super
(
RoutersploitCompleterTest
,
self
)
.
__init__
(
methodName
)
...
...
routersploit/test/test_interpreter.py
View file @
0b4784e1
...
...
@@ -8,10 +8,10 @@ except ImportError:
import
mock
from
routersploit.interpreter
import
RoutersploitInterpreter
from
routersploit.
exceptions
import
RoutersploitException
from
routersploit.
test
import
RoutersploitTestCase
class
RoutersploitInterpreterTest
(
unittest
.
TestCase
):
class
RoutersploitInterpreterTest
(
Routersploit
TestCase
):
def
setUp
(
self
):
RoutersploitInterpreter
.
setup
=
mock
.
Mock
()
...
...
@@ -39,18 +39,6 @@ class RoutersploitInterpreterTest(unittest.TestCase):
getattr
(
self
.
interpreter
,
'_{}__parse_prompt'
.
format
(
self
.
interpreter
.
__class__
.
__name__
))()
def
assertIsDecorated
(
self
,
function
,
decorator_name
):
try
:
decorator_list
=
function
.
__decorators__
except
AttributeError
:
decorator_list
=
[]
self
.
assertIn
(
decorator_name
,
decorator_list
,
msg
=
"'{}' method should be decorated with 'module_required'"
.
format
(
function
.
__name__
)
)
@mock.patch
(
'routersploit.utils.print_success'
)
def
test_command_set
(
self
,
mock_print_success
):
rhost
,
new_rhost_value
=
'rhost_value'
,
"new_rhost_value"
...
...
routersploit/test/test_modules.py
View file @
0b4784e1
import
unittest
from
routersploit.utils
import
iter_modules
from
routersploit.test
import
RoutersploitTestCase
class
ModuleTest
(
unittest
.
TestCase
):
class
ModuleTest
(
Routersploit
TestCase
):
"""A test case that every module must pass.
Attributes:
...
...
@@ -32,6 +33,11 @@ class ModuleTest(unittest.TestCase):
)
self
.
assertItemsEqual
(
required_metadata
,
self
.
module_metadata
.
keys
())
def
test_metadata_type
(
self
):
self
.
assertIsSequence
(
self
.
module_metadata
[
'authors'
])
self
.
assertIsSequence
(
self
.
module_metadata
[
'references'
])
self
.
assertIsSequence
(
self
.
module_metadata
[
'devices'
])
def
load_tests
(
loader
,
tests
,
pattern
):
""" Map every module to a test case, and group them into a suite. """
...
...
@@ -44,4 +50,4 @@ def load_tests(loader, tests, pattern):
if
__name__
==
'__main__'
:
unittest
.
main
()
\ No newline at end of file
unittest
.
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment