def test_absent(): """ Test to ensure the DynamoDB table does not exist. """ name = "new_table" ret = {"name": name, "result": True, "changes": {}, "comment": ""} mock = MagicMock(side_effect=[False, True, True]) mock_bool = MagicMock(return_value=True) with patch.dict( boto_dynamodb.__salt__, {"boto_dynamodb.exists": mock, "boto_dynamodb.delete": mock_bool}, ): comt = "DynamoDB table {} does not exist".format(name) ret.update({"comment": comt}) assert boto_dynamodb.absent(name) == ret with patch.dict(boto_dynamodb.__opts__, {"test": True}): comt = "DynamoDB table {} is set to be deleted".format(name) ret.update({"comment": comt, "result": None}) assert boto_dynamodb.absent(name) == ret changes = { "new": "Table new_table deleted", "old": "Table new_table exists", } with patch.dict(boto_dynamodb.__opts__, {"test": False}): comt = "Deleted DynamoDB table {}".format(name) ret.update({"comment": comt, "result": True, "changes": changes}) assert boto_dynamodb.absent(name) == ret
def test_absent(self): ''' Test to ensure the DynamoDB table does not exist. ''' name = 'new_table' ret = {'name': name, 'result': True, 'changes': {}, 'comment': ''} mock = MagicMock(side_effect=[False, True, True]) mock_bool = MagicMock(return_value=True) with patch.dict(boto_dynamodb.__salt__, {'boto_dynamodb.exists': mock, 'boto_dynamodb.delete': mock_bool}): comt = ('DynamoDB table {0} does not exist'.format(name)) ret.update({'comment': comt}) self.assertDictEqual(boto_dynamodb.absent(name), ret) with patch.dict(boto_dynamodb.__opts__, {'test': True}): comt = ('DynamoDB table {0} is set to be deleted \ '.format(name)) ret.update({'comment': comt, 'result': None}) self.assertDictEqual(boto_dynamodb.absent(name), ret) changes = {'new': 'Table new_table deleted', 'old': 'Table new_table exists'} with patch.dict(boto_dynamodb.__opts__, {'test': False}): comt = ('Deleted DynamoDB table {0}'.format(name)) ret.update({'comment': comt, 'result': True, 'changes': changes}) self.assertDictEqual(boto_dynamodb.absent(name), ret)
def test_absent(self): ''' Test to ensure the DynamoDB table does not exist. ''' name = 'new_table' ret = {'name': name, 'result': True, 'changes': {}, 'comment': ''} mock = MagicMock(side_effect=[False, True, True]) mock_bool = MagicMock(return_value=True) with patch.dict(boto_dynamodb.__salt__, {'boto_dynamodb.exists': mock, 'boto_dynamodb.delete': mock_bool}): comt = ('DynamoDB table {0} does not exist'.format(name)) ret.update({'comment': comt}) self.assertDictEqual(boto_dynamodb.absent(name), ret) with patch.dict(boto_dynamodb.__opts__, {'test': True}): comt = 'DynamoDB table {0} is set to be deleted'.format(name) ret.update({'comment': comt, 'result': None}) self.assertDictEqual(boto_dynamodb.absent(name), ret) changes = {'new': 'Table new_table deleted', 'old': 'Table new_table exists'} with patch.dict(boto_dynamodb.__opts__, {'test': False}): comt = ('Deleted DynamoDB table {0}'.format(name)) ret.update({'comment': comt, 'result': True, 'changes': changes}) self.assertDictEqual(boto_dynamodb.absent(name), ret)