def open_destination(self, dest): """If dest is a string, open a search for it in a dictionary, else if it is a Link model instance, open its destination. """ if isinstance(dest, basestring): self.dwnd.load_entry(macmillan.query_site(dest)) else: self.dwnd.load_entry(macmillan.query_site(dest.url))
def test_phrase_take_on(self): res = self.result_hook(query_site("take on")) # res.pprint() senses = res.senses # Entry.original_key self.assertEqual(res.original_key, 'take on') # len(Entry.senses) self.assertEqual(len(senses), 5) # Sense.definition self.assertEqual(senses[0].definition, 'to start to employ someone') # Sense.original_key self.assertEqual(senses[4].original_key, 'take on | take upon') self.assertEqual(senses[1].original_key, 'take on something') # len(Sense.examples) self.assertEqual(len(senses[1].examples), 2) # Example.content self.assertEqual(senses[1].examples[0].content, 'Our website is taking on a new look.') self.assertEqual(senses[4].examples[0].content, 'My mother took it on herself to invite them.') # Example.original_key self.assertEqual(senses[4].examples[0].original_key, 'take it on/upon yourself (to do something)')
def test_phrase_take_off(self): res = self.result_hook(query_site("take off")) senses = res.senses # Sense.style_level self.assertEqual(senses[4].style_level, 'informal') self.assertEqual(senses[5].style_level, 'informal') # Entry.url self.assertEqual(res.url, 'http://www.macmillandictionary.com/dictionary/british/take-off_1')
def test_phrase_take_off(self): res = self.result_hook(query_site("take off")) senses = res.senses # Sense.style_level self.assertEqual(senses[4].style_level, 'informal') self.assertEqual(senses[5].style_level, 'informal') # Entry.url self.assertEqual( res.url, 'http://www.macmillandictionary.com/dictionary/british/take-off_1')
def test_phrase_yours(self): res = self.result_hook(query_site("yours")) # Entry.intro_paragraph self.assertTrue('Her eyes are darker than yours are.' in res.intro_paragraph) s = 'It can refer to a singular or plural noun, and it can be the subject,' \ ' object, or complement of a verb or the object of a preposition' self.assertTrue(s in res.intro_paragraph) # Entry.pron self.assertEqual(res.pron, u'/jɔː(r)z/') # Entry.part_of_speech self.assertEqual(res.part_of_speech, 'pronoun') # Entry.url self.assertEqual(res.url, 'http://www.macmillandictionary.com/dictionary/british/yours_1')
def test_phrase_yours(self): res = self.result_hook(query_site("yours")) # Entry.intro_paragraph self.assertTrue( 'Her eyes are darker than yours are.' in res.intro_paragraph) s = 'It can refer to a singular or plural noun, and it can be the subject,' \ ' object, or complement of a verb or the object of a preposition' self.assertTrue(s in res.intro_paragraph) # Entry.pron self.assertEqual(res.pron, u'/jɔː(r)z/') # Entry.part_of_speech self.assertEqual(res.part_of_speech, 'pronoun') # Entry.url self.assertEqual( res.url, 'http://www.macmillandictionary.com/dictionary/british/yours_1')
def test_phrase_air(self): res = self.result_hook(query_site("air")) senses = res.senses # res.pprint() # Sense.style_level self.assertEqual(senses[3].style_level, 'old-fashioned') # Sense.subject_area self.assertEqual(senses[3].subject_area, 'music') # Sense.syntax_coding self.assertEqual(senses[3].syntax_coding, '[countable]') self.assertEqual(senses[2].syntax_coding, '[plural]') self.assertEqual(senses[1].syntax_coding, '[singular]') self.assertEqual(senses[0].syntax_coding, '[uncountable]') # Entry.pron self.assertEqual(res.pron, u'/eə(r)/') # Entry.part_of_speech self.assertEqual(res.part_of_speech, 'noun')
def dictionary(self, word): res = macmillan.query_site(word, plain_dict=True) return res
def test_phrase_yours_truly(self): res = self.result_hook(query_site("yours truly")) # Entry.style_level self.assertEqual(res.style_level, 'informal')
def test_look_up(self): res = self.result_hook(query_site("look up")) # Link.key self.assertEqual(res.links[0].key, u'look up to') # Link.part_of_speech self.assertEqual(res.links[0].part_of_speech, u'phrasal verb')
def makeView(self, s): res = macmillan.query_site(s) return DictEntryView(res)