def test_absent(self): """ Test to ensure that the named database is absent. """ name = "salt" ret = {"name": name, "result": None, "comment": "", "changes": {}} mock = MagicMock(side_effect=[True, True, True, False]) mock_t = MagicMock(side_effect=[True, False]) with patch.dict( influxdb08_database.__salt__, { "influxdb08.db_exists": mock, "influxdb08.db_remove": mock_t }, ): with patch.dict(influxdb08_database.__opts__, {"test": True}): comt = "Database {0} is present and needs to be removed".format( name) ret.update({"comment": comt}) self.assertDictEqual(influxdb08_database.absent(name), ret) with patch.dict(influxdb08_database.__opts__, {"test": False}): comt = "Database {0} has been removed".format(name) ret.update({ "comment": comt, "result": True, "changes": { "salt": "Absent" } }) self.assertDictEqual(influxdb08_database.absent(name), ret) comt = "Failed to remove database {0}".format(name) ret.update({"comment": comt, "result": False, "changes": {}}) self.assertDictEqual(influxdb08_database.absent(name), ret) comt = "Database {0} is not present, so it cannot be removed".format( name) ret.update({"comment": comt, "result": True}) self.assertDictEqual(influxdb08_database.absent(name), ret)
def test_absent(self): ''' Test to ensure that the named database is absent. ''' name = 'salt' ret = {'name': name, 'result': None, 'comment': '', 'changes': {}} mock = MagicMock(side_effect=[True, True, True, False]) mock_t = MagicMock(side_effect=[True, False]) with patch.dict(influxdb08_database.__salt__, { 'influxdb08.db_exists': mock, 'influxdb08.db_remove': mock_t }): with patch.dict(influxdb08_database.__opts__, {'test': True}): comt = ('Database {0} is present and needs to be removed'. format(name)) ret.update({'comment': comt}) self.assertDictEqual(influxdb08_database.absent(name), ret) with patch.dict(influxdb08_database.__opts__, {'test': False}): comt = ('Database {0} has been removed'.format(name)) ret.update({ 'comment': comt, 'result': True, 'changes': { 'salt': 'Absent' } }) self.assertDictEqual(influxdb08_database.absent(name), ret) comt = ('Failed to remove database {0}'.format(name)) ret.update({'comment': comt, 'result': False, 'changes': {}}) self.assertDictEqual(influxdb08_database.absent(name), ret) comt = ('Database {0} is not present, so it cannot be removed'. format(name)) ret.update({'comment': comt, 'result': True}) self.assertDictEqual(influxdb08_database.absent(name), ret)
def test_absent(self): ''' Test to ensure that the named database is absent. ''' name = 'salt' ret = {'name': name, 'result': None, 'comment': '', 'changes': {}} mock = MagicMock(side_effect=[True, True, True, False]) mock_t = MagicMock(side_effect=[True, False]) with patch.dict(influxdb08_database.__salt__, {'influxdb08.db_exists': mock, 'influxdb08.db_remove': mock_t}): with patch.dict(influxdb08_database.__opts__, {'test': True}): comt = ('Database {0} is present and needs to be removed' .format(name)) ret.update({'comment': comt}) self.assertDictEqual(influxdb08_database.absent(name), ret) with patch.dict(influxdb08_database.__opts__, {'test': False}): comt = ('Database {0} has been removed'.format(name)) ret.update({'comment': comt, 'result': True, 'changes': {'salt': 'Absent'}}) self.assertDictEqual(influxdb08_database.absent(name), ret) comt = ('Failed to remove database {0}'.format(name)) ret.update({'comment': comt, 'result': False, 'changes': {}}) self.assertDictEqual(influxdb08_database.absent(name), ret) comt = ('Database {0} is not present, so it cannot be removed' .format(name)) ret.update({'comment': comt, 'result': True}) self.assertDictEqual(influxdb08_database.absent(name), ret)