Ejemplo n.º 1
0
    def test_poolspecifier_add_cert(self):

        api = mock.create_autospec(BatchAppsApi)
        pool = PoolSpecifier(api)
        pool.add_cert("test_thumb")

        self.assertEqual(pool.certificates, [{
            'thumbprint': 'test_thumb',
            'thumbprintAlgorithm': 'SHA1',
            'storeLocation': 'CurrentUser',
            'storeName': 'My'
        }])

        pool.add_cert("test_thumb", store_location="test", store_name=None)

        self.assertEqual(pool.certificates, [{
            'thumbprint': 'test_thumb',
            'thumbprintAlgorithm': 'SHA1',
            'storeLocation': 'CurrentUser',
            'storeName': 'My'
        }, {
            'thumbprint': 'test_thumb',
            'thumbprintAlgorithm': 'SHA1',
            'storeLocation': 'test',
            'storeName': 'None'
        }])

        pool.id = None
        pool.certificates = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
        pool.add_cert("new_cert")
        self.assertEqual(pool.certificates, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
Ejemplo n.º 2
0
    def test_poolspecifier_create(self):
        """Test PoolSpecifier object"""

        api = mock.create_autospec(BatchAppsApi)
        pool = PoolSpecifier(api)
        self.assertEqual(pool.target_size, 0)
        self.assertEqual(pool.max_tasks, 1)
        self.assertEqual(pool.communication, False)
        self.assertEqual(pool.certificates, [])

        pool = PoolSpecifier(api,
                             target_size=5,
                             max_tasks=2,
                             communication=True)
        self.assertEqual(pool.target_size, 5)
        self.assertEqual(pool.max_tasks, 2)
        self.assertEqual(pool.communication, True)
        self.assertEqual(pool.certificates, [])
Ejemplo n.º 3
0
    def _auto_pool(self, size):
        """
        Create an autopoolspecification reference for use in job
        submission.

        :Returns:
            - A dictionary.
        """
        pool = PoolSpecifier(self._api, target_size=size)

        return {
            'targetDedicated': str(pool.target_size),
            'maxTasksPerTVM': str(pool.max_tasks),
            'communication': pool.communication,
            'certificateReferences': pool.certificates
        }
Ejemplo n.º 4
0
    def test_poolspecifier_start(self):
        """Test start"""

        api = mock.create_autospec(BatchAppsApi)
        api.add_pool.return_value.success = True
        api.add_pool.return_value.result = {
            'poolId': 'abc',
            'link': {
                'href': 'test.com'
            }
        }

        pool = PoolSpecifier(api)
        new_pool = pool.start()
        self.assertEqual(new_pool, {'id': 'abc', 'link': 'test.com'})
        api.add_pool.assert_called_with(0, 1, False, [])

        api.add_pool.return_value.success = False
        api.add_pool.return_value.result = RestCallException(
            None, "Test", None)
        with self.assertRaises(RestCallException):
            pool.start()