示例#1
0
 def test_query_normal(self, Record):
     self.dict._get_raw = Mock(return_value=self.raw_html)
     self.dict.query(self.word, self.timeout)
     Record.assert_called_with(
         word=self.word,
         content=json.dumps(json.loads(self.content)),
         source='spanish',
     )
示例#2
0
文件: test_urban.py 项目: ilcic/zdict
 def test_query_normal(self, Record):
     self.dict._get_raw = Mock(return_value='{"mock": true}')
     self.dict.query('mock')
     Record.assert_called_with(
         word='mock',
         content='{"mock": true}',
         source='urban'
     )
示例#3
0
 def test_query_normal(self, Record):
     self.content_json = json.dumps(self.content)
     self.dict._get_raw = Mock(return_value=self.content_json)
     self.dict.query('Japanese', timeout=5)
     Record.assert_called_with(
         word='Japanese',
         content=self.content_json,
         source='jisho',
     )
示例#4
0
    def test_query_normal(self, Record):
        self.dict._get_raw = Mock(return_value=SAMPLE_RESPONSE)
        self.dict._get_app_key = Mock(return_value=('id', 'key'))

        self.dict.query('string')

        Record.assert_called_with(word='string',
                                  content=SAMPLE_RESPONSE,
                                  source='oxford')
示例#5
0
    def test_query_normal(self, Record):
        self.dict._get_raw = Mock(return_value=SAMPLE_RESPONSE)
        self.dict._get_app_key = Mock(return_value=('id', 'key'))

        self.dict.query('string')

        Record.assert_called_with(word='string',
                                  content=SAMPLE_RESPONSE,
                                  source='oxford')
示例#6
0
 def test_query_normal(self, Record):
     content = '''
     {"en":[{"partOfSpeech":"part_of_speech",
     "definitions":[{"definition":"definition","examples":["example"]}]}]}
     '''
     self.dict._get_raw = Mock(return_value=content)
     self.dict.query('mock')
     r_content = [{"part_of_speech": "part_of_speech",
                   "definitions": [{"definition": "definition",
                                    "examples": ["example"]}]}]
     Record.assert_called_with(
         word='mock',
         content=json.dumps(r_content),
         source='wiktionary'
     )
示例#7
0
 def test_query_normal(self, Record):
     content = '''
     {"en":[{"partOfSpeech":"part_of_speech",
     "definitions":[{"definition":"definition","examples":["example"]}]}]}
     '''
     self.dict._get_raw = Mock(return_value=content)
     self.dict.query('mock')
     r_content = [{
         "part_of_speech":
         "part_of_speech",
         "definitions": [{
             "definition": "definition",
             "examples": ["example"]
         }]
     }]
     Record.assert_called_with(word='mock',
                               content=json.dumps(r_content),
                               source='wiktionary')
示例#8
0
文件: test_moe.py 项目: zhengda/zdict
 def test_query_normal(self, Record):
     self.dict._get_raw = Mock(return_value='{}')
     self.dict.query('萌')
     Record.assert_called_with(word='萌', content='{}', source='moe')
示例#9
0
 def test_query_normal(self, Record):
     content = '{"code":200,"lang":"ru-en","text":["house"]}'
     self.dict._get_raw = Mock(return_value=content)
     self.dict.query('дом')
     Record.assert_called_with(word='дом', content=content, source='yandex')
示例#10
0
 def test_query_normal(self, Record):
     self.dict._get_raw = Mock(return_value='{"mock": true}')
     self.dict.query("mock", timeout=666)
     Record.assert_called_with(word="mock", content='{"mock": true}', source="urban")
示例#11
0
 def test_query_normal(self, Record):
     self.dict._get_raw = Mock(return_value='{"mock": true}')
     self.dict.query('mock')
     Record.assert_called_with(word='mock',
                               content='{"mock": true}',
                               source='urban')
示例#12
0
 def test_query_normal(self, Record):
     self.dict._get_raw = Mock(return_value='{}')
     self.dict.query('萌', timeout=666)
     Record.assert_called_with(word='萌', content='{}', source='moe')