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
|
element = driver.find_element_by_tag_name('title')
|
30
|
title = driver.execute_script('return arguments[0].innerText;', element)
|
31
|
assert "Schrodinger's Document" in title
|
32
|
|
33
|
def test_script_loader(execute_in_page, load_into_page):
|
34
|
"""
|
35
|
A trivial test case that verifies Haketilo's .js files can be properly
|
36
|
loaded into a test page together with their dependencies.
|
37
|
"""
|
38
|
load_into_page('common/stored_types.js', ['common'],
|
39
|
page='https://gotmyowndoma.in')
|
40
|
|
41
|
assert execute_in_page('returnval(TYPE_PREFIX.VAR);') == '_'
|