From fc054f6f41bc2dd7c1bc76cbaf591771563287ab Mon Sep 17 00:00:00 2001 From: Zach Borboa Date: Sat, 28 Apr 2018 02:09:14 -0700 Subject: [PATCH] Add script to generate compressed urls test file. Omit the timestamp and the file name from the file header to make the file deterministic. Refresh the urls test file. --- tests/PHPCurlClass/urls.csv.gz | Bin 74129 -> 74120 bytes tests/generate_urls.py | 61 +++++++++++++++++++++++++++++++++ tests/generate_urls.sh | 10 ++++++ 3 files changed, 71 insertions(+) create mode 100755 tests/generate_urls.sh diff --git a/tests/PHPCurlClass/urls.csv.gz b/tests/PHPCurlClass/urls.csv.gz index 055d81d46ac7a94aa08da7883f8b915168c3be21..cc1972bae5fca90da7c9c4872c03fef1224a0ae5 100644 GIT binary patch delta 24 dcmbPun5E+|3zvL12LlK&F*gct6=tkc1OQJ!1!VvL delta 33 ocmeA;%rfyXi?Dn*2ghT^Cs9nyrA0Z#ddbCQ42@h{xftsd0mKFh#sB~S diff --git a/tests/generate_urls.py b/tests/generate_urls.py index fc28d16..ab468db 100644 --- a/tests/generate_urls.py +++ b/tests/generate_urls.py @@ -54,9 +54,70 @@ first_queries = ['', '?a=1', '?a=647&b=s564'] second_queries = ['', '?a=sdf', '?a=cvb&b=987'] fragments = ['', '#foo', '#bar'] +additional_tests = [ + { + 'args': [ + 'http://www.example.com/', + '', + ], + 'expected': 'http://www.example.com/', + }, + { + 'args': [ + 'http://www.example.com/', + 'foo', + ], + 'expected': 'http://www.example.com/foo', + }, + { + 'args': [ + 'http://www.example.com/', + '/foo', + ], + 'expected': 'http://www.example.com/foo', + }, + { + 'args': [ + 'http://www.example.com/', + '/foo/', + ], + 'expected': 'http://www.example.com/foo/', + }, + { + 'args': [ + 'http://www.example.com/', + '/dir/page.html', + ], + 'expected': 'http://www.example.com/dir/page.html', + }, + { + 'args': [ + 'http://www.example.com/dir1/page2.html', + '/dir/page.html', + ], + 'expected': 'http://www.example.com/dir/page.html', + }, + { + 'args': [ + 'http://www.example.com/dir1/page2.html', + 'dir/page.html', + ], + 'expected': 'http://www.example.com/dir1/dir/page.html', + }, + { + 'args': [ + 'http://www.example.com/dir1/dir3/page.html', + '../dir/page.html', + ], + 'expected': 'http://www.example.com/dir1/dir/page.html', + }, +] + with open('urls.csv', 'wt') as f: csvwriter = csv.writer(f, quotechar='"', quoting=csv.QUOTE_ALL) csvwriter.writerow(['first_url', 'second_url', 'expected']) + for test in additional_tests: + csvwriter.writerow([test['args'][0], test['args'][1], test['expected']]) for first_domain, second_domain in product(first_authorities, second_authorities): for first_path, second_path in product(first_paths, second_paths): for first_query, second_query in product(first_queries, second_queries): diff --git a/tests/generate_urls.sh b/tests/generate_urls.sh new file mode 100755 index 0000000..175f148 --- /dev/null +++ b/tests/generate_urls.sh @@ -0,0 +1,10 @@ +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +cd "${SCRIPT_DIR}" + +set -x + +python "generate_urls.py" && + ([[ -f "urls.csv.gz" ]] && rm --verbose "urls.csv.gz" || exit 0) && + gzip --verbose --best --no-name "urls.csv" && + gzip --verbose --test "urls.csv.gz" && + mv --verbose "urls.csv.gz" "PHPCurlClass/urls.csv.gz"