assert_called_once() failing in hook tests
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
apache2 (Juju Charms Collection) |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
I noticed a problem with the unit tests (run with 'make test'). There were 4 failures in ./hooks/
...
mock_
AttributeError: assert_called_once
...
There is no assert_called_once method. To assert that a mock method (with no params) was indeed called once, something like this could be used:
self.assertEqual(1, mock_close_
That said, i don't think this is the root of the problem. The 4 failures happened in the following test cases:
test_create_
test_create_
test_create_
test_create_
Do we expect [open|close]_port to be called during vhost creation? The purpose of these tests seems to be checking that files are created and contain expected data. I don't see why this would involve any port calls, so I think we can get rid of all [open|close]_port references from test_vhost_
I saw this the other day with charm-helpers. An old version of the mock library has been pinned in the Python virtual env, but if the newer version is installed in the system it takes precedence. Running the tests after doing 'apt get remove python-mock python3-mock' should tell you if you are seeing the same problem, or running the tests in a fresh lxc container where it was not installed in the first place.