File: test_instance_group_args.py

package info (click to toggle)
python-boto 2.49.0-4.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 9,888 kB
  • sloc: python: 86,396; makefile: 112
file content (57 lines) | stat: -rw-r--r-- 2,056 bytes parent folder | download | duplicates (13)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env python
# Author: Charlie Schluting <charlie@schluting.com>
#
# Test to ensure initalization of InstanceGroup object emits appropriate errors
# if bidprice is not specified, but allows float, int, Decimal.

from decimal import Decimal

from tests.compat import unittest
from boto.emr.instance_group import InstanceGroup


class TestInstanceGroupArgs(unittest.TestCase):

    def test_bidprice_missing_spot(self):
        """
        Test InstanceGroup init raises ValueError when market==spot and
        bidprice is not specified.
        """
        with self.assertRaisesRegexp(ValueError, 'bidprice must be specified'):
            InstanceGroup(1, 'MASTER', 'm1.small',
                          'SPOT', 'master')

    def test_bidprice_missing_ondemand(self):
        """
        Test InstanceGroup init accepts a missing bidprice arg, when market is
        ON_DEMAND.
        """
        instance_group = InstanceGroup(1, 'MASTER', 'm1.small',
                                       'ON_DEMAND', 'master')

    def test_bidprice_Decimal(self):
        """
        Test InstanceGroup init works with bidprice type = Decimal.
        """
        instance_group = InstanceGroup(1, 'MASTER', 'm1.small',
                                       'SPOT', 'master', bidprice=Decimal(1.10))
        self.assertEquals('1.10', instance_group.bidprice[:4])

    def test_bidprice_float(self):
        """
        Test InstanceGroup init works with bidprice type = float.
        """
        instance_group = InstanceGroup(1, 'MASTER', 'm1.small',
                                       'SPOT', 'master', bidprice=1.1)
        self.assertEquals('1.1', instance_group.bidprice)

    def test_bidprice_string(self):
        """
        Test InstanceGroup init works with bidprice type = string.
        """
        instance_group = InstanceGroup(1, 'MASTER', 'm1.small',
                                       'SPOT', 'master', bidprice='1.1')
        self.assertEquals('1.1', instance_group.bidprice)

if __name__ == "__main__":
    unittest.main()