def setup(): setup = Setup() unb_segment = "UNB+UNOA:4+APIS*ABE+USADHS+070429:0900+000000001++USADHS'" cc = Characters() setup.cc = cc.with_control_character("decimal_point", ".") setup.collection = SegmentCollection.from_str(unb_segment) return setup
class TestControlCharacters(unittest.TestCase): def setUp(self): self.cc = Characters() def test_wrong_attribute(self): self.assertRaises(AttributeError, self.cc.with_control_character, 'wrongtype', '+') def test_wrong_character_size(self): self.assertRaises(ValueError, self.cc.with_control_character, 'decimal_point', ',.') def test_correct_parameters(self): d = self.cc.with_control_character('component_separator', '/') self.assertEqual(self.cc.with_control_character( 'component_separator', '/').component_separator, '/') self.assertEqual(self.cc.with_control_character( 'data_separator', '/').data_separator, '/') self.assertEqual(self.cc.with_control_character( 'decimal_point', '/').decimal_point, '/') self.assertEqual(self.cc.with_control_character( 'escape_character', '/').escape_character, '/') self.assertEqual(self.cc.with_control_character( 'reserved_character', '/').reserved_character, '/') self.assertEqual(self.cc.with_control_character( 'segment_terminator', '/').segment_terminator, '/')
class TestControlCharacters(unittest.TestCase): def setUp(self): self.cc = Characters() def test_wrong_attribute(self): self.assertRaises(AttributeError, self.cc.with_control_character, "wrongtype", "+") def test_wrong_character_size(self): self.assertRaises(ValueError, self.cc.with_control_character, "decimal_point", ",.") def test_correct_parameters(self): d = self.cc.with_control_character("component_separator", "/") self.assertEqual( self.cc.with_control_character("component_separator", "/").component_separator, "/", ) self.assertEqual( self.cc.with_control_character("data_separator", "/").data_separator, "/") self.assertEqual( self.cc.with_control_character("decimal_point", "/").decimal_point, "/") self.assertEqual( self.cc.with_control_character("escape_character", "/").escape_character, "/", ) self.assertEqual( self.cc.with_control_character("reserved_character", "/").reserved_character, "/", ) self.assertEqual( self.cc.with_control_character("segment_terminator", "/").segment_terminator, "/", )