-
Notifications
You must be signed in to change notification settings - Fork 11
/
test_get_remote_script_full.py
57 lines (47 loc) · 1.69 KB
/
test_get_remote_script_full.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import httpretty
from uranium import get_remote_script
from uranium.build import Build
import pytest
SCRIPT_URL = "http://www.myinternalwebsite.com/uranium_base.py"
REMOTE_SCRIPT = """
def setup(build):
build.index_urls = ["http://www.myinternalwebsite.com/python_index"]
""".strip()
def test_get_remote_script(tmpdir):
httpretty.enable()
httpretty.register_uri(httpretty.GET, SCRIPT_URL,
body=REMOTE_SCRIPT)
script = get_remote_script(SCRIPT_URL)
build = Build(tmpdir.strpath)
script["setup"](build)
httpretty.disable()
httpretty.reset()
def test_get_remote_script_with_cache(tmpdir):
httpretty.enable()
httpretty.register_uri(httpretty.GET, SCRIPT_URL,
body=REMOTE_SCRIPT)
get_remote_script(SCRIPT_URL, cache_dir=tmpdir.strpath)
httpretty.disable()
httpretty.reset()
get_remote_script(SCRIPT_URL, cache_dir=tmpdir.strpath)
def test_build_include_cache(tmpdir):
httpretty.enable()
httpretty.register_uri(httpretty.GET, SCRIPT_URL,
body=REMOTE_SCRIPT)
build = Build(tmpdir.strpath)
build.URANIUM_CACHE_DIR = tmpdir.strpath
build.include(SCRIPT_URL, cache=True)
httpretty.disable()
httpretty.reset()
build.include(SCRIPT_URL, cache=True)
def test_build_include_without_cache(tmpdir):
httpretty.enable()
httpretty.register_uri(httpretty.GET, SCRIPT_URL,
body=REMOTE_SCRIPT)
build = Build(tmpdir.strpath)
build.URANIUM_CACHE_DIR = tmpdir.strpath
build.include(SCRIPT_URL, cache=False)
httpretty.disable()
httpretty.reset()
with pytest.raises(Exception):
build.include(SCRIPT_URL, cache=True)