<commit_before># tests.test_search_ref

import nose.tools as nose
import yvs.search_ref as yvs
from mock import patch
from tests.decorators import use_prefs


@patch('webbrowser.open')
def test_url_open_chapter(wb_open):
    """should open chapter search URL"""
    yvs.main('59/jhn.3')
    wb_open.assert_called_once_with(
        'https://www.google.com/search?q=John+3+%28ESV%29')


@patch('webbrowser.open')
def test_url_open_verse(wb_open):
    """should open verse search URL"""
    yvs.main('59/jhn.3.17')
    wb_open.assert_called_once_with(
        'https://www.google.com/search?q=John+3%3A17+%28ESV%29')


@patch('webbrowser.open')
def test_url_open_verse_range(wb_open):
    """should open verse range search URL"""
    yvs.main('59/jhn.3.16-17')
    wb_open.assert_called_once_with(
        'https://www.google.com/search?q=John+3%3A16-17+%28ESV%29')


@use_prefs({'searchEngine': 'duckduckgo'})
@patch('webbrowser.open')
def test_alternate_search_engine(wb_open):
    """should search using alternate search engine in one is chosen"""
    yvs.main('59/jhn.3')
    wb_open.assert_called_once_with(
        'https://duckduckgo.com/?q=John+3+%28ESV%29')


@use_prefs({'searchEngine': 'xyz'})
@patch('webbrowser.open')
def test_invalid_search_engine(wb_open):
    """should throw exception if nonexistent web browser is given"""
    with nose.assert_raises(Exception):
        yvs.main('59/jhn.3')


@use_prefs({'language': 'es', 'version': 128})
@patch('webbrowser.open')
def test_unicode_search(wb_open):
    """should open search URL for reference containing Unicode"""
    yvs.main('128/exo.4')
    wb_open.assert_called_once_with(
        'https://www.google.com/search?q=%C3%89xodo+4+%28NVI%29')


@patch('webbrowser.open')
def test_invalid_uid(wb_open):
    """should throw exception when UID for a nonexistent reference is given"""
    with nose.assert_raises(Exception):
        yvs.main('64/xyz.7')<commit_msg>Fix search ref test bugs that cancelled each other out<commit_after># tests.test_search_ref

import nose.tools as nose
import yvs.search_ref as yvs
from mock import patch
from tests.decorators import use_prefs


@patch('webbrowser.open')
def test_url_open_chapter(wb_open):
    """should open chapter search URL"""
    yvs.main('59/jhn.3')
    wb_open.assert_called_once_with(
        'https://www.google.com/search?q=John+3+%28ESV%29')


@patch('webbrowser.open')
def test_url_open_verse(wb_open):
    """should open verse search URL"""
    yvs.main('59/jhn.3.17')
    wb_open.assert_called_once_with(
        'https://www.google.com/search?q=John+3%3A17+%28ESV%29')


@patch('webbrowser.open')
def test_url_open_verse_range(wb_open):
    """should open verse range search URL"""
    yvs.main('59/jhn.3.16-17')
    wb_open.assert_called_once_with(
        'https://www.google.com/search?q=John+3%3A16-17+%28ESV%29')


@use_prefs({'language': 'en', 'version': 111, 'searchEngine': 'duckduckgo'})
@patch('webbrowser.open')
def test_alternate_search_engine(wb_open):
    """should search using alternate search engine in one is chosen"""
    yvs.main('59/jhn.3')
    wb_open.assert_called_once_with(
        'https://duckduckgo.com/?q=John+3+%28ESV%29')


@use_prefs({'language': 'en', 'version': 111, 'searchEngine': 'xyz'})
@patch('webbrowser.open')
def test_invalid_search_engine(wb_open):
    """should throw exception if nonexistent web browser is given"""
    with nose.assert_raises(Exception):
        yvs.main('59/jhn.3')


@use_prefs({'language': 'es', 'version': 128, 'searchEngine': 'google'})
@patch('webbrowser.open')
def test_unicode_search(wb_open):
    """should open search URL for reference containing Unicode"""
    yvs.main('128/exo.4')
    wb_open.assert_called_once_with(
        'https://www.google.com/search?q=%C3%89xodo+4+%28NVI%29')


@patch('webbrowser.open')
def test_invalid_uid(wb_open):
    """should throw exception when UID for a nonexistent reference is given"""
    with nose.assert_raises(Exception):
        yvs.main('64/xyz.7')
{'fraction_non_alphanumeric': 0.1546933667083855, 'fraction_numerical': 0.03504380475594493, 'mean_word_length': 4.791304347826087, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 10, 'lorem ipsum': 0, 'www.': 8, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6685638', 'n_tokens_mistral': 1550, 'n_tokens_neox': 1447, 'n_words': 262}