def test_present_absent(docker_cmd_run_all_wrapper, rabbitmq_container): """ Test rabbitmq_user.present Create user then delete it. """ # Clear the user ret = rabbitmq_user.present("myuser") expected = { "name": "myuser", "result": True, "comment": "'myuser' was configured.", "changes": {"user": {"old": "", "new": "myuser"}}, } assert ret == expected # Delete the user ret = rabbitmq_user.absent("myuser") expected = { "name": "myuser", "result": True, "comment": "The user 'myuser' was removed.", "changes": {"name": {"old": "myuser", "new": ""}}, } assert ret == expected
def test_absent(docker_cmd_run_all_wrapper, rabbitmq_container): """ Test rabbitmq_user.absent """ # Delete the user ret = rabbitmq_user.absent("myuser") expected = { "name": "myuser", "result": True, "comment": "The user 'myuser' is not present.", "changes": {}, } assert ret == expected
def test_absent(self): ''' Test to ensure the named user is absent. ''' name = 'foo' ret = {'name': name, 'changes': {}, 'result': True, 'comment': 'The user \'foo\' is not present.'} mock = MagicMock(return_value=False) with patch.dict(rabbitmq_user.__salt__, {'rabbitmq.user_exists': mock}): self.assertDictEqual(rabbitmq_user.absent(name), ret)