コード例 #1
0
ファイル: test_statement.py プロジェクト: 9h37/python-cfonb
 def test_parse_content_4(self):
     row = p.parse_content_4(CONTENT_4_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(19):
         self.assertEqual(row.as_list()[i], getattr(row.as_obj(), p.CONTENT_4_KEYS[i]))
         self.assertEqual(row.as_list()[i], CONTENT_4_VALUES[i])
コード例 #2
0
 def test_parse_content_4(self):
     row = p.parse_content_4(CONTENT_4_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(19):
         self.assertEqual(row.as_list()[i],
                          getattr(row.as_obj(), p.CONTENT_4_KEYS[i]))
         self.assertEqual(row.as_list()[i], CONTENT_4_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
ファイル: test_statement.py プロジェクト: 9h37/python-cfonb
 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)