Ejemplo n.º 1
0
    def test_validate(self):
        with pytest.raises(ValueError):
            c = CmdHostCreate()
            c.validate()

        with pytest.raises(ValueError):
            c = CmdHostCreate()
            c.ami("ami")
            c.distro("distro")
            c.validate()

        with pytest.raises(ValueError):
            c = CmdHostCreate()
            c.ami("ami")
            c.validate()

        with pytest.raises(ValueError):
            c = CmdHostCreate()
            c.ami("ami")
            c.instance_type("type")
            c.validate()

        with pytest.raises(ValueError):
            c = CmdHostCreate()
            c.ami("ami")
            c.instance_type("type")
            c.security_group_id("id")
            c.validate()

        with pytest.raises(ValueError):
            c = CmdHostCreate()
            c.distro("distro")
            c.aws_id("id")
            c.validate()

        with pytest.raises(ValueError):
            c = CmdHostCreate()
            c.distro("distro")
            c.aws_id("id")
            c.aws_secret("secret")
            c.validate()

        with pytest.raises(ValueError):
            c = CmdHostCreate()
            c.distro("distro")
            c.aws_secret("secret")
            c.validate()

        with pytest.raises(ValueError):
            c = CmdHostCreate()
            c.distro("distro")
            c.key_name("key")
            c.validate()

        c = CmdHostCreate()
        c.distro("distro")
        c.validate()
Ejemplo n.º 2
0
    def test_parameters(self):
        c = CmdHostCreate()
        c.ami("ami")\
            .aws_id("aws_id")\
            .aws_secret("aws secret")\
            .distro("distro")\
            .instance_type("type")\
            .key_name("key")\
            .num_hosts(5)\
            .provider("ec2")\
            .region("east")\
            .retries(5)\
            .scope("build")\
            .security_group_id("sec group")\
            .spot()\
            .subnet_id("subnet 0")\
            .timeout_setup(100)\
            .timeout_teardown(200)\
            .userdata_file("file 1")\
            .vpc("vpc id")

        p = params(c)
        assert "ami" == p["ami"]
        assert "aws_id" == p["aws_access_key_id"]
        assert "aws secret" == p["aws_secret_access_key"]
        assert "distro" == p["distro"]
        assert "type" == p["instance_type"]
        assert "key" == p["key_name"]
        assert 5 == p["num_hosts"]
        assert "ec2" == p["provider"]
        assert "east" == p["region"]
        assert 5 == p["retries"]
        assert "build" == p["scope"]
        assert "sec group" == p["security_group_ids"][0]
        assert p["spot"]
        assert "subnet 0" == p["subnet_id"]
        assert 100 == p["timeout_setup_secs"]
        assert 200 == p["timeout_teardown_secs"]
        assert "file 1" == p["userdata_file"]
        assert "vpc id" == p["vpc_id"]
Ejemplo n.º 3
0
    def test_invalid_ami(self):
        c = CmdHostCreate()

        with pytest.raises(TypeError):
            c.ami(42)