def test_precheck_dist_hash_s3_404(self, mock_urlopen, mock_version_object): """Test precheck to validate error thrown on a Non-200 response from s3""" mock_version_object.return_value = self.mock_version mock_s3_response = Mock(name='mock s3 response') mock_s3_response.getcode.return_value = 404 mock_urlopen.return_value = mock_s3_response with self.assertRaises(IOError): ef_version.precheck_dist_hash(self)
def test_precheck_dist_hash_urllib_error(self, mock_urlopen, mock_version_object): """Test preckek to validate error thrown on url error""" mock_version_object.return_value = self.mock_version mock_s3_response = Mock(name='mock s3 response') mock_urlopen.return_value = mock_s3_response mock_urlopen.side_effect = IOError with self.assertRaises(IOError): ef_version.precheck_dist_hash(self)
def test_precheck_dist_hash(self, mock_urlopen, mock_version_object): """Test precheck of dist hash version""" mock_version_object.return_value = self.mock_version mock_s3_response = Mock(name='mock s3 response') mock_s3_response.getcode.return_value = 200 mock_s3_response.read.return_value = self.value mock_urlopen.return_value = mock_s3_response self.assertTrue(ef_version.precheck_dist_hash(self))
def test_precheck_dist_hash_version_none(self, mock_version_object): """Test precheck_dist_hash when current version is none""" response = {"Error": {"Code": "NoSuchKey"}} mock_version_object.side_effect = ClientError(response, "Get Object") self.assertTrue(ef_version.precheck_dist_hash(self))