def test_remove_labels(self): jar = LabelJar(self.root) label_id = jar.add('Question', '#FF0000') self.assertEqual( [{'label_id': label_id, 'title': 'Question', 'color': '#FF0000'}], jar.list()) jar.remove(label_id) self.assertEqual([], jar.list())
def test_remove_labels(self): jar = LabelJar(self.root) label_id = jar.add('Question', '#FF0000', False) self.assertEqual([{ 'label_id': label_id, 'title': 'Question', 'color': '#FF0000', 'by_user': False }], jar.list()) jar.remove(label_id) self.assertEqual([], jar.list())
def test_data_is_stored_persistently(self): jar = LabelJar(self.root) label_id = jar.add('Question', '#FF0000') self.assertEqual( [{'label_id': label_id, 'title': 'Question', 'color': '#FF0000'}], jar.list()) jar = LabelJar(self.root) self.assertEqual( [{'label_id': label_id, 'title': 'Question', 'color': '#FF0000'}], jar.list())
def test_list_mutations_are_not_stored(self): jar = LabelJar(self.root) label_id = jar.add('Question', '#FF0000') labels = jar.list() self.assertEqual( [{'label_id': label_id, 'title': 'Question', 'color': '#FF0000'}], labels) del labels[0] self.assertEqual( [{'label_id': label_id, 'title': 'Question', 'color': '#FF0000'}], jar.list())
def test_data_is_stored_persistently(self): jar = LabelJar(self.root) label_id = jar.add('Question', '#FF0000', False) self.assertEqual([{ 'label_id': label_id, 'title': 'Question', 'color': '#FF0000', 'by_user': False }], jar.list()) jar = LabelJar(self.root) self.assertEqual([{ 'label_id': label_id, 'title': 'Question', 'color': '#FF0000', 'by_user': False }], jar.list())
def test_list_mutations_are_not_stored(self): jar = LabelJar(self.root) label_id = jar.add('Question', '#FF0000', False) labels = jar.list() self.assertEqual([{ 'label_id': label_id, 'title': 'Question', 'color': '#FF0000', 'by_user': False }], labels) del labels[0] self.assertEqual([{ 'label_id': label_id, 'title': 'Question', 'color': '#FF0000', 'by_user': False }], jar.list())
def test_listing_labels_is_sorted(self): jar = LabelJar(self.root) jar.add('Zeta-0', '', False) jar.add('zeta-1', '', False) jar.add('alpha-0', '', True) jar.add('\xc3\x84lpha-1', '', False) jar.add('Alpha-2', '', True) self.assertEqual( ['alpha-0', '\xc3\x84lpha-1', 'Alpha-2', 'Zeta-0', 'zeta-1'], [label.get('title') for label in jar.list()])
def test_listing_labels(self): jar = LabelJar(self.root) first_label_id = jar.add('First', '#FF0000') second_label_id = jar.add('Second', '#0000FF') self.assertItemsEqual( [{'label_id': first_label_id, 'title': 'First', 'color': '#FF0000'}, {'label_id': second_label_id, 'title': 'Second', 'color': '#0000FF'}], jar.list())
def test_listing_labels(self): jar = LabelJar(self.root) first_label_id = jar.add('First', '#FF0000', False) second_label_id = jar.add('Second', '#0000FF', True) self.assertItemsEqual([{ 'label_id': first_label_id, 'title': 'First', 'color': '#FF0000', 'by_user': False }, { 'label_id': second_label_id, 'title': 'Second', 'color': '#0000FF', 'by_user': True }], jar.list())