How to use the pypistats.overall function in pypistats

To help you get started, we’ve selected a few pypistats examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hugovk / pypistats / tests / test_pypistats.py View on Github external
# Arrange
        package = "pip"
        mocked_url = "https://pypistats.org/api/packages/pip/overall"
        mocked_response = SAMPLE_RESPONSE_OVERALL
        expected_output = """
|    category     | downloads |
|-----------------|----------:|
| without_mirrors | 2,297,591 |

Date range: 2018-11-02 - 2018-11-02
"""

        # Act
        with requests_mock.Mocker() as m:
            m.get(mocked_url, text=mocked_response)
            output = pypistats.overall(package, mirrors=False, start_date="2018-11-02")

        # Assert
        self.assertEqual(output.strip(), expected_output.strip())
github hugovk / pypistats / tests / test_pypistats_cache.py View on Github external
"package": "pip",
          "type": "overall_downloads"
        }"""
        expected_output = """
|    category     | downloads |
|-----------------|----------:|
| without_mirrors | 2,295,765 |
"""

        # Act
        with requests_mock.Mocker() as m:
            m.get(mocked_url, text=mocked_response)
            # First time to save to cache
            pypistats.overall(package)
            # Second time to read from cache
            output = pypistats.overall(package)

        # Assert
        self.assertEqual(output.strip(), expected_output.strip())
github hugovk / pypistats / tests / test_pypistats.py View on Github external
# Arrange
        package = "pip"
        mocked_url = "https://pypistats.org/api/packages/pip/overall"
        mocked_response = SAMPLE_RESPONSE_OVERALL
        expected_output = """
|    category     | downloads |
|-----------------|----------:|
| without_mirrors | 2,295,765 |

Date range: 2018-11-01 - 2018-11-01
"""

        # Act
        with requests_mock.Mocker() as m:
            m.get(mocked_url, text=mocked_response)
            output = pypistats.overall(package, mirrors=False, end_date="2018-11-01")

        # Assert
        self.assertEqual(output.strip(), expected_output.strip())
github hugovk / pypistats / tests / test_pypistats_cache.py View on Github external
{"category": "without_mirrors", "date": "2018-11-01", "downloads": 2295765}
          ],
          "package": "pip",
          "type": "overall_downloads"
        }"""
        expected_output = """
|    category     | downloads |
|-----------------|----------:|
| without_mirrors | 2,295,765 |
"""

        # Act
        with requests_mock.Mocker() as m:
            m.get(mocked_url, text=mocked_response)
            # First time to save to cache
            pypistats.overall(package)
            # Second time to read from cache
            output = pypistats.overall(package)

        # Assert
        self.assertEqual(output.strip(), expected_output.strip())
github hugovk / pypistats / src / pypistats / cli.py View on Github external
def overall(args):  # pragma: no cover
    if args.mirrors in ["with", "without"]:
        args.mirrors = args.mirrors == "with"

    print(
        pypistats.overall(
            args.package,
            mirrors=args.mirrors,
            start_date=args.start_date,
            end_date=args.end_date,
            format=args.format,
            total="daily" if args.daily else ("monthly" if args.monthly else "all"),
            verbose=args.verbose,
        )