aboutsummaryrefslogtreecommitdiff
path: root/tests/pypi.scm
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2016-12-18 10:53:27 +0100
committerRicardo Wurmus <rekado@elephly.net>2016-12-18 10:54:11 +0100
commit239f46325d554978cfc2d9dc63f1943527bfd360 (patch)
treef9cb0bfe2286b2cc26a72e5c4b243aae5a6a7439 /tests/pypi.scm
parent36a318adc715879fd7c07c6a7100db7c7d3292b7 (diff)
downloadguix-239f46325d554978cfc2d9dc63f1943527bfd360.tar
guix-239f46325d554978cfc2d9dc63f1943527bfd360.tar.gz
tests: Mock up http-fetch in import test.
This is a follow-up to commit 63773200d7ac68fcaee6efd9ffe8ea7aa3fafa38. * tests/pypi.scm ("pypi->guix-package, wheels"): Add mock definition of "http-fetch".
Diffstat (limited to 'tests/pypi.scm')
-rw-r--r--tests/pypi.scm64
1 files changed, 34 insertions, 30 deletions
diff --git a/tests/pypi.scm b/tests/pypi.scm
index 1f7ac2500a..f26e7fea13 100644
--- a/tests/pypi.scm
+++ b/tests/pypi.scm
@@ -148,10 +148,6 @@ baz > 13.37")
(mock ((guix import utils) url-fetch
(lambda (url file-name)
(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"
(begin
(mkdir "foo-1.0.0")
@@ -175,31 +171,39 @@ baz > 13.37")
(rename-file zip-file file-name))
(delete-file-recursively "foo-1.0.0.dist-info")))
(_ (error "Unexpected URL: " url)))))
- (match (pypi->guix-package "foo")
- (('package
- ('name "python-foo")
- ('version "1.0.0")
- ('source ('origin
- ('method 'url-fetch)
- ('uri (string-append "https://example.com/foo-"
- version ".tar.gz"))
- ('sha256
- ('base32
- (? string? hash)))))
- ('build-system 'python-build-system)
- ('propagated-inputs
- ('quasiquote
- (("python-bar" ('unquote 'python-bar))
- ("python-baz" ('unquote 'python-baz))
- ("python-setuptools" ('unquote 'python-setuptools)))))
- ('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)))))
+ (mock ((guix http-client) http-fetch
+ (lambda (url)
+ (match url
+ ("https://pypi.python.org/pypi/foo/json"
+ (values (open-input-string test-json)
+ (string-length test-json)))
+ ("https://example.com/foo-1.0.0-py2.py3-none-any.whl" #f)
+ (_ (error "Unexpected URL: " url)))))
+ (match (pypi->guix-package "foo")
+ (('package
+ ('name "python-foo")
+ ('version "1.0.0")
+ ('source ('origin
+ ('method 'url-fetch)
+ ('uri (string-append "https://example.com/foo-"
+ version ".tar.gz"))
+ ('sha256
+ ('base32
+ (? string? hash)))))
+ ('build-system 'python-build-system)
+ ('propagated-inputs
+ ('quasiquote
+ (("python-bar" ('unquote 'python-bar))
+ ("python-baz" ('unquote 'python-baz))
+ ("python-setuptools" ('unquote 'python-setuptools)))))
+ ('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")