Project

General

Profile

Download (1.78 KB) Statistics
| Branch: | Tag: | Revision:

haketilo / test / unit / test_basic.py @ c699b640

1
# SPDX-License-Identifier: CC0-1.0
2

    
3
"""
4
Haketilo unit tests - base
5
"""
6

    
7
# This file is part of Haketilo
8
#
9
# Copyright (C) 2021, Wojtek Kosior
10
#
11
# This program is free software: you can redistribute it and/or modify
12
# it under the terms of the CC0 1.0 Universal License as published by
13
# the Creative Commons Corporation.
14
#
15
# This program is distributed in the hope that it will be useful,
16
# but WITHOUT ANY WARRANTY; without even the implied warranty of
17
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
# CC0 1.0 Universal License for more details.
19

    
20
import pytest
21

    
22
def test_driver(driver):
23
    """
24
    A trivial test case that verifies mocked web pages served by proxy can be
25
    accessed by the browser driven.
26
    """
27
    for proto in ['http://', 'https://']:
28
        driver.get(proto + 'gotmyowndoma.in')
29
        title = driver.execute_script(
30
            'return document.getElementsByTagName("title")[0].innerText;'
31
        )
32
        assert "Schrodinger's Document" in title
33

    
34
def test_script_loader(execute_in_page, load_into_page):
35
    """
36
    A trivial test case that verifies Haketilo's .js files can be properly
37
    loaded into a test page together with their dependencies.
38
    """
39
    load_into_page('common/stored_types.js', ['common'],
40
                   page='https://gotmyowndoma.in')
41

    
42
    assert execute_in_page('returnval(TYPE_PREFIX.VAR);') == '_'
43

    
44
@pytest.mark.ext_data({})
45
def test_webextension(driver, webextension):
46
    """
47
    A trivial test case that verifies a test WebExtension created and installed
48
    by the `webextension` fixture works and redirects specially-constructed URLs
49
    to its test page.
50
    """
51
    heading = driver.execute_script(
52
        'return document.getElementsByTagName("h1")[0].innerText;'
53
    )
54
    assert "Extension's options page for testing" in heading
(3-3/6)