예제 #1
0
    def test_we_cache_files(self, assets_ini, loader):
        cached = _CachedFile(assets_ini, loader)
        cached.load()
        contents = cached.load()

        loader.assert_called_once()
        assert contents == self.ASSET_INI_CONTENTS
예제 #2
0
    def test_we_auto_reload_if_the_mtime_changes_aith_auto_reload_True(
            self, assets_ini, loader):
        cached = _CachedFile(assets_ini, loader, auto_reload=True)

        cached.load()
        self.age_file(assets_ini, -2000)  # 2 seconds into the future
        cached.load()

        assert loader.call_count == 2
예제 #3
0
    def test_we_read_from_the_cache_if_the_mtime_changes(
            self, assets_ini, loader):
        cached = _CachedFile(assets_ini, loader, auto_reload=False)

        cached.load()
        self.age_file(assets_ini, -2000)  # 2 seconds into the future
        cached.load()

        assert loader.call_count == 1
예제 #4
0
 def test_we_check_paths_when_created(self, loader):
     with pytest.raises(FileNotFoundError):
         _CachedFile("not_a_file.txt", loader)
예제 #5
0
    def test_we_can_load_a_file_outside_of_our_package(self, dockerfile,
                                                       loader):
        cached = _CachedFile(dockerfile, loader)
        contents = cached.load()

        assert contents == self.DOCKER_FILE_CONTENTS
예제 #6
0
    def test_we_can_load_a_file(self, assets_ini, loader):
        cached = _CachedFile(assets_ini, loader)
        contents = cached.load()

        assert contents == self.ASSET_INI_CONTENTS