/srv/irclogs.ubuntu.com/2024/08/26/#cloud-init.txt

=== Juesto is now known as Juest
=== meetingology` is now known as meetingology
minimalA question about mocking, how do I mock a function that's in a __init__.py file? I'm trying to mock the add_user function17:50
minimalI've tried @mock.patch("cloudinit.distros.__init__.add_user", return_value=False)17:51
minimalif I do @mock.patch("cloudinit.distros.alpine.add_user", return_value=False) that will work ok17:53
blackboxswminimal: thanks for the updates last week on https://github.com/canonical/cloud-init/pull/5355. I'm going through this review now and will attempt to get up a couple of unittests to round out your approach there.   Per your mock question and add_user, shouldn't you be mocking cloudinit.distros.Distro.add_user not cloudinit.distros.__init__.add_user?17:59
-ubottu:#cloud-init- Pull 5355 in canonical/cloud-init "fix: cc_user_groups incorrectly assumes 'useradd' never locks password field" [Open]17:59
minimalblackboxsw: I've written some more BSD tests locally and am working on some snappy-related tests. Also intend to rebase the PR shortly18:00
blackboxswExcellent minimal. I'm going through existing unit test coverage and will raise questions here if I start writing up supplemental  tests to make sure I'm not doing work you are already addressing. One minor comment on your PR that I have already https://github.com/canonical/cloud-init/pull/5355#discussion_r1731599452 while you are touching that PR18:02
-ubottu:#cloud-init- Pull 5355 in canonical/cloud-init "fix: cc_user_groups incorrectly assumes 'useradd' never locks password field" [Open]18:02
blackboxswthx for the var renames, makes it easier to reason about that code in add_user18:02
minimalblackboxsw: seeming some strange testcase behaviour, 2 *existing* tests in tests/unittests/distro/test_create_user.py start failing whenever I add a new testfile (not testcases!) in same directory but pass fine when I remove the new testfile. That doesn't make sense to me.22:10
minimalthe same 2 tests every time: TestCreateUser.test_create_groups_with_dict_deprecated and TestCreateUser.test_explicit_sudo_false22:11
minimalthey're both failing with asserts related to deprecation caplog22:19

Generated by irclog2html.py 2.7 by Marius Gedminas - find it at mg.pov.lt!