Beispiel #1
0
def test_resource_page_with_selected_language_links_to_language(get_languages, authenticated_flask_client):
    get_languages.return_value = [
        structures.Language('polish', 'pl'),
        structures.Language('dutch', 'nl'),
    ]
    response = authenticated_flask_client.get('/lang/pl/res/1/')
    assert re.search('<a class="[^"]*" href="/lang/nl/res/1/">\s*dutch\s*</a>', response.data.decode())
Beispiel #2
0
def test_home_shows_selected_language(get_language, get_languages, get_resources, authenticated_flask_client):
    get_resources.return_value = []
    get_languages.return_value = [
        structures.Language('dutch', 'nl'),
    ]
    get_language.return_value = structures.Language('dutch', 'nl')
    response = authenticated_flask_client.get('/lang/nl/')
    assert 'Language: dutch.' in response.data.decode()
Beispiel #3
0
def test_home_with_selected_language_links_to_resource_page(get_languages, get_resources, authenticated_flask_client):
    get_resources.return_value = []
    get_languages.return_value = [
        structures.Language('polish', 'pl'),
        structures.Language('dutch', 'nl'),
    ]
    response = authenticated_flask_client.get('/lang/pl/')
    assert '<title>Dila</title>' in response.data.decode()
    assert 'There are no resources.' in response.data.decode()
    assert re.search('<li class="active">\s*<a class="navbar-brand" href="/lang/pl/">\s*Select resource\s*</a>\s*</li>',
                     response.data.decode())
Beispiel #4
0
def test_home_with_selected_language_links_to_resource_page(get_languages, get_resources, authenticated_flask_client):
    get_languages.return_value = [
        structures.Language('polish', 'pl'),
        structures.Language('dutch', 'nl'),
    ]
    get_resources.return_value = [
        structures.Resource(
            '34',
            'nice_language'
        )
    ]
    response = authenticated_flask_client.get('/lang/pl/')
    assert re.search('<a href="/lang/pl/res/34/">\s*nice_language\s*</a>', response.data.decode())
Beispiel #5
0
 def as_data(self):
     return structures.Language(code=self.code, name=self.name)
Beispiel #6
0
def test_home_prompts_to_select_language(get_languages, get_resources, authenticated_flask_client):
    get_resources.return_value = []
    get_languages.return_value = [structures.Language('dutch', 'nl')]
    response = authenticated_flask_client.get('/')
    assert 'Select language.' in response.data.decode()
Beispiel #7
0
def test_resource_page_ensures_language_is_selected(get_languages, authenticated_flask_client):
    get_languages.return_value = [
        structures.Language('polish', 'pl')
    ]
    response = authenticated_flask_client.get('/res/1/')
    assert 'Select language' in response.data.decode()
Beispiel #8
0
def test_home_links_to_language(get_languages, authenticated_flask_client):
    get_languages.return_value = [
        structures.Language('polish', 'pl')
    ]
    response = authenticated_flask_client.get('/')
    assert re.search('<a class="[^"]*" href="/lang/pl/">\s*polish\s*</a>', response.data.decode())