Commit 9fdd114e authored by Lucas Carvalho's avatar Lucas Carvalho Committed by Łukasz Nowak

Added tests for the previous: d603986d.

parent 9c333b3f
......@@ -425,3 +425,21 @@ Buildout can download the content using the new certificate, because it still av
Got demoneeded 1.2c1.
<BLANKLINE>
###############
# PARSING URL #
###############
Check if the parsing url method works correctly, in low-level:
>>> get_filename_from_url("http://localhost/lib/patch/?id=700c7d5382b01f94e7141")
'patch'
Check if the networkcache upload method is using the correct method to
parse the original url and get the file name:
>>> tmp_dir = tmpdir('tmp_dir')
>>> write(tmp_dir, 'tmp_file', 'Content of temp file.')
>>> get_filename_from_upload_network_cached(
... dir_url=globals().get('nc_url') + 'shadir',
... cache_url=globals().get('nc_url') + 'shacache',
... external_url="http://localhost/lib/patch/?id=700c7d5382b01f94e7141",
... path=globals().get('tmp_dir') + '/tmp_file',
... nc_server_path=sample_buildout)
'patch'
......@@ -37,6 +37,7 @@ import json
import zc.buildout.buildout
import zc.buildout.easy_install
import zc.buildout.networkcache
from zc.buildout.rmtree import rmtree
fsync = getattr(os, 'fsync', lambda fileno: None)
......@@ -293,6 +294,33 @@ def make_buildout(executable=None):
# Reinstate the default values of the installer.
set_installer_values(installer_values)
def get_filename_from_upload_network_cached(**kw):
""" Check the upload network cache. """
import logging
import json
logger = logging.getLogger('zc.buildout')
nc_server_path = kw.pop('nc_server_path')
default_params = dict(logger=logger,
signature_certificate_file='',
signature_private_key_file=None)
kw.update(default_params)
zc.buildout.networkcache.upload_network_cached(**kw)
# check the file created.
external_url = kw.get('external_url')
dir_key = zc.buildout.networkcache.get_directory_key(external_url)
file_path = os.path.join(nc_server_path, 'shadir', dir_key)
f = open(file_path)
try:
data = f.read()
finally:
f.close()
data_list = json.loads(data)
property_dict = data_list[0][0]
return str(property_dict.get('file'))
def buildoutSetUp(test):
test.globs['__tear_downs'] = __tear_downs = []
......@@ -437,7 +465,9 @@ def buildoutSetUp(test):
create_signature_file_list = create_signature_file_list,
buildout = os.path.join(sample, 'bin', 'buildout'),
wait_until = wait_until,
make_py = make_py
make_py = make_py,
get_filename_from_url = zc.buildout.networkcache.get_filename_from_url,
get_filename_from_upload_network_cached = get_filename_from_upload_network_cached,
))
def buildoutTearDown(test):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment