Ejemplo n.º 1
0
 def test_document_move_with_multiple_tags(self):
     scope = Scope(database=self._database)
     scope.add_tag(2)
     scope.add_tag(3)
     scope.add_tag(6)
     self.assertEqual(scope.get_concept_document_ids(), [])
     self.assertEqual(set(scope.get_concept_tag_ids()), {2, 3, 6})
     self.assertEqual(scope.get_selection_document_ids(), [])
     self.assertEqual(set(scope.get_selection_tag_ids()),
                      {1, 2, 3, 4, 5, 6})
     self.assertEqual(scope.get_concept_only_document_ids(), [])
     self.assertEqual(set(scope.get_selection_only_tag_ids()), {1, 4, 5})
     scope.move_document(6)
     self.assertEqual(scope.get_concept_document_ids(), [6])
     self.assertEqual(set(scope.get_concept_tag_ids()), {2, 3, 6})
     self.assertEqual(scope.get_selection_document_ids(), [])
     self.assertEqual(set(scope.get_selection_tag_ids()),
                      {1, 2, 3, 4, 5, 6})
     self.assertEqual(scope.get_concept_only_document_ids(), [6])
     self.assertEqual(set(scope.get_selection_only_tag_ids()), {1, 4, 5})
     scope.select_document(6)
     self.assertEqual(scope.get_concept_document_ids(), [6])
     self.assertEqual(set(scope.get_concept_tag_ids()), {2, 3, 6})
     self.assertEqual(scope.get_selection_document_ids(), [6])
     self.assertEqual(set(scope.get_selection_tag_ids()), {2, 3, 6})
     self.assertEqual(scope.get_concept_only_document_ids(), [])
     self.assertEqual(scope.get_selection_only_tag_ids(), [])
Ejemplo n.º 2
0
 def test_document_creation_with_single_tag(self):
     scope = Scope(database=self._database)
     scope.add_tag(2)
     self.assertEqual(scope.get_concept_tag_ids(), [2])
     self.assertEqual(set(scope.get_selection_tag_ids()),
                      {1, 2, 3, 4, 5, 6})
     self.assertEqual(set(scope.get_selection_only_tag_ids()),
                      {1, 3, 4, 5, 6})
     document = scope.create_document('main.py', 'python', '/tmp/main.py')
     self.assertEqual(set(scope.get_concept_document_ids()),
                      {1, 4, 5, document.id})
     self.assertEqual(scope.get_concept_tag_ids(), [2])
     self.assertEqual(scope.get_selection_document_ids(), [])
     self.assertEqual(set(scope.get_selection_tag_ids()),
                      {1, 2, 3, 4, 5, 6})
     self.assertEqual(set(scope.get_concept_only_document_ids()),
                      {1, 4, 5, document.id})
     self.assertEqual(set(scope.get_selection_only_tag_ids()),
                      {1, 3, 4, 5, 6})
     scope.select_document(document.id)
     self.assertEqual(set(scope.get_concept_document_ids()),
                      {1, 4, 5, document.id})
     self.assertEqual(scope.get_concept_tag_ids(), [2])
     self.assertEqual(scope.get_selection_document_ids(), [document.id])
     self.assertEqual(scope.get_selection_tag_ids(), [2])
     self.assertEqual(set(scope.get_concept_only_document_ids()), {1, 4, 5})
     self.assertEqual(scope.get_selection_only_tag_ids(), [])
     scope.deselect_document(document.id)
     self.assertEqual(set(scope.get_concept_document_ids()),
                      {1, 4, 5, document.id})
     self.assertEqual(scope.get_concept_tag_ids(), [2])
     self.assertEqual(scope.get_selection_document_ids(), [])
     self.assertEqual(set(scope.get_selection_tag_ids()),
                      {1, 2, 3, 4, 5, 6})
     self.assertEqual(set(scope.get_concept_only_document_ids()),
                      {1, 4, 5, document.id})
     self.assertEqual(set(scope.get_selection_only_tag_ids()),
                      {1, 3, 4, 5, 6})
     scope.remove_tag(2)
     self.assertEqual(set(scope.get_concept_document_ids()),
                      {1, 2, 3, 4, 5, 6, 7, 8, document.id})
     self.assertEqual(scope.get_concept_tag_ids(), [])
     self.assertEqual(scope.get_selection_document_ids(), [])
     self.assertEqual(set(scope.get_selection_tag_ids()),
                      {1, 2, 3, 4, 5, 6})
     self.assertEqual(set(scope.get_concept_only_document_ids()),
                      {1, 2, 3, 4, 5, 6, 7, 8, document.id})
     self.assertEqual(set(scope.get_selection_only_tag_ids()),
                      {1, 2, 3, 4, 5, 6})
     scope.select_document(document.id)
     self.assertEqual(set(scope.get_concept_document_ids()),
                      {1, 2, 3, 4, 5, 6, 7, 8, document.id})
     self.assertEqual(scope.get_concept_tag_ids(), [])
     self.assertEqual(scope.get_selection_document_ids(), [document.id])
     self.assertEqual(scope.get_selection_tag_ids(), [2])
     self.assertEqual(set(scope.get_concept_only_document_ids()),
                      {1, 2, 3, 4, 5, 6, 7, 8})
     self.assertEqual(scope.get_selection_only_tag_ids(), [2])
Ejemplo n.º 3
0
 def test_deselect_all_documents(self):
     scope = Scope(database=self._database)
     for last_document_id in range(1, 10):
         for document_id in range(1, last_document_id):
             scope.select_document(document_id)
         self.assertEqual(len(scope.get_selection_documents()),
                          last_document_id - 1)
         scope.deselect_all_documents()
         self.assertEqual(scope.get_selection_documents(), [])
Ejemplo n.º 4
0
 def test_document_copy_to_root(self):
     scope = Scope(database=self._database)
     scope.copy_document(7)
     self.assertEqual(set(scope.get_concept_document_ids()),
                      {1, 2, 3, 4, 5, 6, 7, 8})
     self.assertEqual(scope.get_concept_tag_ids(), [])
     self.assertEqual(scope.get_selection_document_ids(), [])
     self.assertEqual(set(scope.get_selection_tag_ids()),
                      {1, 2, 3, 4, 5, 6})
     self.assertEqual(set(scope.get_concept_only_document_ids()),
                      {1, 2, 3, 4, 5, 6, 7, 8})
     self.assertEqual(set(scope.get_selection_only_tag_ids()),
                      {1, 2, 3, 4, 5, 6})
     scope.select_document(7)
     self.assertEqual(set(scope.get_concept_document_ids()),
                      {1, 2, 3, 4, 5, 6, 7, 8})
     self.assertEqual(scope.get_concept_tag_ids(), [])
     self.assertEqual(scope.get_selection_document_ids(), [7])
     self.assertEqual(set(scope.get_selection_tag_ids()), {3, 6})
     self.assertEqual(set(scope.get_concept_only_document_ids()),
                      {1, 2, 3, 4, 5, 6, 8})
     self.assertEqual(set(scope.get_selection_only_tag_ids()), {3, 6})
     scope.add_tag(3)
     self.assertEqual(set(scope.get_concept_document_ids()), {2, 7, 8})
     self.assertEqual(scope.get_concept_tag_ids(), [3])
     self.assertEqual(scope.get_selection_document_ids(), [7])
     self.assertEqual(set(scope.get_selection_tag_ids()), {3, 6})
     self.assertEqual(set(scope.get_concept_only_document_ids()), {2, 8})
     self.assertEqual(scope.get_selection_only_tag_ids(), [6])
     scope.remove_tag(3)
     self.assertEqual(set(scope.get_concept_document_ids()),
                      {1, 2, 3, 4, 5, 6, 7, 8})
     self.assertEqual(scope.get_concept_tag_ids(), [])
     self.assertEqual(scope.get_selection_document_ids(), [7])
     self.assertEqual(set(scope.get_selection_tag_ids()), {3, 6})
     self.assertEqual(set(scope.get_concept_only_document_ids()),
                      {1, 2, 3, 4, 5, 6, 8})
     self.assertEqual(set(scope.get_selection_only_tag_ids()), {3, 6})
     scope.add_tag(6)
     self.assertEqual(set(scope.get_concept_document_ids()), {4, 7})
     self.assertEqual(scope.get_concept_tag_ids(), [6])
     self.assertEqual(scope.get_selection_document_ids(), [7])
     self.assertEqual(set(scope.get_selection_tag_ids()), {3, 6})
     self.assertEqual(scope.get_concept_only_document_ids(), [4])
     self.assertEqual(scope.get_selection_only_tag_ids(), [3])
     scope.remove_tag(6)
     self.assertEqual(set(scope.get_concept_document_ids()),
                      {1, 2, 3, 4, 5, 6, 7, 8})
     self.assertEqual(scope.get_concept_tag_ids(), [])
     self.assertEqual(scope.get_selection_document_ids(), [7])
     self.assertEqual(set(scope.get_selection_tag_ids()), {3, 6})
     self.assertEqual(set(scope.get_concept_only_document_ids()),
                      {1, 2, 3, 4, 5, 6, 8})
     self.assertEqual(set(scope.get_selection_only_tag_ids()), {3, 6})
Ejemplo n.º 5
0
 def test_tag_creation_with_multiple_documents(self):
     scope = Scope(database=self._database)
     for document_id in [4, 6, 7, 8]:
         scope.select_document(document_id)
     tag = scope.create_tag('source')
     scope.add_tag(tag.id)
     self.assertEqual(set(scope.get_concept_document_ids()), {4, 6, 7, 8})
     self.assertEqual(scope.get_concept_tag_ids(), [tag.id])
     self.assertEqual(set(scope.get_selection_document_ids()), {4, 6, 7, 8})
     self.assertEqual(scope.get_selection_tag_ids(), [tag.id])
     self.assertEqual(scope.get_concept_only_document_ids(), [])
     self.assertEqual(scope.get_selection_only_tag_ids(), [])
Ejemplo n.º 6
0
 def test_tag_addition_with_single_selection(self):
     scope = Scope(database=self._database)
     scope.select_document(7)
     self.assertEqual(scope.get_concept_tags(), [])
     document_only_tags = scope.get_selection_only_tags()
     self.assertEqual(len(document_only_tags), 2)
     _ = scope.create_tag('script')
     _ = scope.create_tag('web')
     selection_only_tags = scope.get_selection_only_tags()
     self.assertEqual(len(selection_only_tags), 4)
     for tag in selection_only_tags:
         self.assertIn(tag.name, ['rust', 'index', 'script', 'web'])
Ejemplo n.º 7
0
 def test_document_deselection(self):
     scope = Scope(database=self._database)
     expected_tag_ids = {6: [2], 4: [1, 2], 1: [1, 2, 5]}
     for document_id in [1, 4, 5, 6]:
         scope.select_document(document_id)
     for document_id in [6, 4, 1]:
         scope.deselect_document(document_id)
         selection_only_tags = scope.get_selection_only_tags()
         self.assertEqual(len(selection_only_tags),
                          len(expected_tag_ids[document_id]))
         for tag in selection_only_tags:
             self.assertIn(tag.id, expected_tag_ids[document_id])
Ejemplo n.º 8
0
 def test_document_creation_without_tags(self):
     scope = Scope(database=self._database)
     document = scope.create_document('main.c', 'c', '/tmp/main.c')
     scope.select_document(document.id)
     self.assertEqual(set(scope.get_concept_document_ids()),
                      {1, 2, 3, 4, 5, 6, 7, 8, document.id})
     self.assertEqual(scope.get_concept_tag_ids(), [])
     self.assertEqual(scope.get_selection_document_ids(), [document.id])
     self.assertEqual(scope.get_selection_tag_ids(), [])
     self.assertEqual(set(scope.get_concept_only_document_ids()),
                      {1, 2, 3, 4, 5, 6, 7, 8})
     self.assertEqual(scope.get_selection_only_tag_ids(), [])
Ejemplo n.º 9
0
 def test_tag_creation_with_single_document(self):
     scope = Scope(database=self._database)
     scope.select_document(4)
     tag = scope.create_tag('template')
     scope.add_tag(tag.id)
     self.assertEqual(scope.get_concept_document_ids(), [4])
     self.assertEqual(scope.get_concept_tag_ids(), [tag.id])
     self.assertEqual(scope.get_selection_document_ids(), [4])
     self.assertEqual(set(scope.get_selection_tag_ids()), {2, 6, tag.id})
     self.assertEqual(scope.get_concept_only_document_ids(), [])
     self.assertEqual(set(scope.get_selection_only_tag_ids()), {2, 6})
     tag_names = {2: 'python', 6: 'index', tag.id: 'template'}
     for tag in scope.get_selection_only_tags():
         self.assertEqual(tag.name, tag_names[tag.id])
Ejemplo n.º 10
0
 def test_tag_removing_with_selection_from_document(self):
     scope = Scope(database=self._database)
     scope.add_tag(2)
     scope.add_tag(5)
     scope.select_document(5)
     concept_tags = scope.get_concept_tags()
     self.assertEqual(len(concept_tags), 2)
     for tag in concept_tags:
         self.assertIn(tag.name, ['gui', 'python'])
     selection_only_tags = scope.get_selection_only_tags()
     self.assertEqual(len(selection_only_tags), 1)
     self.assertEqual(selection_only_tags[0].name, 'book')
     scope.remove_tag(1)
     concept_tags = scope.get_concept_tags()
     self.assertEqual(len(concept_tags), 2)
     for tag in concept_tags:
         self.assertIn(tag.name, ['gui', 'python'])
     self.assertEqual(scope.get_selection_only_tags(), [])
Ejemplo n.º 11
0
 def test_tag_destroying(self):
     scope = Scope(database=self._database)
     tag_counts = {
         1: [2, 1, 0, 0, 0, 0, 0],
         2: [2, 1, 1, 0, 0, 0, 0],
         3: [2, 1, 1, 1, 0, 0, 0],
         4: [2, 2, 1, 1, 1, 1, 0],
         5: [3, 2, 1, 1, 1, 0, 0],
         6: [2, 2, 2, 2, 1, 0, 0],
         7: [2, 2, 2, 1, 1, 1, 0],
         8: [2, 2, 2, 1, 1, 0, 0]
     }
     for i in range(7):
         if i > 0:
             scope.destroy_tag(i)
         for document_id in range(1, 9):
             scope.select_document(document_id)
             self.assertEqual(len(scope.get_selection_only_tags()),
                              tag_counts[document_id][i])
             scope.deselect_document(document_id)
Ejemplo n.º 12
0
 def test_document_clone_with_single_tag(self):
     scope = Scope(database=self._database)
     scope.add_tag(6)
     self.assertEqual(set(scope.get_concept_document_ids()), {4, 7})
     self.assertEqual(scope.get_concept_tag_ids(), [6])
     self.assertEqual(set(scope.get_selection_tag_ids()),
                      {1, 2, 3, 4, 5, 6})
     self.assertEqual(set(scope.get_selection_only_tag_ids()),
                      {1, 2, 3, 4, 5})
     cloned_document = scope.clone_document(2)
     self.assertEqual(set(scope.get_concept_document_ids()),
                      {4, 7, cloned_document.id})
     self.assertEqual(scope.get_concept_tag_ids(), [6])
     self.assertEqual(scope.get_selection_document_ids(), [])
     self.assertEqual(set(scope.get_selection_tag_ids()),
                      {1, 2, 3, 4, 5, 6})
     self.assertEqual(set(scope.get_concept_only_document_ids()),
                      {4, 7, cloned_document.id})
     self.assertEqual(set(scope.get_selection_only_tag_ids()),
                      {1, 2, 3, 4, 5})
     scope.remove_tag(6)
     self.assertEqual(set(scope.get_concept_document_ids()),
                      {1, 2, 3, 4, 5, 6, 7, 8, cloned_document.id})
     self.assertEqual(scope.get_concept_tag_ids(), [])
     self.assertEqual(scope.get_selection_document_ids(), [])
     self.assertEqual(set(scope.get_selection_tag_ids()),
                      {1, 2, 3, 4, 5, 6})
     self.assertEqual(set(scope.get_concept_only_document_ids()),
                      {1, 2, 3, 4, 5, 6, 7, 8, cloned_document.id})
     self.assertEqual(set(scope.get_selection_only_tag_ids()),
                      {1, 2, 3, 4, 5, 6})
     scope.select_document(cloned_document.id)
     self.assertEqual(set(scope.get_concept_document_ids()),
                      {1, 2, 3, 4, 5, 6, 7, 8, cloned_document.id})
     self.assertEqual(scope.get_concept_tag_ids(), [])
     self.assertEqual(scope.get_selection_document_ids(),
                      [cloned_document.id])
     self.assertEqual(scope.get_selection_tag_ids(), [6])
     self.assertEqual(set(scope.get_concept_only_document_ids()),
                      {1, 2, 3, 4, 5, 6, 7, 8})
     self.assertEqual(scope.get_selection_only_tag_ids(), [6])
Ejemplo n.º 13
0
 def test_document_selection(self):
     scope = Scope(database=self._database)
     document_selections = {
         (1, 2): [1],
         (1, 5): [1, 2],
         (2, 7): [3],
         (5, 6, 8): [5],
         (2, 7, 8): [3],
         (3, 4): [],
         (5, 7): [],
         (1, 2, 3, 4, 5, 6, 7, 8): []
     }
     for selection, tag_ids in document_selections.items():
         for document_id in selection:
             scope.select_document(document_id)
         selection_only_tags = scope.get_selection_only_tags()
         self.assertEqual(len(selection_only_tags), len(tag_ids))
         for tag in selection_only_tags:
             self.assertIn(tag.id, tag_ids)
         for document_id in selection:
             scope.deselect_document(document_id)
Ejemplo n.º 14
0
 def test_single_document_move_to_root(self):
     scope = Scope(database=self._database)
     scope.move_document(7)
     self.assertEqual(set(scope.get_concept_document_ids()),
                      {1, 2, 3, 4, 5, 6, 7, 8})
     self.assertEqual(scope.get_concept_tag_ids(), [])
     self.assertEqual(scope.get_selection_document_ids(), [])
     self.assertEqual(set(scope.get_selection_tag_ids()),
                      {1, 2, 3, 4, 5, 6})
     self.assertEqual(set(scope.get_concept_only_document_ids()),
                      {1, 2, 3, 4, 5, 6, 7, 8})
     self.assertEqual(set(scope.get_selection_only_tag_ids()),
                      {1, 2, 3, 4, 5, 6})
     scope.select_document(7)
     self.assertEqual(set(scope.get_concept_document_ids()),
                      {1, 2, 3, 4, 5, 6, 7, 8})
     self.assertEqual(scope.get_concept_tag_ids(), [])
     self.assertEqual(scope.get_selection_document_ids(), [7])
     self.assertEqual(scope.get_selection_tag_ids(), [])
     self.assertEqual(set(scope.get_concept_only_document_ids()),
                      {1, 2, 3, 4, 5, 6, 8})
     self.assertEqual(scope.get_selection_only_tag_ids(), [])
Ejemplo n.º 15
0
 def test_document_creation_with_multiple_tags(self):
     scope = Scope(database=self._database)
     scope.add_tag(4)
     self.assertEqual(set(scope.get_concept_document_ids()), {3, 6})
     self.assertEqual(scope.get_concept_tag_ids(), [4])
     self.assertEqual(set(scope.get_selection_tag_ids()),
                      {1, 2, 3, 4, 5, 6})
     self.assertEqual(set(scope.get_selection_only_tag_ids()),
                      {1, 2, 3, 5, 6})
     scope.add_tag(1)
     self.assertEqual(scope.get_concept_document_ids(), [3])
     self.assertEqual(set(scope.get_concept_tag_ids()), {1, 4})
     self.assertEqual(set(scope.get_selection_tag_ids()),
                      {1, 2, 3, 4, 5, 6})
     self.assertEqual(set(scope.get_selection_only_tag_ids()), {2, 3, 5, 6})
     scope.add_tag(2)
     self.assertEqual(scope.get_concept_document_ids(), [])
     self.assertEqual(set(scope.get_concept_tag_ids()), {1, 2, 4})
     self.assertEqual(set(scope.get_selection_tag_ids()),
                      {1, 2, 3, 4, 5, 6})
     self.assertEqual(set(scope.get_selection_only_tag_ids()), {3, 5, 6})
     document = scope.create_document('vm.pdf', 'pdf', '/tmp/vm.pdf')
     self.assertEqual(scope.get_concept_document_ids(), [document.id])
     self.assertEqual(set(scope.get_concept_tag_ids()), {1, 2, 4})
     self.assertEqual(scope.get_selection_document_ids(), [])
     self.assertEqual(set(scope.get_selection_tag_ids()),
                      {1, 2, 3, 4, 5, 6})
     self.assertEqual(scope.get_concept_only_document_ids(), [document.id])
     self.assertEqual(set(scope.get_selection_only_tag_ids()), {3, 5, 6})
     scope.select_document(document.id)
     self.assertEqual(scope.get_concept_document_ids(), [document.id])
     self.assertEqual(set(scope.get_concept_tag_ids()), {1, 2, 4})
     self.assertEqual(scope.get_selection_document_ids(), [document.id])
     self.assertEqual(set(scope.get_selection_tag_ids()), {1, 2, 4})
     self.assertEqual(scope.get_concept_only_document_ids(), [])
     self.assertEqual(scope.get_selection_only_tag_ids(), [])
Ejemplo n.º 16
0
 def test_document_clone_to_root(self):
     scope = Scope(database=self._database)
     cloned_document = scope.clone_document(7)
     self.assertNotEqual(cloned_document.id, 7)
     self.assertEqual(set(scope.get_concept_document_ids()),
                      {1, 2, 3, 4, 5, 6, 7, 8, cloned_document.id})
     self.assertEqual(scope.get_concept_tag_ids(), [])
     self.assertEqual(scope.get_selection_document_ids(), [])
     self.assertEqual(set(scope.get_selection_tag_ids()),
                      {1, 2, 3, 4, 5, 6})
     self.assertEqual(set(scope.get_concept_only_document_ids()),
                      {1, 2, 3, 4, 5, 6, 7, 8, cloned_document.id})
     self.assertEqual(set(scope.get_selection_only_tag_ids()),
                      {1, 2, 3, 4, 5, 6})
     scope.select_document(cloned_document.id)
     self.assertEqual(set(scope.get_concept_document_ids()),
                      {1, 2, 3, 4, 5, 6, 7, 8, cloned_document.id})
     self.assertEqual(scope.get_concept_tag_ids(), [])
     self.assertEqual(scope.get_selection_document_ids(),
                      [cloned_document.id])
     self.assertEqual(scope.get_selection_tag_ids(), [])
     self.assertEqual(set(scope.get_concept_only_document_ids()),
                      {1, 2, 3, 4, 5, 6, 7, 8})
     self.assertEqual(scope.get_selection_only_tag_ids(), [])
Ejemplo n.º 17
0
 def test_document_clone_with_multiple_tags(self):
     scope = Scope(database=self._database)
     scope.add_tag(2)
     scope.add_tag(3)
     scope.add_tag(6)
     self.assertEqual(scope.get_concept_document_ids(), [])
     self.assertEqual(set(scope.get_concept_tag_ids()), {2, 3, 6})
     self.assertEqual(scope.get_selection_document_ids(), [])
     self.assertEqual(set(scope.get_selection_tag_ids()),
                      {1, 2, 3, 4, 5, 6})
     self.assertEqual(scope.get_concept_only_document_ids(), [])
     self.assertEqual(set(scope.get_selection_only_tag_ids()), {1, 4, 5})
     cloned_document = scope.clone_document(6)
     self.assertNotEqual(cloned_document.id, 6)
     self.assertEqual(scope.get_concept_document_ids(),
                      [cloned_document.id])
     self.assertEqual(set(scope.get_concept_tag_ids()), {2, 3, 6})
     self.assertEqual(scope.get_selection_document_ids(), [])
     self.assertEqual(set(scope.get_selection_tag_ids()),
                      {1, 2, 3, 4, 5, 6})
     self.assertEqual(scope.get_concept_only_document_ids(),
                      [cloned_document.id])
     self.assertEqual(set(scope.get_selection_only_tag_ids()), {1, 4, 5})
     scope.select_document(cloned_document.id)
     self.assertEqual(scope.get_concept_document_ids(),
                      [cloned_document.id])
     self.assertEqual(set(scope.get_concept_tag_ids()), {2, 3, 6})
     self.assertEqual(scope.get_selection_document_ids(),
                      [cloned_document.id])
     self.assertEqual(set(scope.get_selection_tag_ids()), {2, 3, 6})
     self.assertEqual(scope.get_concept_only_document_ids(), [])
     self.assertEqual(scope.get_selection_only_tag_ids(), [])
     scope.remove_tag(3)
     self.assertEqual(set(scope.get_concept_document_ids()),
                      {4, cloned_document.id})
     self.assertEqual(set(scope.get_concept_tag_ids()), {2, 6})
     self.assertEqual(scope.get_selection_document_ids(),
                      [cloned_document.id])
     self.assertEqual(set(scope.get_selection_tag_ids()), {2, 3, 6})
     self.assertEqual(scope.get_concept_only_document_ids(), [4])
     self.assertEqual(scope.get_selection_only_tag_ids(), [3])
     scope.remove_tag(2)
     self.assertEqual(set(scope.get_concept_document_ids()),
                      {4, 7, cloned_document.id})
     self.assertEqual(set(scope.get_concept_tag_ids()), {6})
     self.assertEqual(scope.get_selection_document_ids(),
                      [cloned_document.id])
     self.assertEqual(set(scope.get_selection_tag_ids()), {2, 3, 6})
     self.assertEqual(set(scope.get_concept_only_document_ids()), {4, 7})
     self.assertEqual(set(scope.get_selection_only_tag_ids()), {2, 3})
     scope.remove_tag(6)
     self.assertEqual(set(scope.get_concept_document_ids()),
                      {1, 2, 3, 4, 5, 6, 7, 8, cloned_document.id})
     self.assertEqual(scope.get_concept_tag_ids(), [])
     self.assertEqual(scope.get_selection_document_ids(),
                      [cloned_document.id])
     self.assertEqual(set(scope.get_selection_tag_ids()), {2, 3, 6})
     self.assertEqual(set(scope.get_concept_only_document_ids()),
                      {1, 2, 3, 4, 5, 6, 7, 8})
     self.assertEqual(set(scope.get_selection_only_tag_ids()), {2, 3, 6})
     scope.deselect_document(cloned_document.id)
     self.assertEqual(set(scope.get_concept_document_ids()),
                      {1, 2, 3, 4, 5, 6, 7, 8, cloned_document.id})
     self.assertEqual(scope.get_concept_tag_ids(), [])
     self.assertEqual(scope.get_selection_document_ids(), [])
     self.assertEqual(set(scope.get_selection_tag_ids()),
                      {1, 2, 3, 4, 5, 6})
     self.assertEqual(set(scope.get_concept_only_document_ids()),
                      {1, 2, 3, 4, 5, 6, 7, 8, cloned_document.id})
     self.assertEqual(set(scope.get_selection_only_tag_ids()),
                      {1, 2, 3, 4, 5, 6})
     document_counts = {1: 4, 2: 3 + 1, 3: 3 + 1, 4: 2, 5: 3, 6: 2 + 1}
     for tag_id, document_count in document_counts.items():
         scope.add_tag(tag_id)
         self.assertEqual(len(scope.get_concept_documents()),
                          document_count)
         scope.remove_tag(tag_id)
Ejemplo n.º 18
0
 def test_invalid_document_selection(self):
     scope = Scope(database=self._database)
     with self.assertRaises(ValueError):
         _ = scope.select_document(0)
     with self.assertRaises(ValueError):
         _ = scope.select_document(9)