Skip to content
Snippets Groups Projects
Select Git revision
  • a427142812f893ca8da546b90046eb47c8200cd9
  • develop default protected
  • production protected
  • nixpkgs-upgrade-2025-06-16
  • nixpkgs-upgrade-2024-12-23
  • 190-our-regular-updates-fill-up-the-servers-boot-partitions
  • nixpkgs-upgrade-2024-10-14
  • hro-cloud protected
  • 162.flexible-grafana-module
  • nixpkgs-upgrade-2024-05-13
  • nixpkgs-upgrade-2024-04-22
  • nixpkgs-upgrade-2024-03-25
  • nixpkgs-upgrade-2024-03-18
  • nixpkgs-upgrade-2024-03-11
  • nixpkgs-upgrade-2024-03-04
  • 163.jp-to-ben-for-prod
  • nixpkgs-upgrade-2024-02-26
  • 164.grafana-alert-rules
  • 157.authorize-new-hro-key
  • nixpkgs-upgrade-2024-02-19
  • nixpkgs-upgrade-2024-02-12
21 results

docs.nix

Blame
  • fixtures.py 2.25 KiB
    # Copyright 2019 PrivateStorage.io, LLC
    #
    # Licensed under the Apache License, Version 2.0 (the "License");
    # you may not use this file except in compliance with the License.
    # You may obtain a copy of the License at
    #
    #     http://www.apache.org/licenses/LICENSE-2.0
    #
    # Unless required by applicable law or agreed to in writing, software
    # distributed under the License is distributed on an "AS IS" BASIS,
    # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    # See the License for the specific language governing permissions and
    # limitations under the License.
    
    """
    Common fixtures to let the test suite focus on application logic.
    """
    
    from __future__ import (
        absolute_import,
    )
    
    import attr
    
    from fixtures import (
        Fixture,
        TempDir,
    )
    
    from twisted.python.filepath import (
        FilePath,
    )
    
    from allmydata.storage.server import (
        StorageServer,
    )
    
    from ..model import (
        VoucherStore,
        memory_connect,
    )
    
    class AnonymousStorageServer(Fixture):
        """
        Supply an instance of allmydata.storage.server.StorageServer which
        implements anonymous access to Tahoe-LAFS storage server functionality.
    
        :ivar FilePath tempdir: The path to the server's storage on the
            filesystem.
    
        :ivar allmydata.storage.server.StorageServer storage_server: The storage
            server.
        """
        def _setUp(self):
            self.tempdir = FilePath(self.useFixture(TempDir()).join(b"storage"))
            self.storage_server = StorageServer(
                self.tempdir.asBytesMode().path,
                b"x" * 20,
            )
    
    
    @attr.s
    class TemporaryVoucherStore(Fixture):
        """
        Create a ``VoucherStore`` in a temporary directory associated with the
        given test case.
    
        :ivar get_config: A function like the one built by ``tahoe_configs``.
        :ivar get_now: A no-argument callable that returns a datetime giving a
            time to consider as "now".
    
        :ivar store: A newly created temporary store.
        """
        get_config = attr.ib()
        get_now = attr.ib()
    
        def _setUp(self):
            self.tempdir = self.useFixture(TempDir())
            self.config = self.get_config(self.tempdir.join(b"node"), b"tub.port")
            self.store = VoucherStore.from_node_config(
                self.config,
                self.get_now,
                memory_connect,
            )