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))
def test_fetch_arg(self): vocabulary_id = 123 vocabulary = Vocabulary() with self.assertRaises(QtArgumentError): vocabulary.fetch(vocabulary_id)
vocabulary = Vocabulary() # Create entries of vocabulary vocabulary.add_entry("Apple Inc.", "AAPL") vocabulary.add_entry("Amazon.com", "AMZN") vocabulary.entries({"str": "Alphabet Inc.", "category": "GOOG"}) # Create Vocabulary try: vocabulary.name("some name").add_entry("Apple Inc.", "AAPL").create() except Exception as e: print(e) # 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")