test_read_support.py 1010 B

1234567891011121314151617181920212223242526272829303132333435
  1. import tempfile
  2. import unittest
  3. import parquet
  4. class TestFileFormat(unittest.TestCase):
  5. def test_header_magic_bytes(self):
  6. with tempfile.NamedTemporaryFile() as t:
  7. t.write("PAR1_some_bogus_data")
  8. t.flush()
  9. self.assertTrue(parquet._check_header_magic_bytes(t))
  10. def test_footer_magic_bytes(self):
  11. with tempfile.NamedTemporaryFile() as t:
  12. t.write("PAR1_some_bogus_data_PAR1")
  13. t.flush()
  14. self.assertTrue(parquet._check_footer_magic_bytes(t))
  15. def test_not_parquet_file(self):
  16. with tempfile.NamedTemporaryFile() as t:
  17. t.write("blah")
  18. t.flush()
  19. self.assertFalse(parquet._check_header_magic_bytes(t))
  20. self.assertFalse(parquet._check_footer_magic_bytes(t))
  21. class TestMetadata(unittest.TestCase):
  22. f = "/Users/joecrow/Code/parquet-compatibility/parquet-testdata/impala/1.1.1-SNAPPY/nation.impala.parquet"
  23. def testFooterBytes(self):
  24. with open(self.f) as fo:
  25. self.assertEquals(327, parquet._get_footer_size(fo))
  26. def testReadFOoter(self):
  27. parquet.read_footer(self.f)