def test_reorder(self): node = create_node(get_n_random_tags(50, list(PRELUDE_TAGS+'ghi'+EPILOGUE_TAGS))) no = PreludeEpilogueOrganizer(PRELUDE_TAGS, EPILOGUE_TAGS) no.reorder(node) validator = NodeStructureChecker(PRELUDE_TAGS, 'ghi', EPILOGUE_TAGS) self.assertEqual(has_valid_structure(node), validator.is_valid(node))
def test_reorg_with_zero_nodes(self): node = create_node('') self.nodeorganizer.reorder(node) self.assertEqual(0, len(node))
def test_invalid_content(self): node = create_node('aabbccgHixxyyzz') validator = NodeStructureChecker(PRELUDE_TAGS, 'ghi', EPILOGUE_TAGS) self.assertFalse(validator.is_valid(node))
def test_invalid_structure_a_in_midrange_without_prelude(self): nodes = create_node('gahi' 'xxxyyzz') self.assertFalse(has_valid_structure(nodes))
def test_invalid_structure_x_in_midrange_without_epilouge(self): nodes = create_node('aabccc' 'gxhi') self.assertFalse(has_valid_structure(nodes))
def test_no_epilogue_tags(self): with self.assertRaises(ValueError): EpilogueTagBlock(create_node('abc'), '')
def test_invalid_structure_b_after_c(self): nodes = create_node('aabbcb' 'ghi' 'xxxyyzz') self.assertFalse(has_valid_structure(nodes))
def test_invalid_structure_x_in_midrange(self): nodes = create_node('aabccc' 'gxhi' 'xxxyyzz') self.assertFalse(has_valid_structure(nodes))
def test_invalid_structure_x_after_y(self): nodes = create_node('aabbcc' 'ghi' 'xxyxyzz') self.assertFalse(has_valid_structure(nodes))
def test_valid_structure_unsorted_midrange(self): nodes = create_node('aabbcc' 'ihg' 'xxxyyzz') self.assertTrue(has_valid_structure(nodes))
def test_valid_content_empty_tag(self): node = create_node('') validator = NodeStructureChecker(PRELUDE_TAGS, 'ghi', EPILOGUE_TAGS) self.assertTrue(validator.is_valid(node))
def test_reorg(self): tags = get_n_random_tags(100, ALLTAGS) tree = create_node(tags) self.nodeorganizer.reorder(tree) self.assertTrue(has_valid_structure(tree))
def test_unique_order_tags(self): with self.assertRaises(ValueError): PreludeTagBlock(create_node("abc"), "abcc")
def test_reorg_with_one_node(self): node = create_node('g') self.nodeorganizer.reorder(node) self.assertEqual('g', node[0].tag)
def getPTB(nodes, preludetags='abc'): return PreludeTagBlock(create_node(nodes), preludetags)
def count(self, nodes): prelude = PreludeTagBlock(create_node(nodes), self.tags) return len(prelude)
def test_no_prelude_tags(self): with self.assertRaises(ValueError): PreludeTagBlock(create_node('abc'), '')
def test_unique_order_tags(self): with self.assertRaises(ValueError): PreludeTagBlock(create_node('abc'), 'abcc')
def getETB(nodes, tags='xyz'): return EpilogueTagBlock(create_node(nodes), tags)
def test_valid_content_without_epilogue(self): node = create_node('aabbccghi') validator = NodeStructureChecker(PRELUDE_TAGS, 'ghi', EPILOGUE_TAGS) self.assertTrue(validator.is_valid(node))
def test_unique_order_tags(self): with self.assertRaises(ValueError): EpilogueTagBlock(create_node('abc'), 'abcc')
def test_tag_error(self): tb = EpilogueTagBlock(create_node('abc'), 'xyz') with self.assertRaises(ValueError): tb.insert_position_after('d')
def test_valid_content_without_prelude(self): node = create_node("ghixxyyzz") validator = NodeStructureChecker(PRELUDE_TAGS, "ghi", EPILOGUE_TAGS) self.assertTrue(validator.is_valid(node))
def test_valid_content_one_tag(self): node = create_node("g") validator = NodeStructureChecker(PRELUDE_TAGS, "ghi", EPILOGUE_TAGS) self.assertTrue(validator.is_valid(node))