def test_update_entries(self): vocabulary_id = "string" name = "name" vocabulary = Vocabulary() vocabulary.name(name) with self.assertRaises(QtVocabularyError): vocabulary.update(vocabulary_id)
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)
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))
def test_update_arg_type(self): vocabulary_id = 123 vocabulary = Vocabulary() with self.assertRaises(QtArgumentError): vocabulary.update(vocabulary_id)
# Fetch from current object print("Fetch vocabulary") print(vocabulary.fetch(vocabulary.get_id())) # Create list of vocabularies from tsv file print("Create list of the vocabularies from TSV file") tsv_voc = Vocabulary() tsv_voc.name("revenue") tsv_voc.source(FILE_NAME) try: tsv_voc.create() except Exception as e: print(e) print(tsv_voc) # Update vocabulary, name and entries are mandatory options print("Update vocabulary") vocabulary.add_entry("Lenovo", "Thinkpad") vocabulary.name("updated name") print(vocabulary.get_id()) vocabulary.update(vocabulary.get_id()) print(vocabulary) # List all existing vocabularies print("List all vocabularies") print(vocabulary.read()) # Delete vocabulary print("Is vocabulary deleted?") print(vocabulary.delete(vocabulary.get_id()))