def test_json_policies_api_set_virtual_directory2(self, mock_put):
     '''
         Tests when requests gets a 500 response from forum
     '''
     test_name = sys._getframe().f_code.co_name
      
     model = VirtualDirectory()  # noqa: E501
     model.name = "bill"
     mock_resp = helper._mock_response(status=500,raise_for_status="internal error")
     mock_put.return_value = mock_resp
      
     with self.assertRaises(ForumHTTPError) as e: 
         created = self._api.set_virtual_directory('bill', 'bob',model)
      
    #print e.exception.message
     self.assertEqual(500, e.exception.cause.response.status_code)
     self.assertIn('internal error', e.exception.message)
Exemplo n.º 2
0
    def setUp(self):
        # FIXME: update assignements for none string types e.g boolean and int
        self._unique_id = self.id_generator()
        self._model = VirtualDirectory()  # noqa: E501

        self._model.acl_policy = self._unique_id
        self._model.remote_path = self._unique_id
        self._model.virtual_host = self._unique_id
        self._model.name = self._unique_id
        self._model.enabled = self._unique_id
        self._model.listener_policy = self._unique_id
        self._model.description = self._unique_id
        self._model.request_process_type = 'TASK_LIST_GROUP'
        self._model.virtual_path = self._unique_id
        self._model.error_template = self._unique_id
        self._model.use_remote_policy = self._unique_id
        self._model.response_process_type = 'TASK_LIST_GROUP'
        self._model.remote_policy = self._unique_id
        self._model.request_process = self._unique_id
        self._model.request_filter_policy = self._unique_id
        self._model.response_process = self._unique_id
Exemplo n.º 3
0
    def testVirtualDirectory_constructor(self):
        """Test VirtualDirectory"""
        # FIXME: update assignements for none string types e.g boolean and int

        model = VirtualDirectory(acl_policy=None,
                                 remote_path=None,
                                 virtual_host=None,
                                 name=None,
                                 enabled=None,
                                 listener_policy=None,
                                 description=None,
                                 request_process_type=None,
                                 virtual_path=None,
                                 error_template=None,
                                 use_remote_policy=None,
                                 response_process_type=None,
                                 remote_policy=None,
                                 request_process=None,
                                 request_filter_policy=None,
                                 response_process=None)  # noqa: E501
        self.assertTrue(isinstance(model, VirtualDirectory))
 def test_json_policies_api_set_virtual_directory1(self, mock_put):
     '''
         Tests when requests gets a successful response from forum
     '''
     test_name = sys._getframe().f_code.co_name
      
     #mock_get.return_value  = self.loadMock(test_name)
     mock_resp = helper._mock_response(test_name=test_name)
     mock_put.return_value = mock_resp
      
     model = VirtualDirectory()  # noqa: E501
     model.name = test_name
     model.acl_policy = ""
     model.description = ""
     model.enabled = False
     model.error_template = ""
     model.listener_policy = ""
     model.remote_path = ""
     model.remote_policy = ""
     model.request_filter_policy = ""
     model.request_process = ""
     model.request_process_type = "TASK_LIST"
     model.response_process = ""
     model._response_process_type = "TASK_LIST"
     model.use_remote_policy = False
     model.virtual_host = ""
     model.virtual_path = "/bob"
              
     created = self._api.set_virtual_directory('bill', 'bob',model)
      
     self.assertIsInstance(created, VirtualDirectory)
     self.assertEqual(created, model)
     self.assertEqual(created.name, test_name)
Exemplo n.º 5
0
    def testVirtualDirectory(self):
        """Test VirtualDirectory"""

        model = VirtualDirectory()  # noqa: E501
        self.assertTrue(isinstance(model, VirtualDirectory))
Exemplo n.º 6
0
class TestVirtualDirectory(unittest.TestCase):
    """VirtualDirectory unit test stubs"""
    def id_generator(self,
                     size=6,
                     chars=string.ascii_uppercase + string.digits):
        return ''.join(random.choice(chars) for _ in range(size))

    def setUp(self):
        # FIXME: update assignements for none string types e.g boolean and int
        self._unique_id = self.id_generator()
        self._model = VirtualDirectory()  # noqa: E501

        self._model.acl_policy = self._unique_id
        self._model.remote_path = self._unique_id
        self._model.virtual_host = self._unique_id
        self._model.name = self._unique_id
        self._model.enabled = self._unique_id
        self._model.listener_policy = self._unique_id
        self._model.description = self._unique_id
        self._model.request_process_type = 'TASK_LIST_GROUP'
        self._model.virtual_path = self._unique_id
        self._model.error_template = self._unique_id
        self._model.use_remote_policy = self._unique_id
        self._model.response_process_type = 'TASK_LIST_GROUP'
        self._model.remote_policy = self._unique_id
        self._model.request_process = self._unique_id
        self._model.request_filter_policy = self._unique_id
        self._model.response_process = self._unique_id

    def tearDown(self):
        pass
        '''
		>>>> custom tests
	'''
        #
        #	Replace with custom tests to increase coverage to 100%. Typically this will be where a value error is thrown on a setter method. This is difficult to template.
        #
        '''
		<<<< custom tests
	'''

    def testVirtualDirectory(self):
        """Test VirtualDirectory"""

        model = VirtualDirectory()  # noqa: E501
        self.assertTrue(isinstance(model, VirtualDirectory))

    def testVirtualDirectory_constructor(self):
        """Test VirtualDirectory"""
        # FIXME: update assignements for none string types e.g boolean and int

        model = VirtualDirectory(acl_policy=None,
                                 remote_path=None,
                                 virtual_host=None,
                                 name=None,
                                 enabled=None,
                                 listener_policy=None,
                                 description=None,
                                 request_process_type=None,
                                 virtual_path=None,
                                 error_template=None,
                                 use_remote_policy=None,
                                 response_process_type=None,
                                 remote_policy=None,
                                 request_process=None,
                                 request_filter_policy=None,
                                 response_process=None)  # noqa: E501
        self.assertTrue(isinstance(model, VirtualDirectory))

    def testVirtualDirectory_constructor_none_default(self):
        """Test VirtualDirectory"""
        # FIXME: update assignements for none string types e.g boolean and int

        model = VirtualDirectory(
            acl_policy=self._unique_id,
            remote_path=self._unique_id,
            virtual_host=self._unique_id,
            name=self._unique_id,
            enabled=self._unique_id,
            listener_policy=self._unique_id,
            description=self._unique_id,
            request_process_type=self._unique_id,
            virtual_path=self._unique_id,
            error_template=self._unique_id,
            use_remote_policy=self._unique_id,
            response_process_type=self._unique_id,
            remote_policy=self._unique_id,
            request_process=self._unique_id,
            request_filter_policy=self._unique_id,
            response_process=self._unique_id)  # noqa: E501
        self.assertTrue(isinstance(model, VirtualDirectory))

    def testVirtualDirectory_properties(self):
        """Test VirtualDirectory"""
        # FIXME: update assignements for none string types e.g boolean and int

        new_unique_id = self.id_generator()

        self._model.acl_policy = new_unique_id
        self.assertEqual(self._model.acl_policy, new_unique_id)
        self.assertNotEqual(self._model.acl_policy, self._unique_id)

        self._model.remote_path = new_unique_id
        self.assertEqual(self._model.remote_path, new_unique_id)
        self.assertNotEqual(self._model.remote_path, self._unique_id)

        self._model.virtual_host = new_unique_id
        self.assertEqual(self._model.virtual_host, new_unique_id)
        self.assertNotEqual(self._model.virtual_host, self._unique_id)

        self._model.name = new_unique_id
        self.assertEqual(self._model.name, new_unique_id)
        self.assertNotEqual(self._model.name, self._unique_id)

        self._model.enabled = new_unique_id
        self.assertEqual(self._model.enabled, new_unique_id)
        self.assertNotEqual(self._model.enabled, self._unique_id)

        self._model.listener_policy = new_unique_id
        self.assertEqual(self._model.listener_policy, new_unique_id)
        self.assertNotEqual(self._model.listener_policy, self._unique_id)

        self._model.description = new_unique_id
        self.assertEqual(self._model.description, new_unique_id)
        self.assertNotEqual(self._model.description, self._unique_id)

        self._model.request_process_type = 'TASK_LIST_GROUP'
        self.assertEqual(self._model.request_process_type, 'TASK_LIST_GROUP')
        self.assertNotEqual(self._model.request_process_type, self._unique_id)

        self._model.virtual_path = new_unique_id
        self.assertEqual(self._model.virtual_path, new_unique_id)
        self.assertNotEqual(self._model.virtual_path, self._unique_id)

        self._model.error_template = new_unique_id
        self.assertEqual(self._model.error_template, new_unique_id)
        self.assertNotEqual(self._model.error_template, self._unique_id)

        self._model.use_remote_policy = new_unique_id
        self.assertEqual(self._model.use_remote_policy, new_unique_id)
        self.assertNotEqual(self._model.use_remote_policy, self._unique_id)

        self._model.response_process_type = 'TASK_LIST_GROUP'
        self.assertEqual(self._model.response_process_type, 'TASK_LIST_GROUP')
        self.assertNotEqual(self._model.response_process_type, self._unique_id)

        self._model.remote_policy = new_unique_id
        self.assertEqual(self._model.remote_policy, new_unique_id)
        self.assertNotEqual(self._model.remote_policy, self._unique_id)

        self._model.request_process = new_unique_id
        self.assertEqual(self._model.request_process, new_unique_id)
        self.assertNotEqual(self._model.request_process, self._unique_id)

        self._model.request_filter_policy = new_unique_id
        self.assertEqual(self._model.request_filter_policy, new_unique_id)
        self.assertNotEqual(self._model.request_filter_policy, self._unique_id)

        self._model.response_process = new_unique_id
        self.assertEqual(self._model.response_process, new_unique_id)
        self.assertNotEqual(self._model.response_process, self._unique_id)

    def testVirtualDirectory_compare(self):
        """Test VirtualDirectory"""

        new_unique_id = self.id_generator()

        model_copy = copy.deepcopy(self._model)

        #check out compare works
        self.assertEqual(model_copy, self._model)

        #change something on the model
        model_copy.name = new_unique_id

        #check our compare detects they arent equal
        self.assertNotEqual(model_copy, self._model)

    def testVirtualDirectory_to_dict(self):
        """Test VirtualDirectory"""

        to_dict_object = self._model.to_dict()

        self.assertTrue(isinstance(to_dict_object, dict))

    def testVirtualDirectory_to_str(self):
        """Test VirtualDirectory"""

        to_str_object = self._model.to_str()

        self.assertTrue(isinstance(to_str_object, str))