Added unittest for arguments.py
Now a basic unittest for arguments.py is available under tests/test_arguments.py Change-Id: I5561fbcf595fc9fa45f729405748a05c82bc6253 LAUNCHPAD: https://blueprints.launchpad.net/freezer/+spec/unittest-arguments
This commit is contained in:
parent
ce996d5bac
commit
978a30ec3a
@ -1,6 +1,7 @@
|
||||
# .coveragerc to control coverage.py
|
||||
[run]
|
||||
branch = True
|
||||
omit = freezer/tests/*
|
||||
|
||||
[report]
|
||||
# Regexes for lines to exclude from consideration
|
||||
|
@ -20,6 +20,34 @@ os.environ['OS_AUTH_URL'] = 'testauthurl'
|
||||
os.environ['OS_USERNAME'] = 'testusername'
|
||||
os.environ['OS_TENANT_NAME'] = 'testtenantename'
|
||||
|
||||
|
||||
class FakeArgparse:
|
||||
|
||||
def __init__(self):
|
||||
return None
|
||||
|
||||
def __call__(self, prog='freezerc'):
|
||||
return self.ArgumentParser
|
||||
|
||||
class ArgumentParser:
|
||||
|
||||
def __init__(self, prog='freezerc'):
|
||||
return None
|
||||
|
||||
def __call__(self, *args, **kwargs):
|
||||
return self
|
||||
|
||||
@classmethod
|
||||
def add_argument(self, *args, **kwargs):
|
||||
self.container = 'testcontainer'
|
||||
self.hostname = 'testhostname'
|
||||
return True
|
||||
|
||||
@classmethod
|
||||
def parse_args(self):
|
||||
return self
|
||||
|
||||
|
||||
class FakeOpen:
|
||||
def __init__(self):
|
||||
return None
|
||||
@ -266,4 +294,3 @@ class Os:
|
||||
|
||||
def exists(self, directory=True):
|
||||
return True
|
||||
|
||||
|
20
tests/test_arguments.py
Normal file
20
tests/test_arguments.py
Normal file
@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from freezer.arguments import backup_arguments
|
||||
import argparse
|
||||
from commons import *
|
||||
|
||||
import __builtin__
|
||||
|
||||
|
||||
class TestArguments:
|
||||
|
||||
def test_arguments(self, monkeypatch):
|
||||
|
||||
fakeargparse = FakeArgparse()
|
||||
fakeargparse = fakeargparse.ArgumentParser()
|
||||
|
||||
monkeypatch.setattr(
|
||||
argparse, 'ArgumentParser', fakeargparse)
|
||||
|
||||
assert backup_arguments() is not Exception or not False
|
13
tox.ini
13
tox.ini
@ -6,14 +6,23 @@ skipsdist = True
|
||||
usedevelop = True
|
||||
deps =
|
||||
pytest
|
||||
coverage
|
||||
flake8
|
||||
pytest-cov
|
||||
pytest-xdist
|
||||
|
||||
install_command = pip install -U {opts} {packages}
|
||||
setenv = VIRTUAL_ENV={envdir}
|
||||
commands = py.test
|
||||
commands = py.test -v -n 2
|
||||
|
||||
[pytest]
|
||||
python_files = test_*.py
|
||||
norecursedirs = .tox
|
||||
|
||||
[testenv:pep8]
|
||||
commands = flake8 freezer
|
||||
|
||||
[flake8]
|
||||
show-source = True
|
||||
exclude = .venv,.tox,dist,doc,test,*egg
|
||||
exclude = .venv,.tox,dist,doc,test,*egg,tests
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user