mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge pull request #10455 from jlaska/tox_and_travis
Add tox and travis-ci support
This commit is contained in:
commit
d65e1ee2cb
8 changed files with 60 additions and 18 deletions
4
.coveragerc
Normal file
4
.coveragerc
Normal file
|
@ -0,0 +1,4 @@
|
|||
[report]
|
||||
omit =
|
||||
*/python?.?/*
|
||||
*/site-packages/nose/*
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -42,6 +42,7 @@ deb-build
|
|||
credentials.yml
|
||||
# test output
|
||||
.coverage
|
||||
.tox
|
||||
results.xml
|
||||
coverage.xml
|
||||
/test/units/cover-html
|
||||
|
|
11
.travis.yml
Normal file
11
.travis.yml
Normal file
|
@ -0,0 +1,11 @@
|
|||
sudo: false
|
||||
language: python
|
||||
env:
|
||||
- TOXENV=py26
|
||||
- TOXENV=py27
|
||||
install:
|
||||
- pip install tox
|
||||
script:
|
||||
- tox
|
||||
after_success:
|
||||
- coveralls
|
2
Makefile
2
Makefile
|
@ -93,7 +93,7 @@ NOSETESTS3 ?= nosetests-3.3
|
|||
all: clean python
|
||||
|
||||
tests:
|
||||
PYTHONPATH=./lib $(NOSETESTS) -d -w test/units -v # Could do: --with-coverage --cover-package=ansible
|
||||
PYTHONPATH=./lib $(NOSETESTS) -d -w test/units -v --with-coverage --cover-package=ansible --cover-branches
|
||||
|
||||
newtests:
|
||||
PYTHONPATH=./v2:./lib $(NOSETESTS) -d -w v2/test -v --with-coverage --cover-package=ansible --cover-branches
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
[![PyPI version](https://badge.fury.io/py/ansible.png)](http://badge.fury.io/py/ansible) [![PyPI downloads](https://pypip.in/d/ansible/badge.png)](https://pypi.python.org/pypi/ansible)
|
||||
[![PyPI version](https://badge.fury.io/py/ansible.png)](http://badge.fury.io/py/ansible)
|
||||
[![PyPI downloads](https://pypip.in/d/ansible/badge.png)](https://pypi.python.org/pypi/ansible)
|
||||
[![Build Status](https://travis-ci.org/ansible/ansible.svg?branch=tox_and_travis)](https://travis-ci.org/ansible/ansible)
|
||||
|
||||
|
||||
Ansible
|
||||
|
|
|
@ -5,3 +5,5 @@
|
|||
nose
|
||||
mock
|
||||
passlib
|
||||
coverage
|
||||
coveralls
|
||||
|
|
|
@ -1,8 +1,26 @@
|
|||
import collections
|
||||
import mock
|
||||
import os
|
||||
import re
|
||||
|
||||
from nose import tools
|
||||
from nose.tools import eq_
|
||||
try:
|
||||
from nose.tools import assert_raises_regexp
|
||||
except ImportError:
|
||||
# Python < 2.7
|
||||
def assert_raises_regexp(expected, regexp, callable, *a, **kw):
|
||||
try:
|
||||
callable(*a, **kw)
|
||||
except expected as e:
|
||||
if isinstance(regexp, basestring):
|
||||
regexp = re.compile(regexp)
|
||||
if not regexp.search(str(e)):
|
||||
raise Exception('"%s" does not match "%s"' %
|
||||
(regexp.pattern, str(e)))
|
||||
else:
|
||||
if hasattr(expected,'__name__'): excName = expected.__name__
|
||||
else: excName = str(expected)
|
||||
raise AssertionError("%s not raised" % excName)
|
||||
|
||||
from ansible.module_utils.database import (
|
||||
pg_quote_identifier,
|
||||
|
@ -70,34 +88,31 @@ class TestQuotePgIdentifier(object):
|
|||
}
|
||||
|
||||
def check_valid_quotes(self, identifier, quoted_identifier):
|
||||
tools.eq_(pg_quote_identifier(identifier, 'table'), quoted_identifier)
|
||||
eq_(pg_quote_identifier(identifier, 'table'), quoted_identifier)
|
||||
|
||||
def test_valid_quotes(self):
|
||||
for identifier in self.valid:
|
||||
yield self.check_valid_quotes, identifier, self.valid[identifier]
|
||||
|
||||
def check_invalid_quotes(self, identifier, id_type, msg):
|
||||
if hasattr(tools, 'assert_raises_regexp'):
|
||||
tools.assert_raises_regexp(SQLParseError, msg, pg_quote_identifier, *(identifier, id_type))
|
||||
else:
|
||||
tools.assert_raises(SQLParseError, pg_quote_identifier, *(identifier, id_type))
|
||||
assert_raises_regexp(SQLParseError, msg, pg_quote_identifier, *(identifier, id_type))
|
||||
|
||||
def test_invalid_quotes(self):
|
||||
for test in self.invalid:
|
||||
yield self.check_invalid_quotes, test[0], test[1], self.invalid[test]
|
||||
|
||||
def test_how_many_dots(self):
|
||||
tools.eq_(pg_quote_identifier('role', 'role'), '"role"')
|
||||
tools.assert_raises_regexp(SQLParseError, "PostgreSQL does not support role with more than 1 dots", pg_quote_identifier, *('role.more', 'role'))
|
||||
eq_(pg_quote_identifier('role', 'role'), '"role"')
|
||||
assert_raises_regexp(SQLParseError, "PostgreSQL does not support role with more than 1 dots", pg_quote_identifier, *('role.more', 'role'))
|
||||
|
||||
tools.eq_(pg_quote_identifier('db', 'database'), '"db"')
|
||||
tools.assert_raises_regexp(SQLParseError, "PostgreSQL does not support database with more than 1 dots", pg_quote_identifier, *('db.more', 'database'))
|
||||
eq_(pg_quote_identifier('db', 'database'), '"db"')
|
||||
assert_raises_regexp(SQLParseError, "PostgreSQL does not support database with more than 1 dots", pg_quote_identifier, *('db.more', 'database'))
|
||||
|
||||
tools.eq_(pg_quote_identifier('db.schema', 'schema'), '"db"."schema"')
|
||||
tools.assert_raises_regexp(SQLParseError, "PostgreSQL does not support schema with more than 2 dots", pg_quote_identifier, *('db.schema.more', 'schema'))
|
||||
eq_(pg_quote_identifier('db.schema', 'schema'), '"db"."schema"')
|
||||
assert_raises_regexp(SQLParseError, "PostgreSQL does not support schema with more than 2 dots", pg_quote_identifier, *('db.schema.more', 'schema'))
|
||||
|
||||
tools.eq_(pg_quote_identifier('db.schema.table', 'table'), '"db"."schema"."table"')
|
||||
tools.assert_raises_regexp(SQLParseError, "PostgreSQL does not support table with more than 3 dots", pg_quote_identifier, *('db.schema.table.more', 'table'))
|
||||
eq_(pg_quote_identifier('db.schema.table', 'table'), '"db"."schema"."table"')
|
||||
assert_raises_regexp(SQLParseError, "PostgreSQL does not support table with more than 3 dots", pg_quote_identifier, *('db.schema.table.more', 'table'))
|
||||
|
||||
tools.eq_(pg_quote_identifier('db.schema.table.column', 'column'), '"db"."schema"."table"."column"')
|
||||
tools.assert_raises_regexp(SQLParseError, "PostgreSQL does not support column with more than 4 dots", pg_quote_identifier, *('db.schema.table.column.more', 'column'))
|
||||
eq_(pg_quote_identifier('db.schema.table.column', 'column'), '"db"."schema"."table"."column"')
|
||||
assert_raises_regexp(SQLParseError, "PostgreSQL does not support column with more than 4 dots", pg_quote_identifier, *('db.schema.table.column.more', 'column'))
|
||||
|
|
7
tox.ini
Normal file
7
tox.ini
Normal file
|
@ -0,0 +1,7 @@
|
|||
[tox]
|
||||
envlist = py26,py27
|
||||
|
||||
[testenv]
|
||||
deps = -r{toxinidir}/test-requirements.txt
|
||||
whitelist_externals = make
|
||||
commands = make tests
|
Loading…
Reference in a new issue