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)
# 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()))