コード例 #1
0
    def test_block_device(self):
        c = CmdHostCreate()
        c.block_device("name", "100", "200", "id")

        p = params(c)["ebs_block_device"]
        assert "name" == p["device_name"]
        assert "100" == p["ebs_iops"]
        assert "200" == p["ebs_size"]
        assert "id" == p["ebs_snapshot_id"]
コード例 #2
0
    def test_invalid_timeout_teardown(self):
        c = CmdHostCreate()

        with pytest.raises(TypeError):
            c.timeout_teardown("string")

        with pytest.raises(ValueError):
            c.timeout_teardown(-5)

        with pytest.raises(ValueError):
            c.timeout_teardown(10000000)
コード例 #3
0
    def test_invalid_num_hosts(self):
        c = CmdHostCreate()

        with pytest.raises(TypeError):
            c.num_hosts("string")

        with pytest.raises(ValueError):
            c.num_hosts(-5)

        with pytest.raises(ValueError):
            c.num_hosts(10000000)
コード例 #4
0
ファイル: test_operations.py プロジェクト: dbradf/shrub.py
    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"]
コード例 #5
0
    def test_invalid_vpc(self):
        c = CmdHostCreate()

        with pytest.raises(TypeError):
            c.vpc(42)
コード例 #6
0
    def test_invalid_userdata_file(self):
        c = CmdHostCreate()

        with pytest.raises(TypeError):
            c.userdata_file(42)
コード例 #7
0
    def test_invalid_scope(self):
        c = CmdHostCreate()

        with pytest.raises(ValueError):
            c.scope("hello")
コード例 #8
0
    def test_invalid_retries(self):
        c = CmdHostCreate()

        with pytest.raises(TypeError):
            c.retries("hello")
コード例 #9
0
    def test_invalid_region(self):
        c = CmdHostCreate()

        with pytest.raises(TypeError):
            c.region(42)
コード例 #10
0
    def test_invalid_provider(self):
        c = CmdHostCreate()

        with pytest.raises(ValueError):
            c.provider("me")
コード例 #11
0
    def test_invalid_distro(self):
        c = CmdHostCreate()

        with pytest.raises(TypeError):
            c.distro(42)
コード例 #12
0
    def test_invalid_aws_secret(self):
        c = CmdHostCreate()

        with pytest.raises(TypeError):
            c.aws_secret(42)
コード例 #13
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()
コード例 #14
0
    def test_command_basics(self):
        c = CmdHostCreate()

        assert "host.create" == command_name(c)