def test_not_csv_file(self):
     self.filename = 'not_csv.xls'
     self.generate_non_csv_file(self.filename)
     file = open(self.filename,'rb')
     upload_location_form = UploadCSVFileForm(UploadLocation, {}, {'file':SimpleUploadedFile(self.filename, file.read())})
     self.assertEqual(False, upload_location_form.is_valid())
     self.assertIn('%s is not a valid csv file.'%self.filename, upload_location_form.errors['file'])
 def test_not_csv_file(self):
     self.filename = 'not_csv.xls'
     self.generate_non_csv_file(self.filename)
     file = open(self.filename, 'rb')
     upload_location_form = UploadCSVFileForm(
         UploadLocation, {},
         {'file': SimpleUploadedFile(self.filename, file.read())})
     self.assertEqual(False, upload_location_form.is_valid())
     self.assertIn('%s is not a valid csv file.' % self.filename,
                   upload_location_form.errors['file'])
    def test_empty_file(self):
        data_file = {
            'file':
            SimpleUploadedFile(self.filename,
                               open(self.filename, 'a').close())
        }

        upload_location_form = UploadCSVFileForm(UploadLocation, {}, data_file)
        self.assertEqual(False, upload_location_form.is_valid())
        self.assertIn('The submitted file is empty.',
                      upload_location_form.errors['file'])
    def test_empty_file(self):
        data_file={'file': SimpleUploadedFile(self.filename, open(self.filename, 'a').close())}

        upload_location_form = UploadCSVFileForm(UploadLocation, {}, data_file)
        self.assertEqual(False, upload_location_form.is_valid())
        self.assertIn('The submitted file is empty.', upload_location_form.errors['file'])