-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest_assets.py
39 lines (29 loc) · 1.28 KB
/
test_assets.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import assets
from database_testing import DatabaseTest
from os import makedirs, remove
class TestDependencies(DatabaseTest):
resources = {
'dependency': assets.CSSResource(
'http://some.de/pendency/it/is.ok',
),
'dependency_with_integrity': assets.JSResource(
'http://some.de/pendency/it/is.ok',
'sha256-somehashcode'
)
}
def test_dependency_manager(self):
dm = assets.DependencyManager(self)
dm.third_party = self.resources
assert dm.get_dependency('dependency_with_integrity') == (
'<script src="http://some.de/pendency/it/is.ok" '
'integrity="sha256-somehashcode" crossorigin="anonymous"></script>'
)
assert dm.get_dependency('dependency') == '<link rel="stylesheet" href="http://some.de/pendency/it/is.ok">'
self.USE_CONTENT_DELIVERY_NETWORK = False
dm = assets.DependencyManager(self)
dm.third_party = self.resources
file_path = 'static/thirdparty/pendency/it/is.ok'
makedirs('static/thirdparty/pendency/it/', exist_ok=True)
open(file_path, 'w').close()
assert dm.get_dependency('dependency') == '<link rel="stylesheet" href="/static/thirdparty/pendency/it/is.ok">'
remove(file_path)