File: test_pypi_client.py

package info (click to toggle)
python-azure 20250603%2Bgit-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 851,724 kB
  • sloc: python: 7,362,925; ansic: 804; javascript: 287; makefile: 195; sh: 145; xml: 109
file content (41 lines) | stat: -rw-r--r-- 1,561 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from pypi_tools.pypi import PyPIClient
from unittest.mock import patch
import os
import pytest
import pdb


class TestPyPiClient:
    @pytest.mark.skipif(
        os.environ.get("TF_BUILD", "None") == True,
        reason=f"This test isn't worth recording and could be flaky. Skipping in CI.",
    )
    def test_package_retrieve(self):
        client = PyPIClient()
        result = client.project("azure-core")

        # we won't _exhaustively_ check this, but we can sanity check a few proxy values to ensure we haven't broken anything
        assert result["info"]["name"] == "azure-core"
        assert len(result["releases"].keys()) > 47
        assert "1.25.1" in result["releases"]
        assert "1.10.0" in result["releases"]

    @pytest.mark.skipif(
        os.environ.get("TF_BUILD", "None") == True,
        reason=f"This test isn't worth recording and could be flaky. Skipping in CI.",
    )
    def test_package_version_retrieve(self):
        client = PyPIClient()
        result = client.project_release("azure-core", "1.8.0")

        assert result["info"]["name"] == "azure-core"
        assert result["info"]["release_url"] == "https://pypi.org/project/azure-core/1.8.0/"

    @patch("pypi_tools.pypi.sys")
    def test_package_filter_for_compatibility(self, mock_sys):
        mock_sys.version_info = (2, 7, 0)
        client = PyPIClient()
        result = client.get_ordered_versions("azure-core", True)
        unfiltered_results = client.get_ordered_versions("azure-core", False)

        assert len(result) < len(unfiltered_results)