def test_choice_build_random_pass(): random.seed(0) choice = Choice(options=[name, [drive0, timing]]) actual = choice.build(random_choice=True) expected = [Element(tag='drive', value=None), Element(tag='timing', value=None)] nose.tools.eq_(actual, expected)
def test_choice_to_key_sets_multiple_required_true_pass(): choice = Choice(options=[ ElementSchema('addressBlock', minOccurs=1), ElementSchema('bank', minOccurs=1), ElementSchema('subspaceMap', minOccurs=1), ]) min_key_sets = choice.choice_to_key_sets(required=True) expected = [{'addressBlock'}, {'bank'}, {'subspaceMap'}] nose.tools.eq_(min_key_sets, expected)
def test_choice_basic_two_extra_fail(): choice = Choice(options=[ ElementSchema('either', minOccurs=1), ElementSchema('or', minOccurs=1), ]) value_key_set = {'extra', 'or'} utils.reset_message_counters() choice.match_choice_keys(value_key_set) nose.tools.eq_(utils.error_count, 1)
def test_choice_three_options_two_pass(): choice = Choice(options=[ [timing, drive0, load0], [drive1, load0], load1 ]) value_key_set = {'timing', 'load'} actual = choice.match_choice_keys(value_key_set) nose.tools.eq_(actual, [timing, load0])
def test_choice_three_options_one_empty_pass(): choice = Choice(options=[ ElementSchema('writeAsRead', minOccurs=1), ElementSchema('useEnumeratedValues', minOccurs=1), [ ElementSchema('minimum', minOccurs=1), ElementSchema('maximum', minOccurs=1), ] ], required=False) value_key_set = set() actual = choice.match_choice_keys(value_key_set) nose.tools.eq_(actual, [])
def test_choice_three_options_mixed_single_pass(): choice = Choice(options=[ ElementSchema('writeAsRead', minOccurs=1), useEnumeratedValues, [ minimum, maximum, ] ]) value_key_set = {'useEnumeratedValues'} actual = choice.match_choice_keys(value_key_set) nose.tools.eq_(actual, [useEnumeratedValues])
def test_choice_to_key_sets_multiple_required_false_pass(): choice = Choice(options=[ ElementSchema('addressBlock', minOccurs=1), ElementSchema('bank', minOccurs=1), [ ElementSchema('test', minOccurs=1), ElementSchema('optional'), ], ElementSchema('subspaceMap', minOccurs=1), ]) max_key_sets = choice.choice_to_key_sets(required=False) expected = [set([]), set([]), {'optional'}, set([])] nose.tools.eq_(max_key_sets, expected)
class Test(SequenceSchema): sequence = [name, Choice(options=[count, wire])]
def test_str_unicode_pass(): choice = Choice(options=[wire, transaction]) nose.tools.eq_(str(choice), 'Choice: (wire | transaction)')
def test_choice_keys_str_single_list_pass(): choice = Choice(options=[wire, transaction]) nose.tools.eq_(choice.choice_keys_str(), '(wire | transaction)')
def test_choice_missing_required_first_optional_second_fail(): choice = Choice(options=[[name, load0], [drive0, load0]]) value_key_set = {'name', 'drive', 'load'} utils.reset_message_counters() choice.match_choice_keys(value_key_set) nose.tools.eq_(utils.error_count, 1)
def test_choice_missing_required_fail(): choice = Choice(options=[name, [drive0, timing]]) value_key_set = {'drive'} utils.reset_message_counters() choice.match_choice_keys(value_key_set) nose.tools.eq_(utils.error_count, 1)
def test_choice_basic_two_both_fail(): choice = Choice(options=[either, orValidator]) value_key_set = {'either', 'or'} utils.reset_message_counters() choice.match_choice_keys(value_key_set) nose.tools.eq_(utils.error_count, 1)
def test_choice_basic_two_pass(): choice = Choice(options=[either, orValidator]) value_key_set = {'or'} actual = choice.match_choice_keys(value_key_set) nose.tools.eq_(actual, [orValidator])
def test_choice_keys_str_nested_list_2_levels_empty_pass(): choice = Choice(options=[name, [transaction, drive0], [wire, count], []]) nose.tools.eq_(choice.choice_keys_str(), '(name | (transaction, drive) | (wire, count) | ())')
def test_choice_build_first_pass(): choice = Choice(options=[name, [drive0, timing]]) actual = choice.build(random_choice=False) expected = [Element(tag='name', value='NCName')] nose.tools.eq_(actual, expected)
class Test(SequenceSchema): sequence = [name, Choice(options=[wire, transaction]), count ]
class Test(SequenceSchema): sequence = [name, Choice(options=[drive0, load0]), count ]