예제 #1
0
 def test_subtag_doesnt_match(self):
     bad_subtag = Tag('rank')
     tag = GroupTag('employer', subtag='job')
     tag.data['bobsburgers'] = bad_subtag
     tag.validate()
     assert not tag.valid
     assert "Tag 'employer' uses subtag 'job', but found 'rank' for 'bobsburgers'" in tag.problems
예제 #2
0
 def test_hides_single_subvalue(self):
     tag = GroupTag('type', 'value1', 'value2', hidden=False)
     tag.subtag('value2').append('cart')
     tag.subtag('value2').append('blart')
     tag.subtag('value2').hide_value('cart')
     header = tag.to_header()
     assert '@hide type >> value2 >> cart' in header
예제 #3
0
 def test_preserves_attributes(self):
     tag = GroupTag('employer',
                    'value1',
                    'value2',
                    'value3',
                    required=True,
                    hidden=True,
                    limit=5)
     tag2 = tag.tagslice(0, 1)
     assert tag2.required == tag.required
     assert tag2.hidden == tag.hidden
     assert tag2.limit == tag.limit
예제 #4
0
 def test_inserts_from_group_tag(self):
     tag = GroupTag('group')
     tag2 = GroupTag('group')
     tag2.append('funny')
     tag2['funny'].append('giggles')
     tag.update(tag2)
     assert 'funny' in tag
     assert 'giggles' in tag['funny']
예제 #5
0
 def test_filled_with_values_set(self):
     tag = GroupTag('employer', 'fruitco')
     assert tag.filled
     assert tag
예제 #6
0
 def test_leaves_old_values(self):
     tag = GroupTag('group')
     tag.update(['werewolves'])
     tag.update(['humans', 'monkeys'])
     assert 'humans' in tag
     assert 'werewolves' in tag
예제 #7
0
 def test_limit_zero_and_required_dont_mix(self):
     tag = GroupTag('employer', 'fruitco', required=True, limit=0)
     tag.validate()
     assert not tag.valid
     assert "Tag 'employer' is required but limited to zero values" in tag.problems
예제 #8
0
 def test_present_with_values_set(self):
     tag = GroupTag('employer', 'fruitco')
     assert tag.present
     assert tag
예제 #9
0
 def test_required_with_no_values_fails(self):
     tag = GroupTag('employer', required=True)
     tag.validate()
     assert not tag.valid
예제 #10
0
def test_bool_truthy_when_present():
    tag = GroupTag('type')
    assert not tag
    tag.append('human')
    assert tag
예제 #11
0
 def test_when_hidden_removes_all_values(self):
     tag = GroupTag('group', 'value1', 'value2', 'value3', hidden=True)
     tag.sanitize()
     assert not tag
예제 #12
0
 def test_returns_string_if_present(self):
     tag = GroupTag('type', 'value1', 'value2')
     assert tag.first_value() == 'value1'
예제 #13
0
 def test_returns_none_if_no_values(self):
     tag = GroupTag('type')
     assert tag.first_value() is None
예제 #14
0
 def test_matches_subvalues(self):
     tag = GroupTag('group', 'value1', 'value2', 'value3')
     tag['value1'].append('subval1')
     assert tag.contains('subval1')
예제 #15
0
 def test_matches_partial_values(self):
     tag = GroupTag('group', 'value1', 'value2', 'value3')
     assert tag.contains('val')
예제 #16
0
 def test_matches_wrong_case(self):
     tag = GroupTag('group', 'value1', 'value2', 'value3')
     assert tag.contains('VALUE1')
예제 #17
0
 def test_saves_list_values(self):
     tag = GroupTag('group', 'guys', 'dolls')
     assert 'guys' in tag
     assert 'dolls' in tag
예제 #18
0
 def test_when_not_hidden_removes_nothing(self):
     tag = GroupTag('group', 'value1', 'value2', 'value3', hidden=False)
     tag.sanitize()
     assert list(tag) == ['value1', 'value2', 'value3']
예제 #19
0
 def test_not_filled_with_no_values(self):
     tag = GroupTag('employer')
     assert not tag.filled
     assert not tag
예제 #20
0
 def test_hides_all_subtags(self):
     tag = GroupTag('group', 'value1', 'value2', 'value3', hidden=False)
     tag.subtag('value1').append('subvalue')
     tag.subtag('value1').hidden = True
     tag.sanitize()
     assert not tag.subtag('value1')
예제 #21
0
 def test_not_present_with_no_values(self):
     tag = GroupTag('employer')
     assert not tag.present
     assert not tag
예제 #22
0
 def test_hidden_values_must_exist(self):
     tag = GroupTag('employer', 'value1')
     tag.hide_value('value2')
     tag.validate()
     assert not tag.valid
     assert "Value 'value2' for tag 'employer' cannot be hidden, because it does not exist" in tag.problems
예제 #23
0
 def test_required_with_values_passes(self):
     tag = GroupTag('employer', 'fruitco', required=True)
     tag.validate()
     assert tag.valid
예제 #24
0
 def test_adds_value_to_keys(self):
     tag = GroupTag('employer')
     tag.append('bobsburgers')
     assert 'bobsburgers' in tag
예제 #25
0
 def test_hide_present_value_removes_value(self):
     tag = GroupTag('group', 'value1', 'value2', 'value3', hidden=False)
     tag.hide_value('value2')
     tag.sanitize()
     assert list(tag) == ['value1', 'value3']
예제 #26
0
 def test_wildcard_with_any_values_is_true(self):
     tag = GroupTag('group', 'value1', 'value2', 'value3')
     assert tag.contains('*')
예제 #27
0
 def test_saves_keyword_values(self):
     tag = GroupTag('group', guys=Tag('rank'), dolls=Tag('rank'))
     assert 'guys' in tag
     assert 'dolls' in tag
예제 #28
0
 def test_hide_partial_value_does_nothing(self):
     tag = GroupTag('group', 'value1', 'value2', 'value3', hidden=False)
     tag.hide_value('val')
     tag.sanitize()
     assert list(tag) == ['value1', 'value2', 'value3']
예제 #29
0
 def test_add_group_creates_group_object(self):
     container = TagContainer()
     container.add_group('group', 'club')
     assert 'group' in container
     assert container('group') == GroupTag('group', 'club')
예제 #30
0
def test_touch_shows_error(capsys):
    tag = GroupTag('group')
    tag.touch()
    _, err = capsys.readouterr()
    assert "Calling touch() on non-flag class GroupTag object 'group'" in err