test_csv_cleanup.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import unittest
  2. from misc.csv_cleanup import cleanup_line
  3. class TestCsvCleanup(unittest.TestCase):
  4. def test_cleanup_line_ident(self):
  5. simple_int = "1;2;3\n"
  6. simple_float = "1,20;2,322;3,434\n"
  7. simple_string = '"Test";"Default";"Simple Test"\n'
  8. self.assertEqual(cleanup_line(simple_int), simple_int)
  9. self.assertEqual(cleanup_line(simple_float), simple_float)
  10. self.assertEqual(cleanup_line(simple_string), simple_string)
  11. def test_cleanup_line_semicolon(self):
  12. string_1_in = '"String 1";"String;2";"Test 3"\n'
  13. string_1_out = '"String 1";"String2";"Test 3"\n'
  14. string_2_in = '"1;2;3"\n'
  15. string_2_out = '"123"\n'
  16. string_3_in = '"1";";";3\n'
  17. string_3_out = '"1";"";3\n'
  18. string_4_in = '";;;;;;;"\n'
  19. string_4_out = '""\n'
  20. string_5_in = '"";"";"";"";";;;"\n'
  21. string_5_out = '"";"";"";"";""\n'
  22. self.assertEqual(cleanup_line(string_1_in), string_1_out)
  23. self.assertEqual(cleanup_line(string_2_in), string_2_out)
  24. self.assertEqual(cleanup_line(string_3_in), string_3_out)
  25. self.assertEqual(cleanup_line(string_4_in), string_4_out)
  26. self.assertEqual(cleanup_line(string_5_in), string_5_out)