예제 #1
0
    def test_client_setter(self, client, bg_system):
        """Create a Plugin with no client, set it once, but never change"""
        # Don't use the plugin fixture as it already has a client
        p = Plugin(bg_host="localhost", system=bg_system)
        assert p.client is None

        # Can set to None if already None
        p.client = None
        assert p.client is None

        p.client = client
        assert p.client == client

        with pytest.raises(AttributeError):
            p.client = None

        # Should still be the same client
        assert p.client == client
예제 #2
0
    def test_system_attributes_from_client(self, client):
        """Test that @system decorator and client docstring are used"""
        client._bg_name = "name"
        client._bg_version = "1.0.0"
        client.__doc__ = "Description\nSome more stuff"

        # Don't use plugin fixture as the _system name, version, doc are already set
        p = Plugin(bg_host="localhost")

        p.client = client
        assert p._system.name == "name"
        assert p._system.version == "1.0.0"
        assert p._system.description == "Description"