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

Commit

Permalink
Merge pull request #51 from jmtd/test-change-processor
Browse files Browse the repository at this point in the history
test change processor handling of ints
  • Loading branch information
rwngwn committed Aug 15, 2016
2 parents 84f46e7 + cd04e00 commit 7c3e919
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 1 deletion.
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()

0 comments on commit 7c3e919

Please sign in to comment.