def test_invalid_file(self): """ When file is not a zip file, ValidationError should be raised. """ f = File('invalidfile') f.content_type = 'invalid' with self.assertRaises(ValidationError): validatefiletype(f)
def test_txt_file(self): """ When file is a TXT file, no exception should be raised. """ f = File('txtfile') f.content_type = 'text/plain' try: validatefiletype(f) except ValidationError: self.fail('Should not raise Validation Error on a TXT file.')