def test_create_carbon_configuration(self): config = model.CarbonConfiguration(path='foo/bar/test.confml', version_identifier='testing', type="confroot") self.assertEquals(config.version_identifier, 'testing') self.assertEquals(config.path, 'foo/bar/test.confml') self.assertEquals(config.ref, 'foo__bar__test_confml') self.assertEquals(config.name, 'test') self.assertEquals(config.type, 'confroot') config = model.CarbonConfiguration(ref='foo/bar/test.confml') self.assertEquals(config.path, 'foo/bar/test.confml') self.assertEquals(config.ref, 'foo__bar__test_confml') self.assertEquals(config.name, 'test')
def test_map_carbon_configuration(self): mapper = model.get_mapper('confml') c1 = model.CarbonConfiguration("test") c2 = mapper.configuration(c1) self.assertTrue(isinstance(c2, confmlmodel.ConfmlConfiguration)) c2 = mapper.map_object(c1) self.assertTrue(isinstance(c2, confmlmodel.ConfmlConfiguration))
def test_map_carbon_configuration_with_data(self): mapper = model.get_mapper('confml') c1 = model.CarbonConfiguration("test") c1.name = "test.confml" c1.namespace = "com.nokia" c2 = mapper.map_object(c1) self.assertTrue(isinstance(c2, confmlmodel.ConfmlConfiguration)) self.assertEquals(c2.name, "test.confml") self.assertEquals(c2.namespace, "com.nokia") self.assertEquals(c2.path, "test")
def add_configuration(self, configuration): """ Add a list of Carbon configurations. """ # Create the configuration as a layer and configuration root self._cache[configuration.get_path()] = configuration.path rootconf_path = configuration.name+'.confml' rootconf = model.CarbonConfiguration(rootconf_path) rootconf.include_configuration(configuration.get_path()) self._cache[rootconf_path] = rootconf
def loads(self, dict): """ @param obj: The Configuration object """ name = dict.get('configuration_name') path = name + "/root.confml" conf = model.CarbonConfiguration(dict.get('ref'), path=path, type='configurationlayer') conf.name = name conf.version = dict.get('version_identifier') """ Last read the data of this configuration and add it as a configuration """ data_reader = DataReader() datacont = data_reader.loads(dict.get('data', {})) conf.add_configuration(datacont) return conf
def loads(self, dict): """ @param obj: The Configuration object """ name = dict.get('configuration_name') path = name + ".confml" conf = model.CarbonConfiguration(dict.get('ref'), path=path, type='configurationroot') conf.name = name conf.version = dict.get('version_identifier') resmapper = CarbonResourceMapper() """ Read the featurelists as included configurations """ for fealist in dict.get('feature_lists',[]): conf.include_configuration(resmapper.map_carbon_resource(fealist)) """ Read the included configurations """ for includedconfig in dict.get('included',[]): conf.include_configuration(resmapper.map_carbon_resource(includedconfig)) return conf
def test_create_carbon_configuration_with_current_week_version(self): config = model.CarbonConfiguration(path='foo/bar/test.confml') dt = datetime.datetime.today() self.assertEquals(config.version_identifier, "%dwk%02d" % dt.isocalendar()[0:2])