Exemplo n.º 1
0
 def test_add_entry_value_none(self):
     key = "test"
     value = None
     list_entries = [{"str": key}]
     vocabulary = Vocabulary()
     vocabulary.add_entry(key, value)
     self.assertEqual(list_entries, vocabulary.temp_vocabulary['entries'])
Exemplo n.º 2
0
 def test_update_name(self):
     vocabulary_id = "string"
     entries = {"str": "str", "category": "category"}
     vocabulary = Vocabulary()
     vocabulary.entries(entries)
     with self.assertRaises(QtVocabularyError):
         vocabulary.update(vocabulary_id)
Exemplo n.º 3
0
 def test_add_entry(self):
     key = "New York"
     value = "Knicks"
     list_entries = [{"str": key, "category": value}]
     vocabulary = Vocabulary()
     vocabulary.add_entry(key, value)
     self.assertEqual(list_entries, vocabulary.temp_vocabulary['entries'])
Exemplo n.º 4
0
 def test_update_entries(self):
     vocabulary_id = "string"
     name = "name"
     vocabulary = Vocabulary()
     vocabulary.name(name)
     with self.assertRaises(QtVocabularyError):
         vocabulary.update(vocabulary_id)
Exemplo n.º 5
0
 def test_delete_false(self, con):
     some_id = 'some id'
     voc = Vocabulary()
     response = Mock()
     response.status_code = 200
     response.ok = False
     con.return_value = response
     res = voc.delete(some_id)
     self.assertEqual(res, False)
Exemplo n.º 6
0
 def test_read(self, con):
     voc = Vocabulary()
     some_json = [{"key": "value"}]
     response = Mock()
     response.status_code = 200
     response.json.return_value = some_json
     con.return_value = response
     res = voc.read()
     self.assertEqual(res, some_json)
Exemplo n.º 7
0
 def test_entries_vocabulary_len_3(self):
     test_vocabulary = {
         "str": "str",
         "category": "category",
         "some_key": "some_value"
     }
     vocabulary = Vocabulary()
     with self.assertRaises(QtArgumentError):
         vocabulary.entries(test_vocabulary)
Exemplo n.º 8
0
 def test_fetch(self, con):
     some_id = 'some id'
     some_json = {
         "id": "some id",
         "name": "some name",
         "entries": "some entries"
     }
     voc = Vocabulary()
     response = Mock()
     response.json.return_value = some_json
     con.return_value = response
     res = voc.fetch(some_id)
     self.assertEqual(str(res), str(some_json))
Exemplo n.º 9
0
 def test_create_input_stream_none(self, con):
     name = "some name"
     some_dict = {
         "id": "some value",
         'name': 'some name',
         'entries': [{
             'str': 'some entry'
         }]
     }
     some_entry = "some entry"
     voc = Vocabulary()
     voc.name(name)
     voc.add_entry(some_entry)
     response = Mock()
     response.json.return_value = some_dict
     con.return_value = response
     res = voc.create()
     self.assertEqual(str(res), str(some_dict))
Exemplo n.º 10
0
 def test_update(self, con):
     some_id = "some id"
     some_name = 'some name'
     some_key = 'some key'
     some_dict = {
         "id": None,
         'name': 'some name',
         'entries': [{
             'str': 'some entry'
         }]
     }
     voc = Vocabulary()
     voc.name(some_name)
     voc.add_entry(some_key)
     response = Mock()
     response.json.return_value = some_dict
     con.return_value = response
     res = voc.update(some_id)
     self.assertEqual(str(res), str(some_dict))
Exemplo n.º 11
0
 def test_create_input_stream(self, con):
     name = "some name"
     some_tsv_file = 'test.tsv'
     with open(some_tsv_file, "w") as f:
         f.write("Delete me!")
     some_dict = {
         "id": "some value",
         'name': 'some name',
         'entries': [{
             'str': 'some entry'
         }]
     }
     some_entry = "some entry"
     voc = Vocabulary()
     voc.name(name)
     voc.add_entry(some_entry)
     voc.source(some_tsv_file)
     response = Mock()
     response.json.return_value = some_dict
     con.return_value = response
     res = voc.create()
     self.assertEqual(str(res), str(some_dict))
     os.remove("test.tsv")
Exemplo n.º 12
0
 def test_get_entries(self):
     vocabulary = Vocabulary()
     some_entry = []
     self.assertEqual(vocabulary.temp_vocabulary["entries"], some_entry)
Exemplo n.º 13
0
 def test_entries_vocabulary_len_0(self):
     test_vocabulary = {}
     vocabulary = Vocabulary()
     with self.assertRaises(QtArgumentError):
         vocabulary.entries(test_vocabulary)
Exemplo n.º 14
0
 def test_get_name(self):
     vocabulary = Vocabulary()
     some_name = None
     self.assertEqual(vocabulary.temp_vocabulary["name"], some_name)
Exemplo n.º 15
0
 def test_entries_type(self):
     test_vocabulary = "string"
     vocabulary = Vocabulary()
     with self.assertRaises(QtArgumentError):
         vocabulary.entries(test_vocabulary)
Exemplo n.º 16
0
 def test_fetch_arg(self):
     vocabulary_id = 123
     vocabulary = Vocabulary()
     with self.assertRaises(QtArgumentError):
         vocabulary.fetch(vocabulary_id)
Exemplo n.º 17
0
 def test_name_type(self):
     name = 123
     vocabulary = Vocabulary()
     with self.assertRaises(QtArgumentError):
         vocabulary.name(name)
Exemplo n.º 18
0
 def test_name_name(self):
     name = "some name"
     vocabulary = Vocabulary()
     vocabulary.name(name)
     self.assertEqual(name, vocabulary.temp_vocabulary["name"])
Exemplo n.º 19
0
 def test_set_id(self):
     vocabulary = Vocabulary()
     some_id = 'some id'
     vocabulary.set_id(some_id)
     self.assertEqual(vocabulary.id, some_id)
Exemplo n.º 20
0
 def test_update_arg_type(self):
     vocabulary_id = 123
     vocabulary = Vocabulary()
     with self.assertRaises(QtArgumentError):
         vocabulary.update(vocabulary_id)
Exemplo n.º 21
0
 def test_delete_arg(self):
     vocabulary_id = 123
     vocabulary = Vocabulary()
     with self.assertRaises(QtArgumentError):
         vocabulary.delete(vocabulary_id)
Exemplo n.º 22
0
 def test_source_arg_file_type(self):
     file = 123
     vocabulary = Vocabulary()
     with self.assertRaises(QtArgumentError):
         vocabulary.source(file)
Exemplo n.º 23
0
 def test_source_file_exist(self):
     file = "path.tsv"
     vocabulary = Vocabulary()
     with self.assertRaises(QtArgumentError):
         vocabulary.source(file)
Exemplo n.º 24
0
 def test_create_miss_entry(self):
     name = "some name"
     voc = Vocabulary()
     voc.name(name)
     with self.assertRaises(QtVocabularyError):
         voc.create()
Exemplo n.º 25
0
 def test_entries_vocabulary_content_2(self):
     test_vocabulary = {"str": "str", "test": "category"}
     vocabulary = Vocabulary()
     with self.assertRaises(QtArgumentError):
         vocabulary.entries(test_vocabulary)
Exemplo n.º 26
0
 def test_set_id_arg_err(self):
     vocabulary = Vocabulary()
     some_id = 123
     with self.assertRaises(QtArgumentError):
         vocabulary.set_id(some_id)
Exemplo n.º 27
0
 def test_entries_category(self):
     test_vocabulary = {"str": "str"}
     vocabulary = Vocabulary()
     vocabulary.entries(test_vocabulary)
     self.assertEqual([test_vocabulary],
                      vocabulary.temp_vocabulary['entries'])
Exemplo n.º 28
0
 def test_create_miss_name(self):
     entries = {"str": "str", "category": "category"}
     vocabulary = Vocabulary()
     vocabulary.entries(entries)
     with self.assertRaises(QtVocabularyError):
         vocabulary.create()
from qtcurate.document import Document
from qtcurate.result import Result

API_KEY = "YOUR-API-KEY"
DOCUMENT = "resources/sample.pdf"

# Initialise with api key
Qt.init(API_KEY)

# 1- Upload the sample document for processing
list_of_documents = []
document = Document()
doc = document.create(DOCUMENT)
list_of_documents.append(doc)
# 2- Create vocabulary
vocabulary = Vocabulary()
vocabulary.add_entry("Industrials")
vocabulary.add_entry("Quasi-Governments")
vocabulary.add_entry("Governments")
vocabulary.name("Allocations (%)").create()

# 3- Creator Extractor - Regex must have 1 capturing group
extractor = Extractor()
extractor.set_vocabulary(vocabulary.get_id())
extractor.set_validator("^ +(\\d[\\d\\.\\,]+\\d)")
extractor.set_type(Type.DOUBLE)

# 4- Run
model = Model()
model.set_description("test data process")
model.add_extractor(extractor)
Exemplo n.º 30
0
 def test_add_entry_value_type(self):
     key = "test"
     value = ["Knicks"]
     vocabulary = Vocabulary()
     with self.assertRaises(QtArgumentError):
         vocabulary.add_entry(key, value)