How to use the pypistats._save_cache 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_cache.py View on Github external
def test_cache_round_trip(self):
        # Arrange
        filename = pypistats.CACHE_DIR / "test_cache_round_trip.json"
        data = "test data"

        # Act
        pypistats._save_cache(filename, data)
        new_data = pypistats._load_cache(filename)

        # Tidy up
        filename.unlink()

        # Assert
        self.assertEqual(new_data, data)
github hugovk / pypistats / tests / test_pypistats.py View on Github external
def setUp(self):
        # Stub caching. Caches are tested in another class.
        self.original__cache_filename = pypistats._cache_filename
        self.original__save_cache = pypistats._save_cache
        pypistats._cache_filename = stub__cache_filename
        pypistats._save_cache = stub__save_cache
github hugovk / pypistats / tests / test_pypistats.py View on Github external
def setUp(self):
        # Stub caching. Caches are tested in another class.
        self.original__cache_filename = pypistats._cache_filename
        self.original__save_cache = pypistats._save_cache
        pypistats._cache_filename = stub__cache_filename
        pypistats._save_cache = stub__save_cache
github hugovk / pypistats / tests / test_pypistats_cache.py View on Github external
def test__clear_cache(self):
        # Arrange
        # Create old cache file
        cache_file = pypistats.CACHE_DIR / "2018-11-26-old-cache-file.json"
        pypistats._save_cache(cache_file, data={})
        self.assertTrue(cache_file.exists())

        # Act
        pypistats._clear_cache()

        # Assert
        self.assertFalse(cache_file.exists())
github hugovk / pypistats / tests / test_pypistats.py View on Github external
def tearDown(self):
        # Unstub caching
        pypistats._cache_filename = self.original__cache_filename
        pypistats._save_cache = self.original__save_cache