'Verifies that exceptions are thrown in the expected cases.'

def test_error_conditions(self):

    with self.assertRaises(ValueError) as error:
        self.request.FILES = {'uploaded_file': SimpleUploadedFile('tempfile.csv', self.file_content)}
        store_uploaded_file(self.request, 'wrong_key', ['.txt', '.csv'], 'stored_file', self.default_max_size)
    self.verify_exception("No    file    uploaded    with    key    'wrong_key'.", error)
    with self.assertRaises(exceptions.PermissionDenied) as error:
        self.request.FILES = {'uploaded_file': SimpleUploadedFile('tempfile.csv', self.file_content)}
        store_uploaded_file(self.request, 'uploaded_file', [], 'stored_file', self.default_max_size)
    self.verify_exception("The    file    must    end    with    one    of    the    following    extensions:    ''.", error)
    with self.assertRaises(exceptions.PermissionDenied) as error:
        self.request.FILES = {'uploaded_file': SimpleUploadedFile('tempfile.csv', self.file_content)}
        store_uploaded_file(self.request, 'uploaded_file', ['.bar'], 'stored_file', self.default_max_size)
    self.verify_exception("The    file    must    end    with    the    extension    '.bar'.", error)
    with self.assertRaises(exceptions.PermissionDenied) as error:
        self.request.FILES = {'uploaded_file': SimpleUploadedFile('tempfile.csv', self.file_content)}
        store_uploaded_file(self.request, 'uploaded_file', ['.xxx', '.bar'], 'stored_file', self.default_max_size)
    self.verify_exception("The    file    must    end    with    one    of    the    following    extensions:    '.xxx',    '.bar'.", error)
    with self.assertRaises(exceptions.PermissionDenied) as error:
        self.request.FILES = {'uploaded_file': SimpleUploadedFile('tempfile.csv', self.file_content)}
        store_uploaded_file(self.request, 'uploaded_file', ['.csv'], 'stored_file', 2)
    self.verify_exception('Maximum    upload    file    size    is    2    bytes.', error)
