Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
illfelder committed Dec 13, 2016
2 parents 20ea00e + 36cb06e commit c4793ea
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 5 deletions.
2 changes: 1 addition & 1 deletion google_compute_engine/ip_forwarding/ip_forwarding_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def ParseForwardedIps(self, forwarded_ips):
forwarded_ips = forwarded_ips or []
for ip in forwarded_ips:
if ip and (IP_REGEX.match(ip) or IP_ALIAS_REGEX.match(ip)):
addresses.append(ip)
addresses.append(ip[:-3] if ip.endswith('/32') else ip)
else:
self.logger.warning('Could not parse IP address: "%s".', ip)
return addresses
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"""Unittest for ip_forwarding_utils.py module."""

from google_compute_engine.ip_forwarding import ip_forwarding_utils
from google_compute_engine.test_compat import builtin
from google_compute_engine.test_compat import mock
from google_compute_engine.test_compat import unittest

Expand Down Expand Up @@ -152,6 +151,17 @@ def testParseForwardedIpsComplex(self):
expected_calls = [mock.call.warning(mock.ANY, ip) for ip in invalid_ips]
self.assertEqual(self.mock_logger.mock_calls, expected_calls)

def testParseForwardedIpsSubnet(self):
forwarded_ips = {
'1.1.1.1': '1.1.1.1',
'1.1.1.1/32': '1.1.1.1',
'1.1.1.1/1': '1.1.1.1/1',
'1.1.1.1/10': '1.1.1.1/10',
'1.1.1.1/24': '1.1.1.1/24',
}
for ip, value in forwarded_ips.items():
self.assertEqual(self.mock_utils.ParseForwardedIps([ip]), [value])

def testGetForwardedIps(self):
mock_options = mock.Mock()
mock_options.return_value = self.options
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
packages=setuptools.find_packages(),
scripts=glob.glob('scripts/*'),
url='https://github.com/GoogleCloudPlatform/compute-image-packages',
version='2.3.1',
version='2.3.2',
# Entry points create scripts in /usr/bin that call a function.
entry_points={
'console_scripts': [
Expand Down
31 changes: 29 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,37 @@ commands =
-v \
{posargs:.}

# Note: currently disabled.
[testenv:lint]
deps =
flake8
flake8-import-order
commands =
flake8 --exclude=env --import-order-style=google
flake8 --import-order-style=google

[flake8]
# Temporarly disabling warnings until code is flake8 compliant.
# E111 indentation is not a multiple of four
# E114 indentation is not a multiple of four (comment)
# E121 continuation line under-indented for hanging indent
# E125 continuation line with same indent as next logical line
# E128 continuation line under-indented for visual indent
# E129 visually indented line with same indent as next logical line
# E226 missing whitespace around arithmetic operator
# E231 missing whitespace after ','
# E261 at least two spaces before inline comment
# E302 expected 2 blank lines, found 1
# E501 line too long
# F401 imported but unused
ignore = E111,E114,E121,E125,E128,E129,E226,E231,E261,E302,E501,F401
exclude =
.git,
.tox,
__pycache__,
dist,
env

# This section configures tox-travis.
# See https://github.com/ryanhiebert/tox-travis#advanced-configuration
[travis]
python =
2.7: py27, lint

0 comments on commit c4793ea

Please sign in to comment.