Пример #1
0
 def test_search_words_boosts_word_over_meaning(self):
     WordSearchRepoTestCase.TestScenario() \
             .given_a_word(WordMeanings('cadell', [Meaning('', '', '', '', ['gosset'], [])])) \
             .given_a_word(WordMeanings('gosset', [Meaning('', '', '', '', ['cadell'], [])])) \
             .given_everythin_is_indexed() \
             .when_search_word('gosset') \
             .then_should_return(['gosset', 'cadell'])
Пример #2
0
 def test_two_meanings_should_be_returned_sorted_by_semantic_group(self):
     WordRepoTestCase.TestScenario() \
             .given_a_definition(word="piece", phonetic="ph2", scientific="lorem2", type="noun2",
                                 meaning="A small part2", extra_info="Typical word2",
                                 private_notes="secret2", synonyms="taste2, specimen2",
                                 related="data2, analysis2", origin="england2",
                                 semantic_field="statistics2", semantic_group=2,
                                 source="test data", reviewed=True, public=True) \
             .given_a_definition(word="piece", phonetic="ph", scientific="lorem", type="noun",
                                 meaning="A small part", extra_info="Typical word",
                                 private_notes="secret", synonyms="taste, specimen",
                                 related="data, analysis", origin="england",
                                 semantic_field="statistics", semantic_group=1,
                                 source="test data", reviewed=True, public=True) \
             .when_get_word_meanings("piece") \
             .then_should_return(WordMeanings(word="piece",
                                              meanings=[Meaning(scientific="lorem", type="noun",
                                                                description="A small part",
                                                                extra_info="Typical word",
                                                                synonym_words=["taste", "specimen"],
                                                                related_words=["data", "analysis"]),
                                                        Meaning(scientific="lorem2", type="noun2",
                                                                description="A small part2",
                                                                extra_info="Typical word2",
                                                                synonym_words=["taste2", "specimen2"],
                                                                related_words=["data2", "analysis2"])]))
Пример #3
0
 def test_returns_list_of_word_with_uri_and_200(self):
     TestAllWordsView.TestScenario() \
             .given_a_word_repo_that_returns([
                 WordMeanings(word='word_a', meanings=[
                     Meaning('s', 't', 'one', 'x', ['a', 'b 2'], ['c 1', 'b 2']),
                     Meaning('r', 'u', 'two', 'y', ['x', 'b2'], ['c1', 'w2'])
                 ]),
                 WordMeanings(word='word_b', meanings=[
                     Meaning('s', 'q', 'new', 'o', ['x', 'b2'], ['c1', 'w2'])
                 ]),
             ]) \
             .when_get_all_words_view() \
             .then_should_call_repo_get_all_words_meanings() \
             .then_should_response(200, [
                 {
                     'word': 'word_a',
                     'meanings': [
                         {
                             'scientific': 's',
                             'type': 't',
                             'description': 'one',
                             'extra_info': 'x',
                             'synonym_words': ['a', 'b 2'],
                             'related_words': ['c 1', 'b 2']
                         },
                         {
                             'scientific': 'r',
                             'type': 'u',
                             'description': 'two',
                             'extra_info': 'y',
                             'synonym_words': ['x', 'b2'],
                             'related_words': ['c1', 'w2']
                         }
                     ]
                 },
                 {
                     'word': 'word_b',
                     'meanings': [
                         {
                             'scientific': 's',
                             'type': 'q',
                             'description': 'new',
                             'extra_info': 'o',
                             'synonym_words': ['x', 'b2'],
                             'related_words': ['c1', 'w2']
                         },
                     ]
                 },
             ])
Пример #4
0
 def parse_meaning(self, orm_definition):
     return Meaning(scientific=orm_definition.scientific,
                    type=orm_definition.type,
                    description=orm_definition.meaning,
                    extra_info=orm_definition.extra_info,
                    synonym_words=orm_definition.synonyms.split(', ') if orm_definition.synonyms else [],
                    related_words=orm_definition.related.split(', ') if orm_definition.related else [])
Пример #5
0
 def test_get_all_words_meanings(self):
     WordRepoTestCase.TestScenario() \
             .given_a_definition(word='word_a', scientific='s', type='t', meaning='one',
                                 extra_info='x', synonyms="a, b 2", related="c 1, b 2", public=True) \
             .given_a_definition(word='word_a', scientific='r', type='u', meaning='two',
                                 extra_info='y', synonyms="x, b2", related="c1, w2", public=True) \
             .given_a_definition(word='word_b', scientific='s', type='q', meaning='new',
                                 extra_info='o', synonyms="x, b2", related="c1, w2", public=True) \
             .when_get_all_words() \
             .then_should_return([
                 WordMeanings(word='word_a', meanings=[
                     Meaning('s', 't', 'one', 'x', ['a', 'b 2'], ['c 1', 'b 2']),
                     Meaning('r', 'u', 'two', 'y', ['x', 'b2'], ['c1', 'w2'])
                 ]),
                 WordMeanings(word='word_b', meanings=[
                     Meaning('s', 'q', 'new', 'o', ['x', 'b2'], ['c1', 'w2'])
                 ]),
             ])
Пример #6
0
 def test_get_word_meanings_random(self):
     WordRepoTestCase.TestScenario() \
             .given_a_definition(word='a_word', scientific='s', type='t', meaning='one',
                                 extra_info='x', synonyms="a, b 2", related="c 1, b 2", public=True) \
             .given_a_definition(word='a_word', scientific='r', type='u', meaning='two',
                                 extra_info='y', synonyms="x, b2", related="c1, w2", public=True) \
             .given_a_definition(word='word_b', scientific='s', type='q', meaning='new',
                                 extra_info='o', synonyms="x, b2", related="c1, w2", public=True) \
             .given_a_definition(word='word_b', scientific='p', type='m', meaning='old',
                                 extra_info='u', synonyms="w, b3", related="c8, w9", public=True) \
             .given_everything_is_indexed() \
             .when_get_random_word_meanings() \
             .then_should_return_one_of([
                 WordMeanings(word='a_word', meanings=[
                     Meaning('s', 't', 'one', 'x', ['a', 'b 2'], ['c 1', 'b 2']),
                     Meaning('r', 'u', 'two', 'y', ['x', 'b2'], ['c1', 'w2'])
                 ]),
                 WordMeanings(word='word_b', meanings=[
                     Meaning('s', 'q', 'new', 'o', ['x', 'b2'], ['c1', 'w2']),
                     Meaning('p', 'm', 'old', 'u', ['w', 'b3'], ['c8', 'w9'])
                 ]),
             ])
Пример #7
0
    def test_if_word_daily_retrieves_and_returns_random_word_meanings_with_seed(
            self):
        meaning_a = Meaning(scientific='sc',
                            type='ty',
                            description='desc',
                            extra_info='e_i',
                            synonym_words=['a', 'b'],
                            related_words=['c', 'd'])
        meaning_b = Meaning(scientific='lorem',
                            type='noun',
                            description='word meaning',
                            extra_info='none',
                            synonym_words=[],
                            related_words=[])

        TestWordView.TestScenario() \
                .given_a_word_repo_that_returns_on_random(WordMeanings("Test", [meaning_a, meaning_b])) \
                .when_get_word_view("daily", seed=4) \
                .then_should_call_repo_get_random_word_meanings(seed=4) \
                .then_should_response(200, {'word': 'Test',
                    'meanings': [
                           {
                               'scientific': 'sc',
                               'type': 'ty',
                               'description': 'desc',
                               'extra_info': 'e_i',
                               'synonym_words': ['a', 'b'],
                               'related_words': ['c', 'd']
                           },
                           {
                               'scientific': 'lorem',
                               'type': 'noun',
                               'description': 'word meaning',
                               'extra_info': 'none',
                               'synonym_words': [],
                               'related_words': [],
                           },
                       ]})
Пример #8
0
 def test_search_words_meanings(self):
     WordRepoTestCase.TestScenario() \
             .given_a_definition(word='a_word', scientific='s', type='t', meaning='one target',
                                 extra_info='x', synonyms="a, b 2", related="c 1, b 2", public=True) \
             .given_a_definition(word='a_word', scientific='r', type='u', meaning='two',
                                 extra_info='y', synonyms="x, b2", related="c1, w2", public=True) \
             .given_a_definition(word='target', scientific='r', type='w', meaning='first',
                                 extra_info='q', synonyms="o, b9", related="c4, t2", public=True) \
             .given_a_definition(word='word_b', scientific='s', type='q', meaning='new',
                                 extra_info='o', synonyms="x, b2", related="c1, w2", public=True) \
             .given_a_definition(word='b_word', scientific='s', type='q', meaning='new',
                                 extra_info='o', synonyms="x, b2", related="c1, w2", public=True) \
             .given_everything_is_indexed() \
             .when_search_words_meanings('target') \
             .then_should_return([
                 WordMeanings(word='target', meanings=[
                     Meaning('r', 'w', 'first', 'q', ['o', 'b9'], ['c4', 't2'])
                 ]),
                 WordMeanings(word='a_word', meanings=[
                     Meaning('s', 't', 'one target', 'x', ['a', 'b 2'], ['c 1', 'b 2']),
                     Meaning('r', 'u', 'two', 'y', ['x', 'b2'], ['c1', 'w2'])
                 ]),
             ])
Пример #9
0
 def test_search_words_matches_by_related(self):
     WordSearchRepoTestCase.TestScenario() \
             .given_a_word(WordMeanings('lliri blanc', [Meaning('', '', '', '', [], ['assutzena'])])) \
             .given_everythin_is_indexed() \
             .when_search_word('assutzena') \
             .then_should_return(['lliri blanc'])
Пример #10
0
 def test_search_words_matches_by_synonyms(self):
     WordSearchRepoTestCase.TestScenario() \
             .given_a_word(WordMeanings('corna', [Meaning('', '', '', '', ['bana'], [])])) \
             .given_everythin_is_indexed() \
             .when_search_word('bana') \
             .then_should_return(['corna'])
Пример #11
0
 def test_search_words_matches_by_scientific(self):
     WordSearchRepoTestCase.TestScenario() \
             .given_a_word(WordMeanings('sègol', [Meaning('secale cereale', '', '', '', [], [])])) \
             .given_everythin_is_indexed() \
             .when_search_word('secale') \
             .then_should_return(['sègol'])
Пример #12
0
 def test_search_words_matches_by_description(self):
     WordSearchRepoTestCase.TestScenario() \
             .given_a_word(WordMeanings('mallorquer', [Meaning('', '', 'la planta del blat de moro', '', [], [])])) \
             .given_everythin_is_indexed() \
             .when_search_word('blat') \
             .then_should_return(['mallorquer'])