Example #1
0
    def test_pronunciation_found(self, mock_api_call):
        res = [{
            "rawType": "ahd-legacy",
            "seq": 0,
            "raw": "hip"
        }, {
            "rawType": "arpabet",
            "seq": 0,
            "raw": "HH IH2 P AH0 P AA1 T AH0 M AH0 S"
        }]

        mock_api_call.return_value = mock.Mock()
        mock_api_call.return_value.status_code = 200
        mock_api_call.return_value.json.return_value = res

        expected_result = '[{"rawType": "ahd-legacy", "raw": "hip", "seq": 0}, {"rawType": "arpabet", "raw": "HH IH2 P AH0 P AA1 T AH0 M AH0 S", "seq": 1}]'
        result = vb.pronunciation("hippopotamus")

        if sys.version_info[:2] <= (2, 7):
            self.assertItemsEqual(expected_result, result)
        else:
            self.assertCountEqual(expected_result, result)
Example #2
0
    def test_pronunciation_not_found(self, mock_api_call):
        mock_api_call.return_value = mock.Mock()
        mock_api_call.return_value.status_code = 404

        self.assertFalse(vb.pronunciation("hippopotamus"))
Example #3
0
def getpronunciation(word):
    return vb.pronunciation(word, format="list")