Skip to content

Commit

Permalink
Include calico.py and ipam.py in coverage reports
Browse files Browse the repository at this point in the history
  • Loading branch information
Casey D committed Feb 26, 2016
1 parent 4386319 commit 7c0a029
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion nose.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[nosetests]
with-coverage=1
cover-erase=1
cover-package=calico_cni
cover-package=calico_cni,calico,ipam
28 changes: 28 additions & 0 deletions tests/unit/test_cni_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,34 @@ def test_assign_ip_no_ip(self):
e = err.exception
assert_equal(e.code, ERR_CODE_GENERIC)

def test_assign_ip_invalid_ip4(self):
# Mock _call_ipam_plugin.
rc = 0
ipam_result = json.dumps({"ip4": {"ip": "somebadip4"}})
self.plugin._call_ipam_plugin = MagicMock(spec=self.plugin._call_ipam_plugin)
self.plugin._call_ipam_plugin.return_value = rc, ipam_result
env = {CNI_COMMAND_ENV: CNI_CMD_ADD}

# Call _assign_ips.
with assert_raises(SystemExit) as err:
self.plugin._assign_ips(env)
e = err.exception
assert_equal(e.code, ERR_CODE_GENERIC)

def test_assign_ip_invalid_ip6(self):
# Mock _call_ipam_plugin.
rc = 0
ipam_result = json.dumps({"ip6": {"ip": "somebadip6"}})
self.plugin._call_ipam_plugin = MagicMock(spec=self.plugin._call_ipam_plugin)
self.plugin._call_ipam_plugin.return_value = rc, ipam_result
env = {CNI_COMMAND_ENV: CNI_CMD_ADD}

# Call _assign_ips.
with assert_raises(SystemExit) as err:
self.plugin._assign_ips(env)
e = err.exception
assert_equal(e.code, ERR_CODE_GENERIC)

def test_release_ip_mainline(self):
# Mock _call_ipam_plugin.
rc = 0
Expand Down

0 comments on commit 7c0a029

Please sign in to comment.