tests: Mock up http-fetch in import test.

This is a follow-up to commit 63773200d7.

* tests/pypi.scm ("pypi->guix-package, wheels"): Add mock definition of
"http-fetch".
This commit is contained in:
Ricardo Wurmus 2016-12-18 10:53:27 +01:00
parent 36a318adc7
commit 239f46325d
No known key found for this signature in database
GPG key ID: 197A5888235FACAC

View file

@ -148,10 +148,6 @@ (define test-metadata
(mock ((guix import utils) url-fetch (mock ((guix import utils) url-fetch
(lambda (url file-name) (lambda (url file-name)
(match url (match url
("https://pypi.python.org/pypi/foo/json"
(with-output-to-file file-name
(lambda ()
(display test-json))))
("https://example.com/foo-1.0.0.tar.gz" ("https://example.com/foo-1.0.0.tar.gz"
(begin (begin
(mkdir "foo-1.0.0") (mkdir "foo-1.0.0")
@ -175,31 +171,39 @@ (define test-metadata
(rename-file zip-file file-name)) (rename-file zip-file file-name))
(delete-file-recursively "foo-1.0.0.dist-info"))) (delete-file-recursively "foo-1.0.0.dist-info")))
(_ (error "Unexpected URL: " url))))) (_ (error "Unexpected URL: " url)))))
(match (pypi->guix-package "foo") (mock ((guix http-client) http-fetch
(('package (lambda (url)
('name "python-foo") (match url
('version "1.0.0") ("https://pypi.python.org/pypi/foo/json"
('source ('origin (values (open-input-string test-json)
('method 'url-fetch) (string-length test-json)))
('uri (string-append "https://example.com/foo-" ("https://example.com/foo-1.0.0-py2.py3-none-any.whl" #f)
version ".tar.gz")) (_ (error "Unexpected URL: " url)))))
('sha256 (match (pypi->guix-package "foo")
('base32 (('package
(? string? hash))))) ('name "python-foo")
('build-system 'python-build-system) ('version "1.0.0")
('propagated-inputs ('source ('origin
('quasiquote ('method 'url-fetch)
(("python-bar" ('unquote 'python-bar)) ('uri (string-append "https://example.com/foo-"
("python-baz" ('unquote 'python-baz)) version ".tar.gz"))
("python-setuptools" ('unquote 'python-setuptools))))) ('sha256
('home-page "http://example.com") ('base32
('synopsis "summary") (? string? hash)))))
('description "summary") ('build-system 'python-build-system)
('license 'license:lgpl2.0)) ('propagated-inputs
(string=? (bytevector->nix-base32-string ('quasiquote
test-source-hash) (("python-bar" ('unquote 'python-bar))
hash)) ("python-baz" ('unquote 'python-baz))
(x ("python-setuptools" ('unquote 'python-setuptools)))))
(pk 'fail x #f))))) ('home-page "http://example.com")
('synopsis "summary")
('description "summary")
('license 'license:lgpl2.0))
(string=? (bytevector->nix-base32-string
test-source-hash)
hash))
(x
(pk 'fail x #f))))))
(test-end "pypi") (test-end "pypi")