1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2014 David Thompson <davet@gnu.org>
4 ;;; This file is part of GNU Guix.
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
19 (define-module (test-pypi)
20 #:use-module (guix import pypi)
21 #:use-module (guix base32)
22 #:use-module (guix hash)
23 #:use-module (guix tests)
24 #:use-module (srfi srfi-64)
25 #:use-module (ice-9 match))
30 \"version\": \"1.0.0\",
32 \"license\": \"GNU LGPL\",
33 \"summary\": \"summary\",
34 \"home_page\": \"http://example.com\",
39 \"url\": \"https://example.com/foo-1.0.0.egg\",
40 \"packagetype\": \"bdist_egg\",
42 \"url\": \"https://example.com/foo-1.0.0.tar.gz\",
43 \"packagetype\": \"sdist\",
54 (test-assert "pypi->guix-package"
55 ;; Replace network resources with sample data.
56 (mock ((guix import utils) url-fetch
57 (lambda (url file-name)
58 (with-output-to-file file-name
62 ("https://pypi.python.org/pypi/foo/json"
64 ("https://example.com/foo-1.0.0.tar.gz"
66 (_ (error "Unexpected URL: " url))))))))
67 (match (pypi->guix-package "foo")
73 ('uri ('string-append "https://example.com/foo-"
78 ('build-system 'python-build-system)
81 (("python-setuptools" ('unquote 'python-setuptools)))))
82 ('home-page "http://example.com")
84 ('description "summary")
86 (string=? (bytevector->nix-base32-string
87 (call-with-input-string test-source port-sha256))
95 (exit (= (test-runner-fail-count (test-runner-current)) 0))