예제 #1
0
    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={})
        assert cache_file.exists()

        # Act
        pypistats._clear_cache()

        # Assert
        assert not cache_file.exists()
예제 #2
0
    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
        assert new_data == data