def test_good_response_code_empty_entity(self):
        client, config, volume_model, response = self.get_mocks()

        response.entity = None
        response.status_code = '200'
        client.get_volume_info = MagicMock(return_value=response)

        behavior = VolumesAPI_Behaviors(client, config)
        with self.assertRaises(VolumesAPIBehaviorException):
            behavior.wait_for_volume_status(self.defaults.volume_name,
                                            self.defaults.expected_status,
                                            self.defaults.timeout,
                                            poll_rate=self.defaults.poll_rate)
Exemple #2
0
    def test_good_response_code_empty_entity(self):
        client, config, volume_model, response = self.get_mocks()

        response.entity = None
        response.status_code = "200"
        client.get_volume_info = MagicMock(return_value=response)

        behavior = VolumesAPI_Behaviors(client, config)
        with self.assertRaises(VolumesAPIBehaviorException):
            behavior.wait_for_volume_status(
                self.defaults.volume_name,
                self.defaults.expected_status,
                self.defaults.timeout,
                poll_rate=self.defaults.poll_rate,
            )
Exemple #3
0
    def test_good_response_and_entity_bad_status(self):
        client, config, volume_model, response = self.get_mocks()

        recieved_status = "error"
        timeout = 2
        poll_rate = 1

        volume_model.status = recieved_status
        response.entity = volume_model
        client.get_volume_info = MagicMock(return_value=response)

        behavior = VolumesAPI_Behaviors(client, config)
        with self.assertRaises(VolumesAPIBehaviorException):
            behavior.wait_for_volume_status(
                self.defaults.volume_name, self.defaults.expected_status, timeout, poll_rate=poll_rate
            )
    def test_good_response_and_entity_bad_status(self):
        client, config, volume_model, response = self.get_mocks()

        recieved_status = 'error'
        timeout = 2
        poll_rate = 1

        volume_model.status = recieved_status
        response.entity = volume_model
        client.get_volume_info = MagicMock(return_value=response)

        behavior = VolumesAPI_Behaviors(client, config)
        with self.assertRaises(VolumesAPIBehaviorException):
            behavior.wait_for_volume_status(self.defaults.volume_name,
                                            self.defaults.expected_status,
                                            timeout,
                                            poll_rate=poll_rate)
Exemple #5
0
    def test_good_response_code_configured_poll_period(self):
        client, config, volume_model, response = self.get_mocks()

        behavior = VolumesAPI_Behaviors(client, config)
        resp = behavior.wait_for_volume_status(
            self.defaults.volume_name, self.defaults.expected_status, self.defaults.timeout
        )

        self.assertIsNone(resp)
    def test_good_response_code_configured_poll_period(self):
        client, config, volume_model, response = self.get_mocks()

        behavior = VolumesAPI_Behaviors(client, config)
        resp = behavior.wait_for_volume_status(self.defaults.volume_name,
                                               self.defaults.expected_status,
                                               self.defaults.timeout)

        self.assertIsNone(resp)
Exemple #7
0
    def test_timeout_failure(self):
        client, config, volume_model, volume_create_response = self.get_mocks()

        volume_create_response.entity = None
        volume_create_response.status_code = 200

        client.create_volume = MagicMock(return_value=volume_create_response)

        behavior = VolumesAPI_Behaviors(client, config)
        behavior.wait_for_volume_status = MagicMock(side_effect=VolumesAPIBehaviorException)

        with self.assertRaises(VolumesAPIBehaviorException):
            behavior.create_available_volume(self.defaults.display_name, self.defaults.size, self.defaults.volume_type)
    def test_timeout_failure(self):
        client, config, volume_model, volume_create_response = self.get_mocks()

        volume_create_response.entity = None
        volume_create_response.status_code = 200

        client.create_volume = MagicMock(return_value=volume_create_response)

        behavior = VolumesAPI_Behaviors(client, config)
        behavior.wait_for_volume_status = MagicMock(
            side_effect=VolumesAPIBehaviorException)

        with self.assertRaises(VolumesAPIBehaviorException):
            behavior.create_available_volume(self.defaults.display_name,
                                             self.defaults.size,
                                             self.defaults.volume_type)