Exemplo n.º 1
0
 def test_not_a_txt_file(self):
     """
     This method tests if validation error is raised when a non-text file is
     uploaded
     """
     f = File('invalid')
     f.content_type = 'invalid'
     with self.assertRaises(ValueError):
         extract_text_file(f)
Exemplo n.º 2
0
 def test_text_file(self):
     """
     This method tests if content of the text file are extracted when
     a text file is uploaded
     """
     f = ContentFile('This is a sample content', name='test.txt')
     f.content_type = 'text/plain'
     content = extract_text_file(f)
     self.assertEquals(content.strip(), 'This is a sample content')