Guest User

Untitled

a guest
Jul 16th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. class CsvUpload(models.Model):
  2. csv_file = models.FileField(upload_to=data_location,
  3. storage=DATA_STORE,
  4. help_text='Allowed extensions: .csv')
  5. return_email = models.EmailField()
  6. upload_time = models.DateTimeField(blank=True, null=True)
  7.  
  8. def test_valid_file_placement(self):
  9. new_upload = MODELS.CsvUpload(csv_file=self.valid_test_file,
  10. return_email=self.valid_email)
  11. new_upload.full_clean()
  12.  
  13. try:
  14. new_upload.csv_file.save('valid-test.csv', new_upload.csv_file)
  15. except SuspiciousOperation:
  16. pass
  17.  
  18. # File ought to be in the right place now
  19. try:
  20. open(os.path.join(MODELS.ROOT_DATA_LOCATION, self.gen_user, 'valid-test.csv'))
  21. except:
  22. self.fail('File was not placed in the appropriate location after being saved.')
Add Comment
Please, Sign In to add comment