def test_update_groups(self, mocker): client = mocker.Mock() client.put.side_effect = [ http.Response(201, ''), http.Response(201, ''), ] client.delete.side_effect = [ http.Response(204, ''), http.Response(204, ''), ] result = user.update_groups( client, '/path', ['a', 'b', 'c'], ['e', 'd', 'c'], False, ) assert result is True client.put.assert_has_calls([ mocker.call('/path/groups/d', None), mocker.call('/path/groups/e', None), ], any_order=True) client.delete.assert_has_calls([ mocker.call('/path/groups/a'), mocker.call('/path/groups/b'), ], any_order=True)
def test_update_groups_check_mode(self, mocker): client = mocker.Mock() result = user.update_groups( client, '/path', ['a', 'b', 'c'], ['e', 'd', 'c'], True, ) assert result is True client.put.assert_not_called() client.delete.assert_not_called()
def test_update_groups_no_change(self, mocker, check): client = mocker.Mock() result = user.update_groups( client, '/path', ['a', 'b'], ['b', 'a'], check, ) assert result is False client.put.assert_not_called() client.delete.assert_not_called()