Bez popisu
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_file.py 1.0KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import os
  2. import unittest
  3. import tempfile
  4. from lodel.leapi.datahandlers.datas import File, Varchar
  5. class FileTestCase(unittest.TestCase):
  6. @classmethod
  7. def setUpClass(cls):
  8. cls.test_file, cls.test_file_path = tempfile.mkstemp()
  9. def test_check_correct_data_value(self):
  10. test_file = File()
  11. test_value = os.path.abspath(os.path.join(os.path.curdir,'test_file.txt'))
  12. _, error = test_file.check_data_value(test_value)
  13. self.assertIsNone(error)
  14. @unittest.skip
  15. def test_check_uncorrect_data_value(self):
  16. test_file = File()
  17. test_bad_value = "invalid_path"
  18. _, error = test_file.check_data_value(test_bad_value)
  19. self.assertIsNotNone(test_bad_value)
  20. def test_can_override(self):
  21. test_file = File()
  22. test_file2 = File()
  23. self.assertTrue(test_file.can_override(test_file2))
  24. test_varchar = Varchar()
  25. self.assertFalse(test_file.can_override(test_varchar))
  26. @classmethod
  27. def tearDownClass(cls):
  28. os.unlink(cls.test_file_path)