Esempio n. 1
0
def test_test_languages():
    data_ru = 'Привет'
    data_en = 'Hello'
    data_for_language = DataForLanguage()
    data_for_language.set_for_language('en', data_en)
    data_for_language.set_for_language('ru', data_ru)

    assert 'en' in data_for_language.get_languages()
    assert 'ru' in data_for_language.get_languages()

    assert 'en' in data_for_language
    assert 'ru' in data_for_language
Esempio n. 2
0
def test_set_get():
    test_data = 'hello'
    data_for_language = DataForLanguage()

    data_for_language.set_for_language('', test_data)
    assert data_for_language[''] == test_data
    assert data_for_language.get('') == test_data
    assert data_for_language.get('', None) == test_data
    assert data_for_language.is_empty() == False
Esempio n. 3
0
def test_set_get_several():
    data_ru = 'Привет'
    data_en = 'Hello'
    data_for_language = DataForLanguage()

    data_for_language.set_for_language('en', data_en)
    data_for_language.set_for_language('ru', data_ru)

    assert data_for_language['en'] == data_en
    assert data_for_language.get('en') == data_en
    assert data_for_language.get('en', None) == data_en

    assert data_for_language['ru'] == data_ru
    assert data_for_language.get('ru') == data_ru
    assert data_for_language.get('ru', None) == data_ru
Esempio n. 4
0
def test_init():
    data_for_language = DataForLanguage()
    assert data_for_language.get_languages() == []
    assert data_for_language.get('ru') is None
    assert data_for_language.get('ru', '') == ''
    assert data_for_language.is_empty()

    with pytest.raises(KeyError):
        _ = data_for_language['ru']
Esempio n. 5
0
def test_get_invalid():
    test_data = 'hello'
    data_for_language = DataForLanguage()

    data_for_language.set_for_language('en', test_data)

    assert data_for_language.get('ru') is None
    assert data_for_language.get('ru', '') == ''

    with pytest.raises(KeyError):
        _ = data_for_language['ru']
Esempio n. 6
0
def test_extract_data_for_language_05():
    data = DataForLanguage()
    data.set_for_language('en_US', 'John Smith')
    assert data.get('ru', '') == ''
Esempio n. 7
0
def test_extract_data_for_language_02():
    data = DataForLanguage()
    data.set_for_language('en', 'John')
    assert data.get('en_US', '') == 'John'