Пример #1
0
def test_lookup_kamusslang_no_definition_found(mocker):
    side_effect_pair = {'close-word-suggestion-text': None, 'term-def': None}

    class FakeSoup:
        def find(self, class_):
            return side_effect_pair[class_]

    mocker.patch('tululbot.utils.slang.requests.get', autospec=True)
    mocker.patch('tululbot.utils.slang.BeautifulSoup',
                 return_value=FakeSoup(),
                 autospec=True)

    rv = lookup_kamusslang('jdflafj')

    assert rv is None
Пример #2
0
def test_lookup_kamusslang_no_definition_found(mocker):
    side_effect_pair = {
        'close-word-suggestion-text': None,
        'term-def': None
    }

    class FakeSoup:
        def find(self, class_):
            return side_effect_pair[class_]

    mocker.patch('tululbot.utils.slang.requests.get', autospec=True)
    mocker.patch('tululbot.utils.slang.BeautifulSoup', return_value=FakeSoup(), autospec=True)

    rv = lookup_kamusslang('jdflafj')

    assert rv is None
Пример #3
0
def test_lookup_kamusslang_close_word_suggestion(mocker):
    class FakeParagraph:
        def __init__(self, strings):
            self.strings = strings

    strings = ['asdf', 'alsjdf', 'kfdg']
    side_effect_pair = {
        'close-word-suggestion-text': 'Apalah',
        'term-def': FakeParagraph(strings)
    }

    class FakeSoup:
        def find(self, class_):
            return side_effect_pair[class_]

    mocker.patch('tululbot.utils.slang.requests.get', autospec=True)
    mocker.patch('tululbot.utils.slang.BeautifulSoup', return_value=FakeSoup(), autospec=True)

    rv = lookup_kamusslang('jdflafj')

    assert rv is None
Пример #4
0
def test_lookup_kamusslang_close_word_suggestion(mocker):
    class FakeParagraph:
        def __init__(self, strings):
            self.strings = strings

    strings = ['asdf', 'alsjdf', 'kfdg']
    side_effect_pair = {
        'close-word-suggestion-text': 'Apalah',
        'term-def': FakeParagraph(strings)
    }

    class FakeSoup:
        def find(self, class_):
            return side_effect_pair[class_]

    mocker.patch('tululbot.utils.slang.requests.get', autospec=True)
    mocker.patch('tululbot.utils.slang.BeautifulSoup',
                 return_value=FakeSoup(),
                 autospec=True)

    rv = lookup_kamusslang('jdflafj')

    assert rv is None