Beispiel #1
0
    def test_koha_booklist_is_a_provider(self, client, tmp_db,
                                         koha_booklist_prov):
        URL = '/status/koha-booklist'
        response = client.get(URL)

        # We have an answer...
        assert response.status_code == OK

        # ...it's an HTML document...
        assert response.mimetype == "text/html"

        # Let's convert it for easy inspection
        data = response.get_data(as_text=True)

        # Test if we recieved a full HTML page
        assert is_html5_page(data)

        assert has_page_title(data, "Koha booklist Status report")
        assert has_header_title(data, "Koha booklist")
        assert has_header_subtitle(data, "Status report")

        assert has_form(data)

        # Do we have the essential info in it
        form_groups = all_form_groups(data)

        assert form_groups["Name"] == "koha booklist"
        assert form_groups["Slug"] == "koha-booklist"
        assert form_groups[
            "Remote url"] == "https://koha.bulac.fr/cgi-bin/koha/opac-shelves.pl?op=view&shelfnumber={param}&sortfield=title"
        assert form_groups[
            "Result selector"] == "#usershelves .searchresults table tr td:not(.select)"
        assert form_groups["No result selector"] == ""
        assert form_groups["No result content"] == ""
Beispiel #2
0
    def test_provider_has_status_page(self, client, tmp_db, fake_serv,
                                      fake_prov):
        URL = '/status/fake-server'
        response = client.get(URL)

        # We have an answer...
        assert response.status_code == OK

        # ...it's an HTML document...
        assert response.mimetype == "text/html"

        # Let's convert it for easy inspection
        data = response.get_data(as_text=True)

        # Test if we recieved a full HTML page
        assert is_html5_page(data)

        # Do we have the essential info in it
        # Provider name
        assert has_page_title(data, "Fake server Status report")
        assert has_header_title(data, "Fake server")
        assert has_header_subtitle(data, "Status report")

        assert has_form(data)

        form_groups = all_form_groups(data)

        assert form_groups["Name"] == fake_prov.name
        assert form_groups["Slug"] == fake_prov.slug
        assert form_groups["Remote url"] == fake_prov.remote_url
        assert form_groups["Result selector"] == fake_prov.result_selector
        assert form_groups[
            "No result selector"] == fake_prov.no_result_selector
        assert form_groups["No result content"] == fake_prov.no_result_content
Beispiel #3
0
    def test_koha_search_is_a_provider(self, client, tmp_db, koha_search_prov):
        URL = '/status/koha-search'
        response = client.get(URL)

        # We have an answer...
        assert response.status_code == OK

        # ...it's an HTML document...
        assert response.mimetype == "text/html"

        # Let's convert it for easy inspection
        data = response.get_data(as_text=True)

        # Test if we recieved a full HTML page
        assert is_html5_page(data)

        assert has_page_title(data, "Koha search Status report")
        assert has_header_title(data, "Koha search")
        assert has_header_subtitle(data, "Status report")

        assert has_form(data)

        # Do we have the essential info in it
        form_groups = all_form_groups(data)

        assert form_groups["Name"] == "koha search"
        assert form_groups["Slug"] == "koha-search"
        assert form_groups[
            "Remote url"] == "https://koha.bulac.fr/cgi-bin/koha/opac-search.pl?idx=&q={param}&branch_group_limit="
        assert form_groups[
            "Result selector"] == "#userresults .searchresults #bookbag_form table tr td.bibliocol"
        assert form_groups["No result selector"] == ".span12 p"
        assert form_groups[
            "No result content"] == "Aucune réponse trouvée dans le catalogue BULAC."
Beispiel #4
0
    def test_has_new_provider_page(self, client, tmp_db):
        response = client.get('/provider/new')

        # We have an answer...
        assert response.status_code == OK

        # ...it's an HTML page
        assert response.mimetype == "text/html"

        # Let's convert it for easy inspection
        data = response.get_data(as_text=True)

        # Test if we recieved a full HTML page
        assert is_html5_page(data)

        assert has_page_title(data, "Provider Add a new provider")
        assert has_header_title(data, "Provider")
        assert has_header_subtitle(data, "Add a new provider")

        assert has_form(data)

        # Do we have the essential info in it
        form_groups = all_form_groups(data)

        assert form_groups["Name"] == ""
        assert form_groups["Remote url"] == ""
        assert form_groups["Result selector"] == ""
        assert form_groups["No result selector"] == ""
        assert form_groups["No result content"] == ""

        # Do we have a button to validate the form ?
        assert has_form_submit_button(data)
Beispiel #5
0
    def test_has_status_page(self, client, tmp_db, bulac_prov):
        response = client.get('/status')

        # We have an answer...
        assert response.status_code == OK

        # ...it's an HTML page
        assert response.mimetype == "text/html"

        # Let's convert it for easy inspection
        data = response.get_data(as_text=True)

        # Test if we recieved a full HTML page
        assert is_html5_page(data)

        assert has_page_title(data, "Mincer Status report")
        assert has_header_title(data, "Mincer")
        assert has_header_subtitle(data, "Status report")

        assert has_table(data)
        assert "Provider's name" in all_table_column_headers(data)
        assert "Server online?" in all_table_column_headers(data)
        assert "Server responding?" in all_table_column_headers(data)
        assert "Correctly formed answer?" in all_table_column_headers(data)

        with mincer.app.test_request_context('/status'):
            links = all_links(data)
            # Test the presence of essencial links
            assert url_for("provider_status",
                           provider_slug="koha-search") in links
            assert url_for("provider_status",
                           provider_slug="koha-booklist") in links
Beispiel #6
0
    def test_has_home_page(self, client, tmp_db, bulac_prov):
        response = client.get('/')

        # We have an answer...
        assert response.status_code == OK

        # ...it's an HTML document...
        assert response.mimetype == "text/html"

        # Let's convert it for easy inspection
        data = response.get_data(as_text=True)

        # Test if we recieved a full HTML page
        assert is_html5_page(data)

        assert has_page_title(data, "Mincer Home")
        assert has_header_title(data, "Mincer")
        assert has_header_subtitle(data, "Home")

        # Test the presence of essenciel links
        with mincer.app.test_request_context('/'):
            links = all_links(data)

            # Do we have providers view links
            assert url_for("provider_status",
                           provider_slug="koha-search") in links
            assert url_for("provider_status",
                           provider_slug="koha-booklist") in links

            # TODO add direct link to edit provider
            # # Do we have providers edit links?
            # assert url_for(
            #     "providers",
            #     provider_slug="koha-search") in links
            # assert url_for(
            #     "providers",
            #     provider_slug="koha-booklist") in links

            # Do we have providers remove links?

            # Do we have new provider link?
            assert url_for("provider_new") in links

            # Do we have admin links?
            assert url_for("status") in links
            assert url_for("admin") in links
Beispiel #7
0
    def test_has_admin_page(self, client, tmp_db):
        response = client.get('/admin')

        # We have an answer...
        assert response.status_code == OK

        # ...it's an HTML page
        assert response.mimetype == "text/html"

        # Let's convert it for easy inspection
        data = response.get_data(as_text=True)

        # Test if we recieved a full HTML page
        assert is_html5_page(data)

        assert has_page_title(data, "Mincer Administration")
        assert has_header_title(data, "Mincer")
        assert has_header_subtitle(data, "Administration")

        assert has_form(data)

        # Do we have the essential info in it
        form_groups = all_form_groups(data)

        # Do we have all the fields needed with the correct initial values ?
        dependencies = {e.name: e for e in Dependency.query.all()}
        assert form_groups["JQuery minified javascript"]\
            == dependencies["jquery-js"].url
        assert form_groups["JQuery minified javascript SHA"]\
            == dependencies["jquery-js"].sha

        assert form_groups["Popper minified javascript"]\
            == dependencies["popper-js"].url
        assert form_groups["Popper minified javascript SHA"]\
            == dependencies["popper-js"].sha

        assert form_groups["Bootstrap minified javascript"]\
            == dependencies["bootstrap-js"].url
        assert form_groups["Bootstrap minified javascript SHA"]\
            == dependencies["bootstrap-js"].sha

        assert form_groups["Bootstrap minified CSS"]\
            == dependencies["bootstrap-css"].url
        assert form_groups["Bootstrap minified CSS SHA"]\
            == dependencies["bootstrap-css"].sha

        assert form_groups["Font-Awesome minified CSS"]\
            == dependencies["font-awesome-css"].url
        assert form_groups["Font-Awesome minified CSS SHA"]\
            == dependencies["font-awesome-css"].sha

        # Do we have a button to validate the form ?
        assert has_form_submit_button(data)

        # Do we have the good links to all ressources ?
        links = all_links(data)
        # Places to get the ressources
        assert "https://code.jquery.com/" in links
        assert "https://github.com/FezVrasta/popper.js#installation" in links
        assert "https://www.bootstrapcdn.com/" in links
        # Hash generator to ensure the ressources are correct using SRI
        assert "https://www.srihash.org/" in links
        # Doc about SRI
        assert "https://hacks.mozilla.org/2015/09/subresource-integrity-in-firefox-43/" in links