configurationengine/source/plugins/common/ConeCommandPlugin/commandplugin/tests/unittest_commandml_plugin.py
changeset 3 e7e0ae78773e
parent 0 2e8eeb919028
--- a/configurationengine/source/plugins/common/ConeCommandPlugin/commandplugin/tests/unittest_commandml_plugin.py	Fri Mar 12 08:30:17 2010 +0200
+++ b/configurationengine/source/plugins/common/ConeCommandPlugin/commandplugin/tests/unittest_commandml_plugin.py	Tue Aug 10 14:29:28 2010 +0300
@@ -16,12 +16,10 @@
 
 import unittest, os, shutil
 
-import __init__	
-from cone.public import exceptions,plugin,api
+# import __init__	
+from cone.public import plugin, api, utils
 from cone.storage import filestorage
-from cone.confml import implml
 from testautomation.base_testcase import BaseTestCase
-from commandplugin import commandml
 
 # Hardcoded value of testdata folder that must be under the current working dir
 ROOT_PATH = os.path.dirname(os.path.abspath(__file__))
@@ -41,27 +39,35 @@
         try:
             OUTPUT_DIR = os.path.join(ROOT_PATH, 'output')
             self.remove_if_exists(OUTPUT_DIR)
+            self.remove_if_exists(['hello.log', 'exec_in_output_test.log',])
             
             fs = filestorage.FileStorage(testdata)
             p = api.Project(fs)
             config = p.get_configuration('product.confml')
+            context = plugin.GenerationContext(configuration=config,
+                                               output=OUTPUT_DIR)
             impls = plugin.get_impl_set(config,'file2\.commandml$')
-            impls.output = OUTPUT_DIR
-            impls.generate()
+            #impls.output = OUTPUT_DIR
+            impls.generate(context)
             
             self.assert_file_content_equals('hello.log',
-                "Hello\r\n" +
-                "Cmd line args: ['-c', 'some_config.txt', '-d', 'some_dir', '-x']\r\n" +
-                "Env: {'MYVAR': '123'}\r\n")
+                "Hello" + os.linesep +
+                "Cmd line args: ['-c', 'some_config.txt', '-d', 'some_dir', '-x']" + os.linesep)
             
             self.assert_file_content_equals('exec_in_output_test.log',
-                os.path.normpath(OUTPUT_DIR) + '\r\n')
+                os.path.normpath(OUTPUT_DIR) + os.linesep)
             
             # Check that the log file of the command that should not be
             # executed does not exist
             self.assertFalse(os.path.exists("should_not_be_created.log"))
+            self.assertTrue(os.path.exists(os.path.join(OUTPUT_DIR,"helloworld.txt")))
+            
+            self.assertEquals(len(context.generation_output), 1)
+            self.assertEquals(utils.relpath(context.generation_output[0].name, OUTPUT_DIR), 'helloworld.txt')
+            self.assertEquals(context.generation_output[0].implementation.ref, 'assets/s60/implml/file2.commandml')
         finally:
             os.chdir(orig_workdir)
+
         
 if __name__ == '__main__':
   unittest.main()