1
|
|
|
#!/usr/bin/env python |
2
|
|
|
# -*- coding: UTF-8 -*- |
3
|
|
|
|
4
|
|
|
# Isomer - The distributed application framework |
5
|
|
|
# ============================================== |
6
|
|
|
# Copyright (C) 2011-2020 Heiko 'riot' Weinen <[email protected]> and others. |
7
|
|
|
# |
8
|
|
|
# This program is free software: you can redistribute it and/or modify |
9
|
|
|
# it under the terms of the GNU Affero General Public License as published by |
10
|
|
|
# the Free Software Foundation, either version 3 of the License, or |
11
|
|
|
# (at your option) any later version. |
12
|
|
|
# |
13
|
|
|
# This program is distributed in the hope that it will be useful, |
14
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
15
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16
|
|
|
# GNU Affero General Public License for more details. |
17
|
|
|
# |
18
|
|
|
# You should have received a copy of the GNU Affero General Public License |
19
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
20
|
|
|
|
21
|
|
|
""" |
22
|
|
|
Isomer - Backend |
23
|
|
|
|
24
|
|
|
Test Isomer Frontend Builder |
25
|
|
|
============================ |
26
|
|
|
|
27
|
|
|
|
28
|
|
|
""" |
29
|
|
|
|
30
|
|
|
import os |
31
|
|
|
import pytest |
32
|
|
|
|
33
|
|
|
from isomer.ui.builder import ( |
34
|
|
|
get_frontend_locations, |
35
|
|
|
generate_component_folders, |
36
|
|
|
get_components, |
37
|
|
|
update_frontends, |
38
|
|
|
get_sails_dependencies, |
39
|
|
|
install_dependencies, |
40
|
|
|
write_main, |
41
|
|
|
install_frontend, |
42
|
|
|
) |
43
|
|
|
|
44
|
|
|
try: |
45
|
|
|
import isomer.test as test |
46
|
|
|
except ImportError: |
47
|
|
|
test = None |
48
|
|
|
|
49
|
|
|
has_test_module = pytest.mark.skipif( |
50
|
|
|
test is None, |
51
|
|
|
reason="isomer-test-module not installed. See " |
52
|
|
|
"https://isomer.readthedocs.io/en/latest/dev/system/backend/modularity.html" |
53
|
|
|
"#modules", |
54
|
|
|
) |
55
|
|
|
|
56
|
|
|
# TODO: These last tests depend on working with the current copy of the source. |
57
|
|
|
# This is especially bad, if there are isomer modules installed, which might |
58
|
|
|
# bring in further dependencies. |
59
|
|
|
|
60
|
|
|
|
61
|
|
|
@has_test_module |
62
|
|
|
def test_install_dependencies(): |
63
|
|
|
pytest.reset_base() |
64
|
|
|
|
65
|
|
|
frontend_root, frontend_target = get_frontend_locations(True) |
66
|
|
|
|
67
|
|
|
component_folder = os.path.join(frontend_root, "src", "components") |
68
|
|
|
generate_component_folders(component_folder) |
69
|
|
|
|
70
|
|
|
components = get_components(frontend_root) |
71
|
|
|
|
72
|
|
|
installation_packages, imports = update_frontends(components, frontend_root, True) |
73
|
|
|
|
74
|
|
|
installation_packages += get_sails_dependencies(frontend_root) |
75
|
|
|
install_dependencies(installation_packages, frontend_root) |
76
|
|
|
|
77
|
|
|
target = os.path.join(frontend_root, "node_modules") |
78
|
|
|
|
79
|
|
|
assert os.path.exists(target) |
80
|
|
|
assert os.path.exists(os.path.join(target, "test-npm-update")) |
81
|
|
|
|
82
|
|
|
|
83
|
|
|
@has_test_module |
84
|
|
|
def test_rebuild_frontend(): |
85
|
|
|
pytest.reset_base() |
86
|
|
|
|
87
|
|
|
frontend_root, frontend_target = get_frontend_locations(True) |
88
|
|
|
|
89
|
|
|
component_folder = os.path.join(frontend_root, "src", "components") |
90
|
|
|
generate_component_folders(component_folder) |
91
|
|
|
|
92
|
|
|
components = get_components(frontend_root) |
93
|
|
|
|
94
|
|
|
installation_packages, imports = update_frontends(components, frontend_root, True) |
95
|
|
|
|
96
|
|
|
installation_packages += get_sails_dependencies(frontend_root) |
97
|
|
|
install_dependencies(installation_packages, frontend_root) |
98
|
|
|
|
99
|
|
|
write_main(imports, frontend_root) |
100
|
|
|
|
101
|
|
|
install_frontend(True, True, True, "build") |
102
|
|
|
|
103
|
|
|
assert os.path.exists(frontend_target) |
104
|
|
|
assert os.path.exists(os.path.join(frontend_target, "index.html")) |
105
|
|
|
assert os.path.exists(os.path.join(frontend_target, "assets")) |
106
|
|
|
|