def test_singleoptionensurer_too_many(): """Raise an error after one ok call.""" soe = SingleOptionEnsurer(int) assert soe("33") == 33 with pytest.raises(ValueError) as cm: soe("33") assert str(cm.value) == "the option can be specified only once"
def fill_parser(self, parser): """Add own parameters to the general parser.""" parser.add_argument( 'charm_name', metavar='charm-name', help="The charm name to associate the resource") parser.add_argument( 'resource_name', metavar='resource-name', help="The resource name") parser.add_argument( '--filepath', type=SingleOptionEnsurer(useful_filepath), required=True, help="The file path of the resource content to upload")
def fill_parser(self, parser): """Add own parameters to the general parser.""" parser.add_argument( "--debug", action="store_true", help="Launch shell in build environment upon failure", ) parser.add_argument( "--destructive-mode", action="store_true", help=("Pack charm using current host which may result in breaking " "changes to system configuration"), ) parser.add_argument( "-e", "--entrypoint", type=SingleOptionEnsurer(useful_filepath), help= ("The executable which is the operator entry point; defaults to 'src/charm.py'" ), ) parser.add_argument( "-r", "--requirement", action="append", type=useful_filepath, help= ("File(s) listing needed PyPI dependencies (can be used multiple " "times); defaults to 'requirements.txt'"), ) parser.add_argument( "--shell", action="store_true", help="Launch shell in build environment in lieu of packing", ) parser.add_argument( "--shell-after", action="store_true", help="Launch shell in build environment after packing", ) parser.add_argument( "--bases-index", action="append", type=int, help="Index of 'bases' configuration to build (can be used multiple " "times); defaults to all", ) parser.add_argument( "--force", action="store_true", help="Force packing even after finding lint errors", )
def fill_parser(self, parser): """Add own parameters to the general parser.""" parser.add_argument('name', help="The name of charm or bundle") parser.add_argument( '-r', '--revision', type=SingleOptionEnsurer(int), required=True, help='The revision to release') parser.add_argument( '-c', '--channel', action='append', required=True, help="The channel(s) to release to (this option can be indicated multiple times)") parser.add_argument( '--resource', action='append', type=ResourceOption(), default=[], help=( "The resource(s) to attach to the release, in the <name>:<revision> format " "(this option can be indicated multiple times)"))
def fill_parser(self, parser): """Add own parameters to the general parser.""" parser.add_argument( "-e", "--entrypoint", type=SingleOptionEnsurer(useful_filepath), help= ("The executable which is the operator entry point; defaults to 'src/charm.py'" ), ) parser.add_argument( "-r", "--requirement", action="append", type=useful_filepath, help= ("File(s) listing needed PyPI dependencies (can be used multiple " "times); defaults to 'requirements.txt'"), )
def test_singleoptionensurer_convert_ok(): """Work fine with one call, convert as expected.""" soe = SingleOptionEnsurer(int) assert soe("33") == 33