Skip to content
This repository has been archived by the owner on Mar 5, 2018. It is now read-only.

test change processor handling of ints #51

Merged
merged 2 commits into from
Aug 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cct/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def _get_resource_path(self, module, resource):
def _process_environment(self, operation):
if '$' in operation.command:
operation.command = self._replace_variables(operation.command)
for i in xrange(len(operation.args)):
for i in range(len(operation.args)):
if '$' in operation.args[i]:
operation.args[i] = self._replace_variables(operation.args[i])

Expand Down
23 changes: 23 additions & 0 deletions tests/modules/dummy/dummy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""
Copyright (c) 2015 Red Hat, Inc
All rights reserved.

This software may be modified and distributed under the terms
of the MIT license. See the LICENSE file for details.
"""

import logging

from cct.module import Module

logger = logging.getLogger('cct')

class Dummy(Module):
def dump(self, *args):
"""
Dumps arguments to a logfile.

Args:
*args: Will be dumped :).
"""
logger.info("dummy module performed dump with args %s and environment: %s" % (args, self.environment ))
43 changes: 43 additions & 0 deletions tests/test_change_processor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"""
Copyright (c) 2015 Red Hat, Inc
All rights reserved.

This software may be modified and distributed under the terms
of the MIT license. See the LICENSE file for details.
"""

import os
import unittest
import mock

from cct.change_processor import ChangeProcessor

class TestModule(unittest.TestCase):
def setUp(self):
os.environ['CCT_MODULES_PATH'] = 'tests/modules'

def test_process_string_values(self):
"""
Make sure that changes that have string values are accepted
"""
config = [{
'changes': [{'dummy.Dummy': [{'dump': '493'}]}],
'name': 'dummy'
}]
changerunner = ChangeProcessor(config)
changerunner.process()


def test_process_int_values(self):
"""
Make sure that changes that have integer values are accepted
"""
config = [{
'changes': [{'dummy.Dummy': [{'dump': 493}]}],
'name': 'dummy'
}]
changerunner = ChangeProcessor(config)
changerunner.process()

if __name__ == '__main__':
unittest.main()