Path:
tests/end2end/performance/200_and_304_based_asset_caching/01_main_page_serves_304/test_case.py
Lines:
64
Non-empty lines:
52
Non-empty lines covered with requirements:
52 / 52 (100.0%)
Functions:
2
Functions covered by requirements:
2 / 2 (100.0%)
1
"""2
@relation(SDOC-SRS-4, scope=file)3
"""4
5
import os
6
7
from tests.end2end.e2e_case import E2ECase
8
from tests.end2end.helpers.screens.project_index.screen_project_index import (
9
Screen_ProjectIndex,
10
)11
from tests.end2end.server import SDocTestServer
12
13
path_to_this_test_file_folder = os.path.dirname(os.path.abspath(__file__))
14
15
16
class Test(E2ECase):
17
def test(self):
18
with SDocTestServer(
19
input_path=path_to_this_test_file_folder
20
) as test_server:
21
with open(
22
test_server.path_to_out_log, encoding="utf8"
23
) as out_log_file:
24
logs = out_log_file.read()
25
assert '"GET / HTTP/1.1" 200 OK' not in logs
26
assert '"GET / HTTP/1.1" 304 Not Modified' not in logs
27
assert '"GET /_static/turbo.js HTTP/1.1" 200 OK' not in logs
28
assert (
29
'"GET /_static/turbo.js HTTP/1.1" 304 Not Modified' not in logs
30
)31
32
self.open(test_server.get_host_and_port())
33
34
screen_project_index = Screen_ProjectIndex(self)
35
screen_project_index.assert_on_screen()
36
37
with open(
38
test_server.path_to_out_log, encoding="utf8"
39
) as out_log_file:
40
logs = out_log_file.read()
41
42
assert '"GET / HTTP/1.1" 200 OK' in logs
43
assert '"GET / HTTP/1.1" 304 Not Modified' not in logs
44
assert '"GET /_static/turbo.min.js HTTP/1.1" 200 OK' in logs
45
assert (
46
'"GET /_static/turbo.min.js HTTP/1.1" 304 Not Modified'47
not in logs
48
)49
50
# Opening for the second time should result in 304 records in the log.51
self.open(test_server.get_host_and_port())
52
53
with open(
54
test_server.path_to_out_log, encoding="utf8"
55
) as out_log_file:
56
logs = out_log_file.read()
57
58
# The HTML pages as well as the assets get cached.59
assert '"GET / HTTP/1.1" 200 OK' in logs
60
assert '"GET / HTTP/1.1" 304 Not Modified' in logs
61
assert '"GET /_static/turbo.min.js HTTP/1.1" 200 OK' in logs
62
assert (
63
'"GET /_static/turbo.min.js HTTP/1.1" 304 Not Modified' in logs
64
)