def testOrganization_invalid(self):
        parser = argparse.ArgumentParser()
        parent.Args(parser)

        args = parser.parse_args(['--organization', 'abc'])
        with self.assertRaises(exceptions.InvalidArgumentException):
            parent.GetParent(args)
    def testFolder_invalid(self):
        parser = argparse.ArgumentParser()
        parent.Args(parser)

        args = parser.parse_args(['--folder', 'folder123'])
        with self.assertRaises(exceptions.InvalidArgumentException):
            parent.GetParent(args)
    def testProject_invalid(self):
        parser = argparse.ArgumentParser()
        parent.Args(parser)

        args = parser.parse_args(['--project', '123AAABBCC'])
        with self.assertRaises(exceptions.InvalidArgumentException):
            parent.GetParent(args)
    def testDefaultToCoreProject(self):
        parser = argparse.ArgumentParser()
        parent.Args(parser)

        properties.VALUES.core.project.Set('my-project-123')

        args = parser.parse_args([])
        self.assertEqual(parent.GetParent(args), 'projects/my-project-123')
Beispiel #5
0
 def Args(parser):
   """Add command-specific args."""
   parent.Args(parser)
   parser.add_argument(
       '--state',
       default='pending',
       help='filter for request state')
   base.URI_FLAG.RemoveFromParser(parser)
    def testNoCoreProjectSet(self):
        parser = argparse.ArgumentParser()
        parent.Args(parser)

        properties.PersistProperty(properties.VALUES.core.project, None)

        args = parser.parse_args([])
        with self.assertRaises(properties.RequiredPropertyError):
            parent.GetParent(args)
    def testOnlyOneParentAllowed(self):
        parser = argparse.ArgumentParser()
        parent.Args(parser)

        # Note: I had trouble getting self.assertRaises to work in this test and
        # gave up. I think it may be because of the test running in both py2 and py3
        # contexts but felt it wasn't worth spending a lot of time on it.
        try:
            parser.parse_args(['--project', '123', '--folder', '456'])
        except:  # pylint: disable=bare-except
            return
        raise AssertionError('parse_args should have raised an exception')
Beispiel #8
0
 def Args(parser):
     """Add command-specific args."""
     parent.Args(parser)
     parser.add_argument(
         '--notification_emails',
         help=
         'Comma-separated list of email addresses to which notifications relating to approval requests should be sent or \'\' to clear all saved notification emails.'
     )
     parser.add_argument(
         '--enrolled_services',
         help=
         'Comma-separated list of services to enroll for Access Approval or \'all\' for all supported services. Note for project and folder enrollments, only \'all\' is supported. Use \'\' to clear all enrolled services.'
     )
Beispiel #9
0
 def Args(parser):
     """Add command-specific args."""
     parent.Args(parser)
     parser.add_argument(
         '--notification_emails',
         help=
         'Comma-separated list of email addresses to which notifications relating to approval requests should be sent or \'\' to clear all saved notification emails.'
     )
     parser.add_argument(
         '--enrolled_services',
         help=
         'Comma-separated list of services to enroll for Access Approval or \'all\' for all supported services. Note for project and folder enrollments, only \'all\' is supported. Use \'\' to clear all enrolled services.'
     )
     parser.add_argument(
         '--active_key_version',
         help=
         'The asymmetric crypto key version to use for signing approval requests. Use `\'\'` to remove the custom signing key.'
     )
    def testOrganization(self):
        parser = argparse.ArgumentParser()
        parent.Args(parser)

        args = parser.parse_args(['--organization', '123'])
        self.assertEqual(parent.GetParent(args), 'organizations/123')
    def testFolder(self):
        parser = argparse.ArgumentParser()
        parent.Args(parser)

        args = parser.parse_args(['--folder', '123'])
        self.assertEqual(parent.GetParent(args), 'folders/123')
    def testProjectId(self):
        parser = argparse.ArgumentParser()
        parent.Args(parser)

        args = parser.parse_args(['--project', 'my-project-abc123'])
        self.assertEqual(parent.GetParent(args), 'projects/my-project-abc123')
Beispiel #13
0
 def Args(parser):
     """Add command-specific args."""
     parent.Args(parser)