def test_query_npm_details(self):
        """
        Verify that the search npm endpoint returns the expected response.

        The response should be a status code 200 and send with the Content-Type
        of application/json.
        """
        package_string = json.dumps({
            "name": "pkgparse",
            "description": "A module for searching details about other "
                           "modules",
            "license": "MIT",
            "source_repo": "https://github.com/marcus-crane/pkgparse",
            "homepage": "",
            "package_page": "https://npmjs.com/package/pkgparse",
            "tarball": "https://registry.npmjs.org/pkgparse/-/"
                       "pkgparse-2.1.1.tgz",
            "latest_version": "2.1.1"
        }, sort_keys=True)

        data = utils.load_json_fixture('../fixtures/npm_pkg_latest.json')
        httpretty.register_uri(httpretty.GET,
                               "https://registry.npmjs.com/pkgparse/latest",
                               body=json.dumps(data))
        response = self.app.get('/npm/pkgparse')

        expected = json.loads(package_string)
        actual = json.loads(response.data)

        assert response.status_code == 200
        assert response.headers['Content-Type'] == 'application/json'
        assert actual == expected
Beispiel #2
0
    def test_query_rubygems_details(self):
        """
        Verify that the search rubygems endpoint returns the expected response.

        The response should be a status code 200 and send with the Content-Type
        of application/json.
        """
        package_string = json.dumps(
            {
                "name": "jekyll",
                "description": "Jekyll is a simple, blog aware, static site "
                "generator.",
                "license": "MIT",
                "source_repo": "https://github.com/jekyll/jekyll",
                "homepage": "",
                "package_page": "https://rubygems.org/gems/jekyll",
                "tarball": "https://rubygems.org/gems/jekyll-3.7.3.gem",
                "latest_version": "3.7.3"
            },
            sort_keys=True)

        data = utils.load_json_fixture('../fixtures/rubygems_pkg.json')
        httpretty.register_uri(httpretty.GET,
                               "https://rubygems.org/api/v1/gems/jekyll.json",
                               body=json.dumps(data))
        response = self.app.get('/rubygems/jekyll')

        expected = json.loads(package_string)
        actual = json.loads(response.data)

        assert response.status_code == 200
        assert response.headers['Content-Type'] == 'application/json'

        assert actual == expected
Beispiel #3
0
    def test_query_npm_details(self):
        """
        Verify that the search npm endpoint returns the expected response.

        The response should be a status code 200 and send with the Content-Type
        of application/json.
        """
        package_string = json.dumps(
            {
                "name": "pkgparse",
                "description": "A module for searching details about other "
                "modules",
                "license": "MIT",
                "source_repo": "https://github.com/marcus-crane/pkgparse",
                "homepage": "",
                "package_page": "https://npmjs.com/package/pkgparse",
                "tarball": "https://registry.npmjs.org/pkgparse/-/"
                "pkgparse-2.1.1.tgz",
                "latest_version": "2.1.1"
            },
            sort_keys=True)

        data = utils.load_json_fixture('../fixtures/npm_pkg_latest.json')
        httpretty.register_uri(httpretty.GET,
                               "https://registry.npmjs.com/pkgparse/latest",
                               body=json.dumps(data))
        response = self.app.get('/npm/pkgparse')

        expected = json.loads(package_string)
        actual = json.loads(response.data)

        assert response.status_code == 200
        assert response.headers['Content-Type'] == 'application/json'
        assert actual == expected
    def test_fetch_npm_pkg_details(self):
        """
        Test that given a valid NPM package name, it can fetch the response,
        parse the specific NPM JSON format and then do a generic repackaging
        of the information that it finds.
        """
        expected = {
            "name": "pkgparse",
            "description": "A module for searching details about other "
                           "modules",
            "license": "MIT",
            "source_repo": "https://github.com/marcus-crane/pkgparse",
            "homepage": "",
            "package_page": "https://npmjs.com/package/pkgparse",
            "tarball": "https://registry.npmjs.org/pkgparse/-"
                       "/pkgparse-2.1.1.tgz",
            "latest_version": "2.1.1"
        }

        body = utils.load_json_fixture('npm_pkg_latest.json')
        httpretty.register_uri(httpretty.GET,
                               "https://registry.npmjs.com/pkgparse/latest",
                               body=json.dumps(body))
        registry = NPMRegistry()
        actual = registry.fetch_pkg_details('pkgparse')

        assert actual == expected
    def test_fetch_rubygems_pkg_details(self):
        """
        Test that given a valid Rubygems package name, it can fetch the
        response, parse the specific Rubygems JSON format and then do a
        generic repackaging of the information that it finds.
        """
        expected = ({
            "name":
            "jekyll",
            "description":
            "Jekyll is a simple, blog aware, static site "
            "generator.",
            "license":
            "MIT",
            "source_repo":
            "https://github.com/jekyll/jekyll",
            "homepage":
            "",
            "package_page":
            "https://rubygems.org/gems/jekyll",
            "tarball":
            "https://rubygems.org/gems/jekyll-3.7.3.gem",
            "latest_version":
            "3.7.3"
        })

        body = utils.load_json_fixture('rubygems_pkg.json')
        httpretty.register_uri(httpretty.GET,
                               "https://rubygems.org/api/v1/gems/jekyll.json",
                               body=json.dumps(body))
        registry = RubygemsRegistry()
        actual = registry.fetch_pkg_details('jekyll')

        assert actual == expected
    def test_fetch_pypi_pkg_details(self):
        """
        Test that given a valid PyPi package name, it can fetch the response,
        parse the specific PyPi JSON format and then do a generic repackaging
        of the information that it finds.
        """
        expected = ({
            "name": "requests",
            "description": "Python HTTP for Humans.",
            "license": "Apache 2.0",
            "source_repo": "",
            "homepage": "http://python-requests.org",
            "package_page": "https://pypi.org/project/requests/",
            "tarball": "https://files.pythonhosted.org/packages/b0/e1/"
                        "eab4fc3752e3d240468a8c0b284607899d2fbfb236a56b7377a3"
                        "29aa8d09/requests-2.18.4.tar.gz",
            "latest_version": "2.18.4"
        })

        body = utils.load_json_fixture('pypi_pkg.json')
        httpretty.register_uri(httpretty.GET,
                               "https://pypi.org/pypi/requests/json",
                               body=json.dumps(body))
        registry = PypiRegistry()
        actual = registry.fetch_pkg_details('requests')

        assert actual == expected
    def test_query_pypi_details(self):
        """
        Verify that the search pypi endpoint returns the expected response.

        The response should be a status code 200 and send with the Content-Type
        of application/json.
        """
        package_string = json.dumps({
            "name": "requests",
            "description": "Python HTTP for Humans.",
            "license": "Apache 2.0",
            "source_repo": "",
            "homepage": "http://python-requests.org",
            "package_page": "https://pypi.org/project/requests/",
            "tarball": "https://files.pythonhosted.org/packages/b0/e1/"
                        "eab4fc3752e3d240468a8c0b284607899d2fbfb236a56b7377a3"
                        "29aa8d09/requests-2.18.4.tar.gz",
            "latest_version": "2.18.4"
        }, sort_keys=True)

        data = utils.load_json_fixture('pypi_pkg.json')
        httpretty.register_uri(httpretty.GET,
                               "https://pypi.org/pypi/requests/json",
                               body=json.dumps(data))
        response = self.app.get('/pypi/requests')

        expected = json.loads(package_string)
        actual = json.loads(response.data)

        assert response.status_code == 200
        assert response.headers['Content-Type'] == 'application/json'
        assert actual == expected
    def test_fetch_rubygems_pkg_details(self):
        """
        Test that given a valid Rubygems package name, it can fetch the
        response, parse the specific Rubygems JSON format and then do a
        generic repackaging of the information that it finds.
        """
        expected = ({
            "name": "jekyll",
            "description": "Jekyll is a simple, blog aware, static site "
                           "generator.",
            "license": "MIT",
            "source_repo": "https://github.com/jekyll/jekyll",
            "homepage": "",
            "package_page": "https://rubygems.org/gems/jekyll",
            "tarball": "https://rubygems.org/gems/jekyll-3.7.3.gem",
            "latest_version": "3.7.3"
        })

        body = utils.load_json_fixture('rubygems_pkg.json')
        httpretty.register_uri(httpretty.GET,
                               "https://rubygems.org/api/v1/gems/jekyll.json",
                               body=json.dumps(body))
        registry = RubygemsRegistry()
        actual = registry.fetch_pkg_details('jekyll')

        assert actual == expected
    def test_query_rubygems_details(self):
        """
        Verify that the search rubygems endpoint returns the expected response.

        The response should be a status code 200 and send with the Content-Type
        of application/json.
        """
        package_string = json.dumps({
            "name": "jekyll",
            "description": "Jekyll is a simple, blog aware, static site "
                           "generator.",
            "license": "MIT",
            "source_repo": "https://github.com/jekyll/jekyll",
            "homepage": "",
            "package_page": "https://rubygems.org/gems/jekyll",
            "tarball": "https://rubygems.org/gems/jekyll-3.7.3.gem",
            "latest_version": "3.7.3"
        }, sort_keys=True)

        data = utils.load_json_fixture('../fixtures/rubygems_pkg.json')
        httpretty.register_uri(httpretty.GET,
                               "https://rubygems.org/api/v1/gems/jekyll.json",
                               body=json.dumps(data))
        response = self.app.get('/rubygems/jekyll')

        expected = json.loads(package_string)
        actual = json.loads(response.data)

        assert response.status_code == 200
        assert response.headers['Content-Type'] == 'application/json'

        assert actual == expected
    def test_fetch_npm_pkg_details(self):
        """
        Test that given a valid NPM package name, it can fetch the response,
        parse the specific NPM JSON format and then do a generic repackaging
        of the information that it finds.
        """
        expected = {
            "name": "pkgparse",
            "description": "A module for searching details about other "
            "modules",
            "license": "MIT",
            "source_repo": "https://github.com/marcus-crane/pkgparse",
            "homepage": "",
            "package_page": "https://npmjs.com/package/pkgparse",
            "tarball": "https://registry.npmjs.org/pkgparse/-"
            "/pkgparse-2.1.1.tgz",
            "latest_version": "2.1.1"
        }

        body = utils.load_json_fixture('npm_pkg_latest.json')
        httpretty.register_uri(httpretty.GET,
                               "https://registry.npmjs.com/pkgparse/latest",
                               body=json.dumps(body))
        registry = NPMRegistry()
        actual = registry.fetch_pkg_details('pkgparse')

        assert actual == expected
Beispiel #11
0
    def test_fetch_nuget_pkg_details(self):
        """
        Test that given a valid NuGet package name, it can fetch the response,
        parse the specific NuGet JSON format and then do a generic repackaging
        of the information that it finds.
        """
        expected = {
            "name": "Newtonsoft.Json",
            "description": ("Json.NET is a popular high-performance "
                            "JSON framework for .NET"),
            "license": ("https://raw.github.com/JamesNK/Newtonsoft.Json"
                        "/master/LICENSE.md"),
            "source_repo": "",
            "homepage": "https://www.newtonsoft.com/json",
            "package_page": "https://www.nuget.org/packages/Newtonsoft.Json/",
            "tarball": "https://api.nuget.org/v3-flatcontainer/"
                        "newtonsoft.json/11.0.2/newtonsoft.json.11.0.2.nupkg",
            "latest_version": "11.0.2"
        }

        body = utils.load_json_fixture('nuget_pkg.json')
        httpretty.register_uri(httpretty.GET,
                               ("https://api.nuget.org/v3/registration3/"
                                "newtonsoft.json/index.json"),
                               body=json.dumps(body))
        registry = NugetRegistry()
        actual = registry.fetch_pkg_details('newtonsoft.json')

        assert actual == expected
    def test_query_nuget_details(self):
        """
        Verify that the search nuget endpoint returns the expected response.

        The response should be a status code 200 and send with the Content-Type
        of application/json.
        """
        package_string = json.dumps({
            "name": "Newtonsoft.Json",
            "description": ("Json.NET is a popular high-performance "
                            "JSON framework for .NET"),
            "license": ("https://raw.github.com/JamesNK/Newtonsoft.Json"
                        "/master/LICENSE.md"),
            "source_repo": "",
            "homepage": "https://www.newtonsoft.com/json",
            "package_page": "https://www.nuget.org/packages/Newtonsoft.Json/",
            "tarball": ("https://api.nuget.org/v3-flatcontainer/"
                        "newtonsoft.json/11.0.2/newtonsoft.json.11.0.2.nupkg"),
            "latest_version": "11.0.2"
        }, sort_keys=True)

        data = utils.load_json_fixture('../fixtures/nuget_pkg.json')
        httpretty.register_uri(httpretty.GET,
                               ("https://api.nuget.org/v3/registration3/"
                                "newtonsoft.json/index.json"),
                               body=json.dumps(data))
        response = self.app.get('/nuget/newtonsoft.json')

        expected = json.loads(package_string)
        actual = json.loads(response.data)

        assert response.status_code == 200
        assert response.headers['Content-Type'] == 'application/json'
        assert actual == expected
    def test_query_nuget_details(self):
        """
        Verify that the search nuget endpoint returns the expected response.

        The response should be a status code 200 and send with the Content-Type
        of application/json.
        """
        package_string = json.dumps(
            {
                "name":
                "Newtonsoft.Json",
                "description": ("Json.NET is a popular high-performance "
                                "JSON framework for .NET"),
                "license": ("https://raw.github.com/JamesNK/Newtonsoft.Json"
                            "/master/LICENSE.md"),
                "source_repo":
                "",
                "homepage":
                "https://www.newtonsoft.com/json",
                "package_page":
                "https://www.nuget.org/packages/Newtonsoft.Json/",
                "tarball":
                ("https://api.nuget.org/v3-flatcontainer/"
                 "newtonsoft.json/11.0.2/newtonsoft.json.11.0.2.nupkg"),
                "latest_version":
                "11.0.2"
            },
            sort_keys=True)

        data = utils.load_json_fixture('../fixtures/nuget_pkg.json')
        httpretty.register_uri(httpretty.GET,
                               ("https://api.nuget.org/v3/registration3/"
                                "newtonsoft.json/index.json"),
                               body=json.dumps(data))
        response = self.app.get('/nuget/newtonsoft.json')

        expected = json.loads(package_string)
        actual = json.loads(response.data)

        assert response.status_code == 200
        assert response.headers['Content-Type'] == 'application/json'
        assert actual == expected
Beispiel #14
0
    def test_query_pypi_details(self):
        """
        Verify that the search pypi endpoint returns the expected response.

        The response should be a status code 200 and send with the Content-Type
        of application/json.
        """
        package_string = json.dumps(
            {
                "name":
                "requests",
                "description":
                "Python HTTP for Humans.",
                "license":
                "Apache 2.0",
                "source_repo":
                "",
                "homepage":
                "http://python-requests.org",
                "package_page":
                "https://pypi.org/project/requests/",
                "tarball":
                "https://files.pythonhosted.org/packages/b0/e1/"
                "eab4fc3752e3d240468a8c0b284607899d2fbfb236a56b7377a3"
                "29aa8d09/requests-2.18.4.tar.gz",
                "latest_version":
                "2.18.4"
            },
            sort_keys=True)

        data = utils.load_json_fixture('pypi_pkg.json')
        httpretty.register_uri(httpretty.GET,
                               "https://pypi.org/pypi/requests/json",
                               body=json.dumps(data))
        response = self.app.get('/pypi/requests')

        expected = json.loads(package_string)
        actual = json.loads(response.data)

        assert response.status_code == 200
        assert response.headers['Content-Type'] == 'application/json'
        assert actual == expected
    def test_parse_rubygems_response(self):
        """
        Test that given a valid Rubygems package response, it can be parsed
        properly by implementing a parser for the Rubygems registry format
        """
        registry = RubygemsRegistry()
        response = utils.load_json_fixture('rubygems_pkg.json')
        actual = registry.parse_response(response)
        expected = {
            "name": "jekyll",
            "description": "Jekyll is a simple, blog aware, static site "
            "generator.",
            "license": "MIT",
            "source_repo": "https://github.com/jekyll/jekyll",
            "package_page": "https://rubygems.org/gems/jekyll",
            "tarball": "https://rubygems.org/gems/jekyll-3.7.3.gem",
            "latest_version": "3.7.3"
        }

        assert actual == expected
    def test_parse_rubygems_response(self):
        """
        Test that given a valid Rubygems package response, it can be parsed
        properly by implementing a parser for the Rubygems registry format
        """
        registry = RubygemsRegistry()
        response = utils.load_json_fixture('rubygems_pkg.json')
        actual = registry.parse_response(response)
        expected = {
            "name": "jekyll",
            "description": "Jekyll is a simple, blog aware, static site "
                           "generator.",
            "license": "MIT",
            "source_repo": "https://github.com/jekyll/jekyll",
            "package_page": "https://rubygems.org/gems/jekyll",
            "tarball": "https://rubygems.org/gems/jekyll-3.7.3.gem",
            "latest_version": "3.7.3"
        }

        assert actual == expected
 def test_parse_npm_response(self):
     """
     Test that given a valid NPM package response, it can be parsed
     properly by implementing a parser for the NPM registry format.
     """
     registry = NPMRegistry()
     response = utils.load_json_fixture('npm_pkg_latest.json')
     actual = registry.parse_response(response)
     expected = {
         "name": "pkgparse",
         "description": "A module for searching details about other "
                        "modules",
         "license": "MIT",
         "source_repo": "https://github.com/marcus-crane/pkgparse",
         "package_page": "https://npmjs.com/package/pkgparse",
         "tarball": "https://registry.npmjs.org/pkgparse/-"
                    "/pkgparse-2.1.1.tgz",
         "latest_version": "2.1.1"
     }
     assert actual == expected
 def test_parse_npm_response(self):
     """
     Test that given a valid NPM package response, it can be parsed
     properly by implementing a parser for the NPM registry format.
     """
     registry = NPMRegistry()
     response = utils.load_json_fixture('npm_pkg_latest.json')
     actual = registry.parse_response(response)
     expected = {
         "name": "pkgparse",
         "description": "A module for searching details about other "
         "modules",
         "license": "MIT",
         "source_repo": "https://github.com/marcus-crane/pkgparse",
         "package_page": "https://npmjs.com/package/pkgparse",
         "tarball": "https://registry.npmjs.org/pkgparse/-"
         "/pkgparse-2.1.1.tgz",
         "latest_version": "2.1.1"
     }
     assert actual == expected
    def test_parse_pypi_response(self):
        """
        Test that given a valid PyPi package response, it can be parsed
        properly by implementing a parser for the PyPi registry format
        """
        registry = PypiRegistry()
        response = utils.load_json_fixture('pypi_pkg.json')
        actual = registry.parse_response(response)
        expected = {
            "name": "requests",
            "description": "Python HTTP for Humans.",
            "license": "Apache 2.0",
            "homepage": "http://python-requests.org",
            "package_page": "https://pypi.org/project/requests/",
            "tarball": "https://files.pythonhosted.org/packages/b0/e1/"
                        "eab4fc3752e3d240468a8c0b284607899d2fbfb236a56b7377a3"
                        "29aa8d09/requests-2.18.4.tar.gz",
            "latest_version": "2.18.4"
        }

        assert actual == expected
Beispiel #20
0
 def test_parse_nuget_response(self):
     """
     Test that given a valid NuGet package response, it can be parsed
     properly by implementing a parser for the NuGet registry format.
     """
     registry = NugetRegistry()
     response = utils.load_json_fixture('nuget_pkg.json')
     actual = registry.parse_response(response)
     expected = {
         "name": "Newtonsoft.Json",
         "description": ("Json.NET is a popular high-performance "
                         "JSON framework for .NET"),
         "license": ("https://raw.github.com/JamesNK/Newtonsoft.Json"
                     "/master/LICENSE.md"),
         "homepage": "https://www.newtonsoft.com/json",
         "package_page": "https://www.nuget.org/packages/Newtonsoft.Json/",
         "tarball": "https://api.nuget.org/v3-flatcontainer/"
                     "newtonsoft.json/11.0.2/newtonsoft.json.11.0.2.nupkg",
         "latest_version": "11.0.2"
     }
     assert actual == expected