def config(tmp_path): """Provide a config class with an extra set method for the test to change it.""" class TestConfig(config_module.Config, frozen=False): """The Config, but with a method to set test values.""" def set(self, prime=None, **kwargs): # prime is special, so we don't need to write all this structure in all tests if prime is not None: self.parts["charm"] = {"prime": prime} # the rest is direct for k, v in kwargs.items(): object.__setattr__(self, k, v) project = config_module.Project( dirpath=tmp_path, started_at=datetime.datetime.utcnow(), config_provided=True, ) # implicit plugin is added by the validator during unmarshal parts = { "charm": { "plugin": "charm", } } return TestConfig(type="charm", parts=parts, project=project)
def config(tmp_path): """Provide a config class with an extra set method for the test to change it.""" class TestConfig(config_module.Config): """The Config, but with a method to set test values.""" def set(self, **kwargs): # prime is special, so we don't need to write all this structure in all tests prime = kwargs.pop('prime', None) if prime is not None: kwargs['parts'] = config_module.BasicPrime.from_dict( {'bundle': { 'prime': prime, }}) # the rest is direct for k, v in kwargs.items(): object.__setattr__(self, k, v) return TestConfig(type='bundle', project=config_module.Project(dirpath=tmp_path))
def bundle_config(tmp_path): """Provide a config class with an extra set method for the test to change it.""" class TestConfig(config_module.Config, frozen=False): """The Config, but with a method to set test values.""" def set(self, prime=None, **kwargs): # prime is special, so we don't need to write all this structure in all tests if prime is not None: if self.parts is None: self.parts = {} self.parts["bundle"] = {"plugin": "bundle", "prime": prime} # the rest is direct for k, v in kwargs.items(): object.__setattr__(self, k, v) project = config_module.Project( dirpath=tmp_path, started_at=datetime.datetime.utcnow(), config_provided=True, ) return TestConfig(type="bundle", project=project)
def config(tmp_path): """Provide a config class with an extra set method for the test to change it.""" class TestConfig(config_module.Config): """The Config, but with a method to set test values.""" def set(self, **kwargs): # prime is special, so we don't need to write all this structure in all tests prime = kwargs.pop("prime", None) if prime is not None: kwargs["parts"] = config_module.BasicPrime.from_dict( {"bundle": { "prime": prime, }}) # the rest is direct for k, v in kwargs.items(): object.__setattr__(self, k, v) project = config_module.Project( dirpath=tmp_path, started_at=datetime.datetime.utcnow(), config_provided=True, ) return TestConfig(type="bundle", project=project)