def test_import_to_zipstorage_multiple_configurations(self): imported_zip = os.path.join(temp_dir, "imported2.zip") fs = FileStorage(datafolder) p = api.Project(fs) zs = ZipStorage(imported_zip, "w") zp = api.Project(zs) conf = p.get_configuration('morestuff.confml') conf_files = conf.list_resources() zp.import_configuration(conf) conf = p.get_configuration('prodX.confml') conf_files.extend(conf.list_resources()) zp.import_configuration(conf) zp.close() p.close() self.assertTrue(os.path.exists(imported_zip)) zfile = zipfile.ZipFile(imported_zip, "r") files = zfile.namelist() files.remove('.metadata') conf_files = utils.distinct_array(conf_files) conf_files.sort() files.sort() for i in range(len(conf_files)): self.assertEquals(conf_files[i], files[i]) zfile.close() os.unlink(imported_zip)
def generate(self, context=None): """ Generate the given implementation. """ #Generating content fullOutputPath = os.path.join(context.output, self.output) if self.project_data.has_key("path"): targetPath = utils.resourceref.norm(self.project_data["path"]) if targetPath and targetPath != "": fullOutputPath = os.path.join(context.output, fullOutputPath, targetPath) fs = filestorage.FileStorage(fullOutputPath, "w") newProject = api.Project(fs) for layer in self.layers: layer.generate(newProject, self.configuration.get_storage().get_path()) newProject.close() #Opening project again to validate the content and remove illegal includes. if self.project_data.has_key("validate") and self.project_data["validate"] != "false": fs = filestorage.FileStorage(fullOutputPath, "w") validateProject = api.Project(fs) for conf in validateProject.list_configurations(): validateProject.get_configuration(conf).list_all_configurations() validateProject.close() return
def test_import_to_zipstorage(self): test_project_dir = os.path.join(temp_dir, "test_project_1") unzip_file.unzip_file(test_cpf, test_project_dir, delete_if_exists=True) imported_zip = os.path.join(temp_dir, "imported1.zip") fs = FileStorage(test_project_dir) p = api.Project(fs) zs = ZipStorage(imported_zip, "w") zp = api.Project(zs) conf = p.get_configuration('root5.confml') conf_files = conf.list_resources() conf_files.append('.metadata') zp.import_configuration(conf) zp.close() p.close() self.assertTrue(os.path.exists(imported_zip)) zfile = zipfile.ZipFile(imported_zip, "r") files = zfile.namelist() conf_files.sort() files.sort() self.assertEquals(conf_files, files) zfile.close() os.unlink(imported_zip)
def test_export_with_include_content_filter(self): include_content_filter = ".*layer4.*" include_filters = {'content': include_content_filter} test_project_dir = os.path.join(temp_dir, "test_project_1") unzip_file.unzip_file(test_cpf, test_project_dir, delete_if_exists=True) export_zip = os.path.join(temp_dir, "configexport.zip") fs = FileStorage(test_project_dir) p = api.Project(fs) conf = p.get_configuration('root5.confml') zs = ZipStorage(export_zip, "w") zp = api.Project(zs) p.export_configuration(conf, zs, include_filters=include_filters) zp.close() zs = ZipStorage(export_zip, "r") zp = api.Project(zs) conf = zp.get_configuration('root5.confml') rel = conf.get_layer().list_all_related() exp = [ 'Layer1/implml/bitmask_test_12341002.crml', 'Layer1/implml/feature1_12341000.crml', 'Layer1/implml/feature1_12341001.crml', 'Layer1/implml/feature1_sequence.gcfml', 'Layer1/implml/feature2_ABCD0000.crml', 'Layer1/implml/time_types_test_12341003.crml', 'Layer4/content/seq/layer4_file.txt' ] zs.close() self.assertEquals(exp, rel) os.unlink(export_zip)
def test_export_to_zipstorage(self): test_project_dir = os.path.join(temp_dir, "test_project_1") unzip_file.unzip_file(test_cpf, test_project_dir, delete_if_exists=True) export_zip = os.path.join(temp_dir, "configexport.zip") fs = FileStorage(test_project_dir) p = api.Project(fs) conf = p.get_configuration('root5.confml') zs = ZipStorage(export_zip, "w") zp = api.Project(zs) conf_files = conf.list_resources() files1 = ['.metadata'] files1.extend(conf_files) p.export_configuration(conf, zs) zp.close() self.assertTrue(os.path.exists(export_zip)) zfile = zipfile.ZipFile(export_zip, "r") files2 = zfile.namelist() zfile.close() files1.sort() files2.sort() for i in range(len(files1)): self.assertEquals(files1[i], files2[i]) os.unlink(export_zip)
def test_export_from_zip_to_zipstorage_add(self): export_zip = os.path.join(temp_dir, "configexport2.zip") zs_source = ZipStorage(test_cpf, 'r') p = api.Project(zs_source) exportconf = p.get_configuration('root4.confml') compareconf = p.get_configuration('root5.confml') zs_target = ZipStorage(export_zip, "w") zp = api.Project(zs_target) conf_files = compareconf.list_resources() files1 = ['.metadata'] files1.extend(conf_files) p.export_configuration(exportconf, zs_target) zp.close() self.assertTrue(os.path.exists(export_zip)) #Re-opening in append mode for adding new layers. zs_target = ZipStorage(export_zip, "a") zp = api.Project(zs_target) conf = p.get_configuration('Layer5/root.confml') p.export_configuration(conf, zs_target) zp.save() zp.close() zfile = zipfile.ZipFile(export_zip, "r") files2 = zfile.namelist() #Root file renaming. files2[files2.index('root4.confml')] = 'root5.confml' zfile.close() files1.sort() files2.sort() for i in range(len(files1)): self.assertEquals(files1[i], files2[i]) os.unlink(export_zip)
def test_create_close_open_configuration(self): tempdir_orig = os.path.normpath(os.path.join(temp_dir, "temp1_orig")) tempdir_copy = os.path.normpath(os.path.join(temp_dir, "temp1_copy")) self.remove_if_exists([tempdir_orig, tempdir_copy]) project = api.Project(api.Storage.open(tempdir_orig, "w")) conf = project.create_configuration("dummy2.confml") conf.set_name("dummy") prop1 = model.ConfmlMetaProperty('owner', 'some guy') prop2 = model.ConfmlMetaProperty('purpose', 'for testing') conf.meta = model.ConfmlMeta([prop1, prop2]) conf.desc = "Testing to see a configuration created" conf.create_configuration("test/path/to/somewhere/r.confml") conf.create_configuration("test/path/to/elsewhere/r.confml") conf.save() project.save() project.close() # Make a copy of the created directory shutil.copytree(tempdir_orig, tempdir_copy) # If everything has been closed properly, the original directory # should now be removable shutil.rmtree(tempdir_orig) project2 = api.Project(api.Storage.open(tempdir_copy)) conf2 = project2.get_configuration("dummy2.confml") self.assertEquals(conf.get_name(), conf2.get_name()) self.assertEquals(conf2.get_name(), 'dummy') self.assertEquals(conf2.meta[0].tag, 'owner') self.assertEquals(conf2.meta[0].value, 'some guy') self.assertEquals(conf.desc, conf2.desc) self.assertEquals(conf.list_configurations(), conf2.list_configurations()) project2.close()
def test_export_from_zipstorage(self): output_dir = os.path.join(temp_dir, "export_from_zipstorage") self.remove_if_exists(output_dir) zs = ZipStorage(test_cpf, "r") p = api.Project(zs) fs = FileStorage(output_dir, "w") r = api.Project(fs) conf = p.get_configuration('root5.confml') conf_files = conf.list_resources() conf_files.append('.metadata') p.export_configuration(conf, fs) p.close() r.close() self.assertTrue(os.path.exists(output_dir))
def test_generate(self): orig_workdir = os.getcwd() os.chdir(ROOT_PATH) 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(context) self.assert_file_content_equals('hello.log', "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) + 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)
def test_get_ApDnContainer(self): project = api.Project( api.Storage.open(os.path.join(ROOT_PATH, 'ruleproject'))) config = project.get_configuration('root.confml') dview = config.get_default_view() container = accesspoint_id_counter._get_ApDnContainer_( dview.get_feature("APs"), dview.get_feature("DNs"), True) self.assertEquals('Internet', container.get_all_dns()[0].get_name()) self.assertEquals('1', container.get_all_dns()[0].get_id()) self.assertEquals([ 'IAP11', 'IAP12', 'IAP13', None, None, None, None, None, None, None ], container.get_all_dns()[0].get_iaps()) self.assertEquals('MMS', container.get_all_dns()[1].get_name()) self.assertEquals('2', container.get_all_dns()[1].get_id()) self.assertEquals([ 'IAP21', 'IAP22', 'IAP23', 'IAP13', None, None, None, None, None, None ], container.get_all_dns()[1].get_iaps()) self.assertEquals('Operator', container.get_all_dns()[2].get_name()) self.assertEquals('3', container.get_all_dns()[2].get_id()) self.assertEquals([ 'IAP31', 'IAP32', 'IAP33', None, None, None, None, None, None, None ], container.get_all_dns()[2].get_iaps()) self.assertEquals('IAP11', container.get_all_aps()[0].get_name()) self.assertEquals('1', container.get_all_aps()[0].get_id())
def test_generate_delta_cenreps(self): project_dir = abspath('gen_project') config = 'root2.confml' output_dir = abspath('temp/gen_output_deltacenrep') expected_dir = abspath('gen_expected_deltacenrep') self.remove_if_exists(output_dir) prj = api.Project(api.Storage.open(project_dir)) config = prj.get_configuration(config) gc = plugin.GenerationContext(configuration=config, output=output_dir) # Get refs from the last layer layer = config.get_configuration_by_index(-1) refs = utils.distinct_array(layer.list_leaf_datas()) impls = plugin.get_impl_set(config, 'crml$') impls = impls | plugin.get_impl_set(config, 'implml$') impls = impls.filter_implementations(refs=refs) gc.tags['crml'] = ['deltacenrep'] gc.changed_refs = refs gc.filtering_disabled = True impls.generate(gc) impls.post_generate(gc) output_dir = os.path.join(output_dir, 'deltacenreps') self.assert_dir_contents_equal(output_dir, expected_dir, ['.svn'])
def test_impl_container_execute_pre_rules(self): project = api.Project( api.Storage.open(os.path.join(ROOT_PATH, 'ruleproject/rules'), "a")) config = project.get_configuration('root.confml') implcontainer = plugin.get_impl_set(config, 'ruleml$') ruleimpl = implcontainer.get_implementations_by_file( 'implml/container_with_rules.ruleml')[0] context = plugin.GenerationContext(configuration=config) context.phase = "pre" ruleimpl.generate(context) lastconfig = config.get_last_configuration() self.assertEquals(lastconfig.get_path(), plugin.AUTOCONFIG_CONFML) self.assertEquals(lastconfig.list_all_datas(), [ 'imakerapi', 'imakerapi.outputLocation', 'StringConcatenationTest', 'StringConcatenationTest.Result1', 'StringConcatenationTest.Result2' ]) self.assertEquals( lastconfig.get_data('imakerapi.outputLocation').get_ref(), 'outputLocation') self.assertEquals( lastconfig.get_data('imakerapi.outputLocation').get_value(), '2') project.close()
def test_rules_get_refs(self): project = api.Project(api.Storage.open(os.path.join(ROOT_PATH,'ruleproject/rules'), "a" )) config = project.get_configuration('root.confml') implcontainer = plugin.get_impl_set(config, 'ruleml$') ruleimpl = implcontainer.get_implementations_by_file('implml/container_with_rules.ruleml')[0] self.assertEquals(ruleimpl.get_child_refs(), [u'imakerapi.PRODUCT_NAME', u'imaker.imagetarget']) self.assertEquals(len(ruleimpl.get_outputs()), 8) outputs = [output.name for output in ruleimpl.get_outputs()] self.assertEquals(outputs, [u'imakerapi.PRODUCT_NAME', u'imakerapi.outputLocation', u'StringConcatenationTest.Result1', u'StringConcatenationTest.Result2', u'StringConcatenationTest.Result3', u'StringConcatenationTest.Result4', u'StringConcatenationTest.Result5', u'StringConcatenationTest.Result6']) inputs = [] for output in ruleimpl.get_outputs(): inputs += output.implementation.get_refs() self.assertEquals(inputs, [u'imakerapi.PRODUCT_NAME', u'imaker.imagetarget']) impls_refs = [] for output in ruleimpl.get_outputs(): impls_refs.append("%s <= %s" % (output.name, output.implementation.implml.ref)) self.assertEquals(impls_refs, [u'imakerapi.PRODUCT_NAME <= implml/container_with_rules.ruleml', u'imakerapi.outputLocation <= implml/container_with_rules.ruleml', u'StringConcatenationTest.Result1 <= implml/container_with_rules.ruleml', u'StringConcatenationTest.Result2 <= implml/container_with_rules.ruleml', u'StringConcatenationTest.Result3 <= implml/container_with_rules.ruleml', u'StringConcatenationTest.Result4 <= implml/container_with_rules.ruleml', u'StringConcatenationTest.Result5 <= implml/container_with_rules.ruleml', u'StringConcatenationTest.Result6 <= implml/container_with_rules.ruleml'])
def test_layered_resources_custom_folder(self): p = api.Project(api.Storage.open(LAYERED_RES_PROJECT)) config = p.get_configuration('root.confml') data = config.layered_resources(folder='foo').data self.assertEquals(data, {'bar.txt': ['layer1/foo/bar.txt', 'layer2/foo/bar.txt']})
def test_configuration_parse_and_filter_implementation_with_tags(self): fs = filestorage.FileStorage(testdata) p = api.Project(fs) config = p.get_configuration('product.confml') impls = plugin.get_impl_set(config, '\.content$') impls_rofs3 = impls.filter_implementations(tags={'target': ['rofs3']}) self.assertEquals(len(list(impls_rofs3)), 3)
def test_prepare_active_themes(self): project = api.Project(api.Storage.open(os.path.join(ROOT_PATH, "e75"))) config = project.get_configuration("root_variant.confml") impl = impl_from_resource("variant/implml/theme.thememl", config) list_tpf = impl.list_tpf_files(impl.list_active_theme, impl.list_theme_dir) container = ThemeContainer(list_tpf, impl.configuration) container.create_themes() def get_theme(lst, tpf_path): for theme in lst: if theme.tpf_path == tpf_path: return theme self.fail("Theme with tpf_path = %r not found!" % tpf_path) self.assertEquals(len(container.list_theme), 2) theme = get_theme(container.list_theme, 'variant/content/UI/Themes/Armi.tpf') self.assertEquals(theme.get_setting_uids(), []) self.assertEquals(theme.get_uid(), None) container.prepare_active_themes(impl.list_active_theme) theme = get_theme(container.list_theme, 's60/content/UI/Armi2.tpf') self.assertEquals(theme.get_setting_uids(), ["KCRUidPersonalisation.KPslnActiveSkinUid"]) self.assertEquals(theme.get_uid(), "0x101FD60A")
def test_create_generator_with_extraparams(self): prj = api.Project(api.Storage.open(os.path.join(ROOT_PATH,"imageproject"))) config = prj.get_configuration('product.confml') dview = config.get_default_view() impl = impl_from_resource('variant/implml/startupmif_animation_with_version.imageml', config) # 1st impl self.assertEquals(impl.generators[0].extraparams, '/V3') # Assert the the extraparams is actually used in the command command_obj = impl.generators[0].get_command() cmd = command_obj.get_command(command_obj._get_filtered_input_files()) self.assertEquals(len(cmd), 6) self.assertEquals(cmd[2], r'/V3') # 2nd impl self.assertEquals(impl.generators[1].extraparams, '${StartupSettings.PluginTimeout}') self.assertEquals(utils.expand_refs_by_default_view(impl.generators[1].extraparams, dview), '30000') # Assert the the extraparams is actually used in the command command_obj = impl.generators[1].get_command() cmd = command_obj.get_command(command_obj._get_filtered_input_files()) self.assertEquals(len(cmd), 6) self.assertEquals(cmd[2], r'30000') # 3rd impl self.assertEquals(impl.generators[2].extraparams, '${StartupSettings.PluginTimeout}') self.assertEquals(utils.expand_refs_by_default_view(impl.generators[1].extraparams, dview), '30000') # Assert the the extraparams is actually used in the command command_obj = impl.generators[2].get_command() cmd = command_obj.get_command(command_obj._get_filtered_input_files()) self.assertEquals(len(cmd), 4) self.assertEquals(cmd[1], r'30000')
def test_flat(self): ''' Test that the configuration flattening works ''' fs = filestorage.FileStorage(testdata) p = api.Project(fs) config = p.get_configuration('product.confml') flat = p.create_configuration('flat.confml') dview = config.get_default_view() for fea in dview.get_features('**'): newfea = copy.copy(fea._obj) flat.add_feature(newfea, fea.namespace) toview = flat.get_default_view() for fea in toview.get_features('**'): fromfea = dview.get_feature(fea.fqr) if fromfea.get_value() != None: fea.set_value(fromfea.get_value()) flat.close() config.close() config = p.get_configuration('product.confml') flat = p.get_configuration('flat.confml') fdview = flat.get_default_view() for fea in config.get_default_view().get_features('**'): self.assertEquals(fea.get_value(), fdview.get_feature(fea.fqr).get_value()) pass
def run(self): filter = ProblemTypeFilter(includes=self.include_filter, excludes=self.exclude_filter) # Open the project if it is not already opened if self.project == None: storage = api.Storage.open(self.project_name, "a", username=self.username, password=self.password) self.project = api.Project(storage) if self.config == None: if not self.configuration_name: logging.getLogger('cone').error( "No configuration given! Use -c / --configuration") return False try: self.config = self.project.get_configuration( self.configuration_name) except exceptions.NotFound: logging.getLogger('cone').error("No such configuration: %s" % self.configuration_name) return False fixers = confmlvalidation.get_fixer_classes(filter) vc = confmlvalidation.fix_configuration(self.config, None, fixers) if vc.fixes: print "Fixed %d problem(s). See log for details" % len(vc.fixes) else: print "No problems to fix found. See log for details" return True
def __init__(self, filename): # Read data from CPF by using VBR reporting tools self.inputfilename = filename #self.datastructure = read_configuration_dict(filename) with closing(CPFReader(filename)) as reader: self.datastructure = reader.read_configuration_dict() rootname = reader.get_active_root() #with open('test_map.txt', 'w') as f: pprint.pprint(self.datastructure, stream=f) # Create root for XML self.root = etree.Element(TESTAUTOMATION_REF) # Create metadata with timestamp self.metadata = etree.SubElement(self.root, METADATA_REF) self.AddCpf2XmlMetadataToOutputXml() # Create layers element self.layers = etree.SubElement(self.root, LAYERS_REF) # Create cone APIs # Create a new storage to a cpf file and give it to the project. project = api.Project(api.Storage.open(self.inputfilename, 'r')) # Find resource of root file config = project.get_configuration(rootname) config_root = config.get_root_configuration() self.dview = config_root.get_default_view() # Create view list for settings self.view = config_root.get_view(config_root.list_views()[0]) self.settingviewdict = {} self.PopulateViewDict() self.featurelistForManifest = [] project.close()
def _get_project_and_config(self, workdir, storage_type): # Create the working directory for the test self.remove_if_exists(workdir) os.makedirs(workdir) # Unpack or copy the project into the working directory project_source_zip = os.path.join(TESTDATA_DIR, 'emptydircopy/project.zip') if storage_type == 'fs': project_location = os.path.join(workdir, 'project') unzip_file(project_source_zip, project_location) elif storage_type == 'zs': project_location = os.path.join(workdir, 'project.zip') shutil.copy(project_source_zip, project_location) else: raise ValueError('Invalid storage type %r' % storage_type) # Copy the external content directory unzip_file( os.path.join(TESTDATA_DIR, 'emptydircopy/external_content.zip'), os.path.join(workdir, 'external_content')) project = api.Project(api.Storage.open(project_location, 'r')) config = project.get_configuration('root.confml') return project, config
def test_changed_on_last_layer(self): project = api.Project(api.Storage.open(os.path.join(ROOT_PATH,'layerproject'))) config = project.get_configuration('root.confml') dview = config.get_default_view() self.assertTrue(layer_utils.changed_on_last_layer(dview.get_feature("StringFeatureTest.Value1"))) self.assertFalse(layer_utils.changed_on_last_layer(dview.get_feature("StringFeatureTest.Value2")))
def test_layered_resources_with_empty_folders(self): p = api.Project(api.Storage.open(LAYERED_RES_PROJECT)) config = p.get_configuration('root.confml') data = config.layered_resources(empty_folders=True, resource_type='confml').data self.assertEquals(data, {'test.confml': ['layer1/confml/test.confml', 'layer2/confml/test.confml'], 'empty': ['layer1/confml/empty', 'layer2/confml/empty']}) data = config.layered_resources(empty_folders=True, resource_type='implml').data self.assertEquals(data, {'test.implml': ['layer1/implml/test.implml', 'layer2/implml/test.implml'], 'empty': ['layer1/implml/empty', 'layer2/implml/empty']}) data = config.layered_resources(empty_folders=True, resource_type='content').data self.assertEquals(data, {'foo.txt': ['layer1/content/foo.txt', 'layer2/content/foo.txt'], 'empty': ['layer1/content/empty', 'layer2/content/empty']}) data = config.layered_resources(empty_folders=True, resource_type='doc').data self.assertEquals(data, {'bar.txt': ['layer1/doc/bar.txt', 'layer2/doc/bar.txt'], 'empty': ['layer1/doc/empty', 'layer2/doc/empty']})
def __enter__(self): self.project = api.Project(FileStorage(self.project_path, self.mode)) conf = self.project.get_configuration(self.config) dview = conf.get_default_view() return dview setting = dview.get_feature(self.setting_ref) return setting
def test_give_changed_layers(self): project = api.Project(api.Storage.open(os.path.join(ROOT_PATH,'layerproject'))) config = project.get_configuration('root.confml') dview = config.get_default_view() self.assertEquals(layer_utils.give_changed_layers(dview.get_feature("StringFeatureTest.Value1")), [True, True, True, True, True]) self.assertEquals(layer_utils.give_changed_layers(dview.get_feature("StringFeatureTest.Value2")), [False, True, True, False, False])
def test_find_tpf_files(self): project = api.Project(api.Storage.open(os.path.join(ROOT_PATH, "e75"))) config = project.get_configuration("root_variant.confml") impl = impl_from_resource("variant/implml/theme.thememl", config) tpf_paths = [] tpf_paths.append("UI/Themes") list_tpf_files = impl.find_tpf_files(tpf_paths) # The found TPF should be the one under variant/ not s60/ self.assertEquals(list_tpf_files, ['variant/content/UI/Themes/Armi.tpf']) tpf_paths = [] tpf_paths.append("UI") list_tpf_files = impl.find_tpf_files(tpf_paths) self.assertEquals(list_tpf_files, ['s60/content/UI/Armi2.tpf']) tpf_paths = [] tpf_paths.append("UI") tpf_paths.append("UI/Themes") list_tpf_files = impl.find_tpf_files(tpf_paths) self.assertEquals( sorted(list_tpf_files), sorted([ 'variant/content/UI/Themes/Armi.tpf', 's60/content/UI/Armi2.tpf' ]))
def test_changed_on_layers(self): project = api.Project(api.Storage.open(os.path.join(ROOT_PATH,'layerproject'))) config = project.get_configuration('root.confml') dview = config.get_default_view() self.assertTrue(layer_utils.changed_on_layers(dview.get_feature("StringFeatureTest.Value1"),0,4)) self.assertTrue(layer_utils.changed_on_layers(dview.get_feature("StringFeatureTest.Value1"),2,3)) self.assertTrue(layer_utils.changed_on_layers(dview.get_feature("StringFeatureTest.Value1"),2,2)) self.assertTrue(layer_utils.changed_on_layers(dview.get_feature("StringFeatureTest.Value1"),1,7)) self.assertFalse(layer_utils.changed_on_layers(dview.get_feature("StringFeatureTest.Value1"),8,9)) self.assertFalse(layer_utils.changed_on_layers(dview.get_feature("StringFeatureTest.Value2"),0,1)) self.assertTrue(layer_utils.changed_on_layers(dview.get_feature("StringFeatureTest.Value2"),1,5)) self.assertFalse(layer_utils.changed_on_layers(dview.get_feature("StringFeatureTest.Value2"),3,5)) self.assertFalse(layer_utils.changed_on_layers(dview.get_feature("StringFeatureTest.Value2"),5,3)) self.assertFalse(layer_utils.changed_on_layers(dview.get_feature("StringFeatureTest.Value2"),-2,-1)) self.assertFalse(layer_utils.changed_on_layers(dview.get_feature("StringFeatureTest.Value2"),-1,-2)) self.assertTrue(layer_utils.changed_on_layers(dview.get_feature("StringFeatureTest.Value2"),2,5)) self.assertTrue(layer_utils.changed_on_layers(dview.get_feature("StringFeatureTest.Value2"),5,2)) self.assertTrue(layer_utils.changed_on_layers(dview.get_feature("StringFeatureTest.Value2"),-3,-1)) self.assertTrue(layer_utils.changed_on_layers(dview.get_feature("StringFeatureTest.Value2"),-1,-3)) self.assertFalse(layer_utils.changed_on_layers(dview.get_feature("StringFeatureTest.Value2"),3,1000)) self.assertFalse(layer_utils.changed_on_layers(dview.get_feature("StringFeatureTest.Value2"),-1000,1)) self.assertTrue(layer_utils.changed_on_layers(dview.get_feature("StringFeatureTest.Value2"),-1000,1000))
def _get_impl_and_set(self, ref): fs = filestorage.FileStorage(testdata) p = api.Project(fs) config = p.get_configuration('product.confml') impl_set = plugin.get_impl_set(config, re.escape(ref) + '$') self.assertEquals(len(impl_set), 1) return iter(impl_set).next(), impl_set
def test_save_load_report_data_with_some_content(self): rdata = generation_report.ReportData() p = api.Project(api.Storage.open(TEMP_DIR, 'w')) config = api.Configuration('test.confml') fea = config.create_feature('Foo') fea.create_feature('Child1') fea.create_feature('Child2') c3 = fea.create_feature('Child3') c3.value = 'test' rdata.log = ['one', 'two', 'three'] p.add_configuration(config) p.save() rdata.context = plugin.GenerationContext(phase="pre", tags={'target': 'rofs3'}, output='foo', configuration=config, project=p) tmpfile = os.path.join(TEMP_DIR, 'repdata.dat') generation_report.save_report_data(rdata, tmpfile) rdata2 = generation_report.load_report_data(tmpfile) self.assertEquals(repr(rdata), repr(rdata2)) self.assertEquals(rdata.log, rdata2.log) self.assertEquals(rdata.log, rdata2.log) self.assertEquals(rdata2.context.phase, 'pre') self.assertEquals(rdata2.context.tags, {'target': 'rofs3'}) self.assertEquals(rdata2.context.output, 'foo') self.assertEquals(rdata2.context.configuration.Foo.Child3.fqr, 'Foo.Child3') self.assertEquals(rdata2.context.configuration.Foo.Child3.get_value(), 'test') self.assertEquals(rdata2.context.configuration.Foo.Child3.value, 'test')
def test_rule_with_empty_value1(self): return project = api.Project( api.Storage.open(os.path.join(ROOT_PATH, 'ruleproject/rules'), "a")) config = project.get_configuration('root.confml') implcontainer = plugin.get_impl_set(config) implcontainer.generate() lastconfig = config.get_last_configuration() self.assertEquals(lastconfig.get_path(), ruleml.RuleImpl.AUTOCONFIGURATION_CONFML) self.assertEquals( lastconfig.get_data('imakerapi.outputLocation').get_ref(), 'outputLocation') self.assertEquals( lastconfig.get_data('imakerapi.outputLocation').get_value(), '2') self.assertEquals( lastconfig.get_data('imakerapi.outputLocationY').get_value(), 'hello') self.assertEquals( lastconfig.get_data('operations.minus').get_value(), '18') self.assertEquals( lastconfig.get_data('operations.minus1').get_value(), '35') self.assertEquals( lastconfig.get_data('operations.minus4').get_value(), '5') project.close()