コード例 #1
0
ファイル: test_base.py プロジェクト: fossabot/kingpin-1
    def setUp(self, *args, **kwargs):
        super(TestRightScaleBaseActor, self).setUp()
        base.TOKEN = 'unittest'

        # Create the actor
        self.actor = base.RightScaleBaseActor(
            'Copy UnitTestArray to NewUnitArray', {})

        # Patch the actor so that we use the client mock
        self.client_mock = mock.MagicMock()
        self.actor._client = self.client_mock
コード例 #2
0
ファイル: test_base.py プロジェクト: teastburn/kingpin
    def test_generate_rightscale_params_with_pure_array(self):
        params = ['testA', 'testB', 'testC']
        expected_params = [
            ('resource_hrefs[]', 'testA'),
            ('resource_hrefs[]', 'testB'),
            ('resource_hrefs[]', 'testC'),
        ]

        actor = base.RightScaleBaseActor('Unit Test Action', {})
        ret = actor._generate_rightscale_params('resource_hrefs', params)

        self.assertEqual(expected_params, ret)
コード例 #3
0
ファイル: test_base.py プロジェクト: teastburn/kingpin
    def test_generate_rightscale_params_with_array(self):
        self.maxDiff = None
        schedule = [{
            'day': 'Sunday',
            'max_count': 2,
            'min_count': 1,
            'time': '07:00'
        }, {
            'day': 'Monday',
            'max_count': 2,
            'min_count': 1,
            'time': '07:00'
        }, {
            'day': 'Tuesday',
            'max_count': 2,
            'min_count': 1,
            'time': '07:00'
        }]
        params = {'elasticity_params': {'schedule': schedule}}

        expected_params = [
            [
                ('server_array[elasticity_params][schedule][][day]', 'Sunday'),
                ('server_array[elasticity_params][schedule][][max_count]', 2),
                ('server_array[elasticity_params][schedule][][min_count]', 1),
                ('server_array[elasticity_params][schedule][][time]', '07:00'),
            ],
            [
                ('server_array[elasticity_params][schedule][][day]', 'Monday'),
                ('server_array[elasticity_params][schedule][][max_count]', 2),
                ('server_array[elasticity_params][schedule][][min_count]', 1),
                ('server_array[elasticity_params][schedule][][time]', '07:00'),
            ],
            [('server_array[elasticity_params][schedule][][day]', 'Tuesday'),
             ('server_array[elasticity_params][schedule][][max_count]', 2),
             ('server_array[elasticity_params][schedule][][min_count]', 1),
             ('server_array[elasticity_params][schedule][][time]', '07:00')]
        ]

        actor = base.RightScaleBaseActor('Unit Test Action', {})
        ret = actor._generate_rightscale_params('server_array', params)

        # Relevant commit: d403420ccc482f2f91eab0eebd38100b3eff6344
        # Groups of 4 have to contain all the needed data

        # Break into chunks of 4 items.
        ret_chunks = list(zip(*[iter(ret)] * 4))

        self.assertCountEqual(expected_params[0], ret_chunks[0])
        self.assertCountEqual(expected_params[1], ret_chunks[1])
        self.assertCountEqual(expected_params[2], ret_chunks[2])
コード例 #4
0
ファイル: test_base.py プロジェクト: fossabot/kingpin-1
    def test_generate_rightscale_params(self):
        params = {'name': 'unittest-name',
                  'status': 'enabled',
                  'elasticity_params': {
                      'bounds': {
                          'min_count': 3,
                          'max_count': 10}}}
        expected_params = [
            ('server_array[status]', 'enabled'),
            ('server_array[name]', 'unittest-name'),
            ('server_array[elasticity_params][bounds][max_count]', 10),
            ('server_array[elasticity_params][bounds][min_count]', 3)]

        actor = base.RightScaleBaseActor('Unit Test Action', {})
        ret = actor._generate_rightscale_params('server_array', params)

        self.assertItemsEqual(expected_params, ret)
コード例 #5
0
ファイル: test_base.py プロジェクト: fossabot/kingpin-1
 def test_init_without_environment_creds(self):
     # Un-set the token and make sure the init fails
     base.TOKEN = None
     with self.assertRaises(exceptions.InvalidCredentials):
         base.RightScaleBaseActor('Unit Test Action', {})