def check_versioned_source_paths(self):
        """Check expected paths when using versions."""
        resolver = create_path_resolver(DummyContext())

        assert resolver.home(V_0_9_0_1) == "/opt/kafka-0.9.0.1"
        assert resolver.bin(V_0_9_0_1) == "/opt/kafka-0.9.0.1/bin"
        assert resolver.script("kafka-run-class.sh", V_0_9_0_1) == "/opt/kafka-0.9.0.1/bin/kafka-run-class.sh"
    def check_paths(self):
        """Check expected path resolution without any version specified."""
        resolver = create_path_resolver(DummyContext())

        assert resolver.home() == "/opt/kafka-trunk"
        assert resolver.bin() == "/opt/kafka-trunk/bin"
        assert resolver.script("kafka-run-class.sh") == "/opt/kafka-trunk/bin/kafka-run-class.sh"
    def check_create_path_resolver_override(self):
        """Test override behavior when instantiating a path resolver using our factory function.

        If context.globals has an entry for a path resolver class, use that class instead of the default.
        """
        mock_context = DummyContext()
        mock_context.globals[KAFKA_PATH_RESOLVER_KEY] = \
            "unit.directory_layout.check_project_paths.DummyPathResolver"

        resolver = create_path_resolver(mock_context)
        assert type(resolver) == DummyPathResolver
    def check_node_or_version_helper(self):
        """KafkaSystemTestPathResolver has a helper method which can take a node or version, and returns the version.
        Check expected behavior here.
        """
        resolver = create_path_resolver(DummyContext())

        # Node with no version attribute should resolve to TRUNK
        node = DummyNode()
        assert resolver._version(node) == TRUNK

        # Node with version attribute should resolve to the version attribute
        node.version = V_0_9_0_1
        assert resolver._version(node) == V_0_9_0_1

        # A KafkaVersion object should resolve to itself
        assert resolver._version(TRUNK) == TRUNK
        version = KafkaVersion("999.999.999")
        assert resolver._version(version) == version
 def check_create_path_resolver_default(self):
     """Test default behavior when instantiating a path resolver using our factory function.
     """
     resolver = create_path_resolver(DummyContext())
     assert type(resolver) == KafkaSystemTestPathResolver