From: Cyril Roelandt <tipecaml@gmail.com>
To: guix-devel@gnu.org
Subject: [PATCH 5/5] import: pypi: Add more tests.
Date: Sat, 16 Jul 2016 17:23:25 +0200 [thread overview]
Message-ID: <1468682605-12622-6-git-send-email-tipecaml@gmail.com> (raw)
In-Reply-To: <1468682605-12622-1-git-send-email-tipecaml@gmail.com>
* tests/pypi.scm ("pypi->guix-package, no requirements", "pypi->guix-package,
no test requirements", "pypi->guix-package, no runtime requirements"): New
tests.
---
tests/pypi.scm | 137 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 137 insertions(+)
diff --git a/tests/pypi.scm b/tests/pypi.scm
index 7a38d6e..dd516c5 100644
--- a/tests/pypi.scm
+++ b/tests/pypi.scm
@@ -85,6 +85,143 @@ test-baz > 42.42")
(test-begin "pypi")
+(test-assert "pypi->guix-package, no requirements"
+ ;; Replace network resources with sample data.
+ (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")
+ ;; Do not create any requirements files.
+ (system* "tar" "czvf" file-name "foo-1.0.0/")
+ (delete-file-recursively "foo-1.0.0")
+ (set! test-source-hash
+ (call-with-input-file file-name port-sha256))))
+ ("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)
+ ('home-page "http://example.com")
+ ('synopsis "summary")
+ ('description "summary")
+ ('license 'lgpl2.0))
+ (string=? (bytevector->nix-base32-string
+ test-source-hash)
+ hash))
+ (x
+ (pk 'fail x #f)))))
+
+(test-assert "pypi->guix-package, no test requirements"
+ ;; Replace network resources with sample data.
+ (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")
+ ;; Create only the runtime requirements.
+ (with-output-to-file "foo-1.0.0/requirements.txt"
+ (lambda ()
+ (display test-requirements)))
+ (system* "tar" "czvf" file-name "foo-1.0.0/")
+ (delete-file-recursively "foo-1.0.0")
+ (set! test-source-hash
+ (call-with-input-file file-name port-sha256))))
+ ("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)))))
+ ('home-page "http://example.com")
+ ('synopsis "summary")
+ ('description "summary")
+ ('license 'lgpl2.0))
+ (string=? (bytevector->nix-base32-string
+ test-source-hash)
+ hash))
+ (x
+ (pk 'fail x #f)))))
+
+(test-assert "pypi->guix-package, no runtime requirements"
+ ;; Replace network resources with sample data.
+ (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")
+ ;; Create only the test requirements.
+ (with-output-to-file "foo-1.0.0/test-requirements.txt"
+ (lambda ()
+ (display test-test-requirements)))
+ (system* "tar" "czvf" file-name "foo-1.0.0/")
+ (delete-file-recursively "foo-1.0.0")
+ (set! test-source-hash
+ (call-with-input-file file-name port-sha256))))
+ ("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)
+ ('native-inputs
+ ('quasiquote
+ (("python-test-bar" ('unquote 'python-test-bar))
+ ("python-test-baz" ('unquote 'python-test-baz)))))
+ ('home-page "http://example.com")
+ ('synopsis "summary")
+ ('description "summary")
+ ('license 'lgpl2.0))
+ (string=? (bytevector->nix-base32-string
+ test-source-hash)
+ hash))
+ (x
+ (pk 'fail x #f)))))
+
(test-assert "pypi->guix-package"
;; Replace network resources with sample data.
(mock ((guix import utils) url-fetch
--
2.6.2
next prev parent reply other threads:[~2016-07-16 15:23 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-16 15:23 [PATCH 0/5] Improve the pypi updater Cyril Roelandt
2016-07-16 15:23 ` [PATCH 1/5] import: pypi: Move runtime dependencies to the propagated-inputs Cyril Roelandt
2016-07-16 15:23 ` [PATCH 2/5] import: pypi: Remove setuptools from the inputs Cyril Roelandt
2016-07-22 21:24 ` Ludovic Courtès
2016-07-22 21:43 ` Leo Famulari
2016-07-23 14:46 ` Cyril Roelandt
2016-07-25 21:07 ` Ludovic Courtès
2016-07-16 15:23 ` [PATCH 3/5] import: pypi: Compute test requirements when using wheels Cyril Roelandt
2016-07-22 21:28 ` Ludovic Courtès
2016-07-16 15:23 ` [PATCH 4/5] import: pypi: Compute test requirements when reading requirements files Cyril Roelandt
2016-07-22 21:30 ` Ludovic Courtès
2016-07-23 14:48 ` Cyril Roelandt
2016-07-25 21:12 ` Ludovic Courtès
2016-07-16 15:23 ` Cyril Roelandt [this message]
2016-07-22 21:31 ` [PATCH 5/5] import: pypi: Add more tests Ludovic Courtès
2016-07-17 16:30 ` [PATCH 0/5] Improve the pypi updater Hartmut Goebel
2016-07-22 21:22 ` Ludovic Courtès
2016-07-23 14:53 ` Cyril Roelandt
2016-07-25 21:14 ` Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1468682605-12622-6-git-send-email-tipecaml@gmail.com \
--to=tipecaml@gmail.com \
--cc=guix-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).