# You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/ """Test odapi.query.organization.company_reference_IDs().""" import sys from os import path from odapi.main import app_main from odapi.util import stdout, stderr from odapi.query.organization import company_reference_IDs usage=""" Usage: {0:s} [OPTIONS] {0:s} --help For all companies the authorized user has access to the company name and reference Id is returned in a list of dictionary objects. The dict object keys are 'name' and 'reference'. """ (pgm, ext) = path.splitext(path.basename(sys.argv[0])) (api, argv) = app_main(pgm, sys.argv[1:], usage) cIds = company_reference_IDs(api) if not cIds or len(cIds) == 0: stderr('failed to fetch company reference ids\n') api.clean_exit(1) for n in range(len(cIds)): item = '{0:2d}: {1:40s} {2:s}\n'.format( n+1, cIds[n]['company'], cIds[n]['ref']) stdout(item) api.clean_exit(0)
elif key == '-f' or key == '--filters' : optdct['filters'] = to_str(val) elif key == '-o' or key == '--out': optdct['out'] = to_str(val) elif key == '-x' or key == '--xml': optdct['xml'] = True elif key == '-t' or key == '--text': optdct['text'] = True else: e = "Unknown option '{0:s}'".format(key) raise AppOptionError(e) log.debug("{0:s}.py:parseargs() returning:\n\t{0!s}".format(pgm, optdct)) return optdct pgm = 'parse_request' usage = None # Need to construct a bogus argv; one with a 'request' and one without argv = [] for arg in ('-s', '3', '-j', 'jobcat', '-f', 'bogus/path', '-r', 'this,that, the next thing'): argv.append(arg) print stdout('argv: ') print argv (api, argv) = app_main(pgm, argv, usage) (popts, args) = parse_request(pgm, argv, usage) print popts print print args api.clean_exit(0)