Пример #1
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'])
Пример #2
0
 def test_tag_creation_without_document(self):
     scope = Scope(database=self._database)
     self.assertEqual(scope.get_concept_tags(), [])
     tag = scope.create_tag('n+1')
     scope.add_tag(tag.id)
     self.assertEqual(scope.get_concept_tag_ids(), [tag.id])
     self.assertEqual(set(scope.get_selection_only_tag_ids()),
                      {1, 2, 3, 4, 5, 6})
     self.assertEqual(scope.get_concept_documents(), [])
Пример #3
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(), [])
Пример #4
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])
Пример #5
0
 def test_duplicated_tag_creation(self):
     scope = Scope(database=self._database)
     _ = scope.create_tag('unique')
     with self.assertRaises(ValueError):
         _ = scope.create_tag('unique')