def test_set_version():
    """should set preferred version"""
    bible = yvs.shared.get_bible_data('en')
    new_version = 59
    yvs.main('version:{}'.format(new_version))
    prefs = yvs.shared.get_prefs()
    nose.assert_equal(prefs['version'], new_version)
def test_set_language():
    """should set preferred language"""
    new_language = 'es'
    yvs.main('language:{}'.format(new_language))
    prefs = yvs.shared.get_prefs()
    nose.assert_equal(prefs['language'], new_language)
    bible = yvs.shared.get_bible_data(prefs['language'])
    nose.assert_equal(prefs['version'], bible['default_version'])
def test_main(out):
    """should pass preference data to setter"""
    alfred_variables = {
        'pref_id': 'version',
        'pref_name': 'version',
        'value_id': '107',
        'value_name': 'New English Translation'
    }
    yvs.main(alfred_variables)
    alfred_json = json.loads(out.getvalue())
    nose.assert_equals(alfred_json['alfredworkflow']['variables'],
                       alfred_variables)
    user_prefs = yvs.core.get_user_prefs()
    nose.assert_equals(user_prefs['version'], 107)
def test_main(out, set_pref):
    """should pass preference data to setter"""
    yvs.main(json.dumps({
        'pref': {'id': 'language', 'name': 'language'},
        'value': {'id': 'spa', 'name': 'Español'}
    }))
    set_pref.assert_called_once_with('language', 'spa')
    pref_set_data = json.loads(out.getvalue())
    nose.assert_not_equals(pref_set_data['alfredworkflow']['arg'], '')
    nose.assert_equals(
        pref_set_data['alfredworkflow']['variables']['pref_name'], 'language')
    nose.assert_equals(
        pref_set_data['alfredworkflow']['variables']['pref_id'], 'language')
    nose.assert_equals(
        pref_set_data['alfredworkflow']['variables']['value_id'], 'spa')
    nose.assert_equals(
        pref_set_data['alfredworkflow']['variables']['value_name'], 'Español')