コード例 #1
0
    def test_api_get_project_by_ecosystem(self):
        """ Test the api_get_project_ecosystem function of the API. """
        create_distro(self.session)
        output = self.app.get("/api/by_ecosystem/pypi/pypi_and_npm")
        self.assertEqual(output.status_code, 404)
        data = _read_json(output)

        exp = {
            "error": 'No project "pypi_and_npm" found in ecosystem "pypi"',
            "output": "notok",
        }
        self.assertEqual(data, exp)

        create_ecosystem_projects(self.session)

        output = self.app.get("/api/by_ecosystem/pypi/not-a-project")
        self.assertEqual(output.status_code, 404)
        data = _read_json(output)

        exp = {
            "error": 'No project "not-a-project" found in ecosystem "pypi"',
            "output": "notok",
        }
        self.assertEqual(data, exp)

        output = self.app.get("/api/by_ecosystem/pypi/pypi_and_npm")
        self.assertEqual(output.status_code, 200)
        data = _read_json(output)

        del data["created_on"]
        del data["updated_on"]

        exp = {
            "id": 1,
            "backend": "PyPI",
            "homepage": "https://example.com/not-a-real-pypi-project",
            "ecosystem": "pypi",
            "name": "pypi_and_npm",
            "regex": None,
            "version": None,
            "version_url": None,
            "versions": [],
            "stable_versions": [],
            "packages": [],
        }

        self.assertEqual(data, exp)
コード例 #2
0
ファイル: test_flask_api.py プロジェクト: fedora-infra/anitya
    def test_api_get_project_by_ecosystem(self):
        """ Test the api_get_project_ecosystem function of the API. """
        create_distro(self.session)
        output = self.app.get("/api/by_ecosystem/pypi/pypi_and_npm")
        self.assertEqual(output.status_code, 404)
        data = _read_json(output)

        exp = {
            "error": 'No project "pypi_and_npm" found in ecosystem "pypi"',
            "output": "notok",
        }
        self.assertEqual(data, exp)

        create_ecosystem_projects(self.session)

        output = self.app.get("/api/by_ecosystem/pypi/not-a-project")
        self.assertEqual(output.status_code, 404)
        data = _read_json(output)

        exp = {
            "error": 'No project "not-a-project" found in ecosystem "pypi"',
            "output": "notok",
        }
        self.assertEqual(data, exp)

        output = self.app.get("/api/by_ecosystem/pypi/pypi_and_npm")
        self.assertEqual(output.status_code, 200)
        data = _read_json(output)

        del data["created_on"]
        del data["updated_on"]

        exp = {
            "id": 1,
            "backend": "PyPI",
            "homepage": "https://example.com/not-a-real-pypi-project",
            "ecosystem": "pypi",
            "name": "pypi_and_npm",
            "regex": None,
            "version": None,
            "version_url": None,
            "versions": [],
            "packages": [],
        }

        self.assertEqual(data, exp)