コード例 #1
0
ファイル: test_props.py プロジェクト: vettom/aem-cmd
def test_parse_boolean():
    y = parse_properties("should_work=true")
    eq_(2, len(y))
    eq_('true', y['should_work'])
    eq_('Boolean', y['should_work@TypeHint'])

    y = parse_properties("should_work={Boolean}true")
    eq_(2, len(y))
    eq_('true', y['should_work'])
    eq_('Boolean', y['should_work@TypeHint'])

    y = parse_properties("should_work={bool}true")
    eq_(2, len(y))
    eq_('true', y['should_work'])
    eq_('Boolean', y['should_work@TypeHint'])

    y = parse_properties("should_work={String}true")
    eq_(2, len(y))
    eq_('true', y['should_work'])
    eq_('String', y['should_work@TypeHint'])
コード例 #2
0
ファイル: jcr.py プロジェクト: vettom/aem-cmd
 def execute(server, argv):
     options, args = parser.parse_args(argv)
     props = parse_properties(args[1])
     if len(args) >= 3:
         path = args[2]
         return set_node_properties(server, options, path, props)
     else:
         for line in sys.stdin:
             path = line.strip()
             set_node_properties(server, options, path, props)
         return OK
コード例 #3
0
ファイル: users.py プロジェクト: iannovic/aem-cmd
 def execute(server, argv):
     options, args = parser.parse_args(argv)
     action = get_action(args, 'list')
     actionarg = get_argument(args)
     if action == 'list' or action == 'ls':
         return list_users(server, options)
     elif action == 'create':
         return create_user(server, options, actionarg)
     elif action == 'setprop':
         username = actionarg
         propstring = get_argument(argv, 3)
         props = parse_properties(propstring)
         return set_profile_properties(server, options, username, props)
     else:
         parser.print_help()
         return USER_ERROR
コード例 #4
0
def test_parser_properties():
    x = 'key=value'
    props = parse_properties(x)
    eq_(1, len(props))
    eq_('value', props['key'])

    x = 'key0=value0,key1=value1'
    props = parse_properties(x)
    eq_(2, len(props))
    eq_('value0', props['key0'])
    eq_('value1', props['key1'])

    x = 'key0="value0",key1="value1"'
    props = parse_properties(x)
    eq_('value0', props['key0'])
    eq_('String', props['key0@TypeHint'])
    eq_('value1', props['key1'])
    eq_('String', props['key1@TypeHint'])
    eq_(4, len(props))

    x = 'key0="value0",key1="Sentence with \\"quotes in it\\""'
    props = parse_properties(x)

    eq_(4, len(props))
    eq_('value0', props['key0'])
    eq_('String', props['key0@TypeHint'])
    eq_('Sentence with \\"quotes in it\\"', props['key1'])
    eq_('String', props['key1@TypeHint'])

    x = 'key0="value0",key1="Sentence, with comma in it"'
    props = parse_properties(x)
    eq_(4, len(props))
    eq_('value0', props['key0'])
    eq_('String', props['key0@TypeHint'])
    eq_('Sentence, with comma in it', props['key1'])
    eq_('String', props['key1@TypeHint'])

    x = 'ary=[foo,bar,baz]'
    props = parse_properties(x)
    eq_(2, len(props))
    eq_(['foo', 'bar', 'baz'], props['ary'])
    eq_('String[]', props['ary@TypeHint'])
コード例 #5
0
ファイル: test_props.py プロジェクト: vettom/aem-cmd
def test_parse_quoted_number():
    y = parse_properties("answer=\"42\"")
    eq_(2, len(y))
    eq_('42', y['answer'])
    eq_('String', y['answer@TypeHint'])
コード例 #6
0
ファイル: test_props.py プロジェクト: vettom/aem-cmd
def test_parse_simple_prop():
    y = parse_properties("foobar=baz")
    eq_(1, len(y))
    eq_('baz', y['foobar'])
コード例 #7
0
ファイル: test_props.py プロジェクト: vettom/aem-cmd
def test_parse_integer():
    y = parse_properties("nbr_dwarves=7")
    eq_(2, len(y))
    eq_('7', y['nbr_dwarves'])
    eq_('Long', y['nbr_dwarves@TypeHint'])
コード例 #8
0
ファイル: test_props.py プロジェクト: vettom/aem-cmd
def test_parse_multi_props():
    y = parse_properties("first=John,last=Doe")
    eq_(2, len(y))
    eq_('John', y['first'])
    eq_('Doe', y['last'])
コード例 #9
0
ファイル: test_props.py プロジェクト: vettom/aem-cmd
def test_parse_double_quoted_prop():
    y = parse_properties('name="John \\"The machine\\" Doe"')
    eq_(2, len(y))
    eq_('John \\"The machine\\" Doe', y['name'])
    eq_('String', y['name@TypeHint'])
コード例 #10
0
ファイル: test_props.py プロジェクト: vettom/aem-cmd
def test_parse_quoted_prop():
    y = parse_properties("name=\"John Doe\"")
    eq_(2, len(y))
    eq_('John Doe', y['name'])
    eq_('String', y['name@TypeHint'])