예제 #1
0
 def test_parse_footer(self):
     row = p.parse_footer(FOOT_LINE)
     # little type check
     self.assertIsInstance(row, Row, 'invalid row type: %s' % type(row))
     # list copy for check
     list_1 = row.as_list()[:]
     list_2 = row.as_dict().values()[:]
     # sort list to be compared
     list_1.sort()
     list_2.sort()
     # list check
     self.assertEqual(list_1, list_2)
     # check dict and obj format
     for i in range(13):
         self.assertEqual(row.as_list()[i], getattr(row.as_obj(), p.FOOT_KEYS[i]))
         self.assertEqual(row.as_list()[i], FOOT_VALUES[i])
예제 #2
0
 def test_parse_footer(self):
     row = p.parse_footer(FOOT_LINE)
     # little type check
     self.assertIsInstance(row, Row, 'invalid row type: %s' % type(row))
     # list copy for check
     list_1 = row.as_list()[:]
     list_2 = row.as_dict().values()[:]
     # sort list to be compared
     list_1.sort()
     list_2.sort()
     # list check
     self.assertEqual(list_1, list_2)
     # check dict and obj format
     for i in range(13):
         self.assertEqual(row.as_list()[i],
                          getattr(row.as_obj(), p.FOOT_KEYS[i]))
         self.assertEqual(row.as_list()[i], FOOT_VALUES[i])
예제 #3
0
 def test_statement(self):
     # prepare file obj
     file_obj = StringIO()
     file_obj.write("%s\n" % HEAD_LINE)
     file_obj.write("%s\n" % CONTENT_4_LINE)
     file_obj.write("%s\n" % FOOT_LINE)
     file_obj.seek(0)
     # init statement
     statement = p.Statement()
     statement.parse(file_obj)
     # prepare values to compare
     header_line = p.parse_head(HEAD_LINE)
     content_line = p.parse_content_4(CONTENT_4_LINE)
     footer_line = p.parse_footer(FOOT_LINE)
     # some tests
     self.assertIsInstance(statement, p.Statement)
     self.assertIsInstance(statement.header, Row)
     self.assertIsInstance(statement.footer, Row)
     self.assertIsInstance(statement.lines, list)
     self.assertEqual(len(statement.lines), 1)
     self.assertIsInstance(statement.lines[0], Row)
     self.assertEqual(statement.header, header_line)
     self.assertEqual(statement.footer, footer_line)
     self.assertEqual(statement.lines[0], content_line)
예제 #4
0
 def test_statement(self):
     # prepare file obj
     file_obj = StringIO()
     file_obj.write("%s\n" % HEAD_LINE)
     file_obj.write("%s\n" % CONTENT_4_LINE)
     file_obj.write("%s\n" % FOOT_LINE)
     file_obj.seek(0)
     # init statement
     statement = p.Statement()
     statement.parse(file_obj)
     # prepare values to compare
     header_line = p.parse_head(HEAD_LINE)
     content_line = p.parse_content_4(CONTENT_4_LINE)
     footer_line = p.parse_footer(FOOT_LINE)
     # some tests
     self.assertIsInstance(statement, p.Statement)
     self.assertIsInstance(statement.header, Row)
     self.assertIsInstance(statement.footer, Row)
     self.assertIsInstance(statement.lines, list)
     self.assertEqual(len(statement.lines), 1)
     self.assertIsInstance(statement.lines[0], Row)
     self.assertEqual(statement.header, header_line)
     self.assertEqual(statement.footer, footer_line)
     self.assertEqual(statement.lines[0], content_line)