예제 #1
0
 def test_header_block_one_and_two_and_four_with_content(self):
     message = "{1:F01HBOSXXXXAXXX9999999999}{2:I940HBOSXXXXXXXXN}{4:\n:61:FOO\n-}"
     expected = {
         "1": 'F01HBOSXXXXAXXX9999999999',
         "2": 'I940HBOSXXXXXXXXN',
         "4": [("61", "FOO")]
     }
     self.assertEqual(expected, parse(message))
예제 #2
0
 def test_header_block_one_and_two_and_four_with_multiple_fields(self):
     message = "{1:F01HBOSXXXXAXXX9999999999}{2:I940HBOSXXXXXXXXN}{4:\n:FOO:BLAH\n:FOD:FIB\n-}"
     expected = {
         "1": 'F01HBOSXXXXAXXX9999999999',
         "2": 'I940HBOSXXXXXXXXN',
         "4": [("FOO", "BLAH"), ("FOD", "FIB")]
     }
     self.assertEqual(expected, parse(message))
예제 #3
0
 def test_header_block_one_and_two_and_four(self):
     message = "{1:F01HBOSXXXXAXXX9999999999}{2:I940HBOSXXXXXXXXN}{4:\n-}"
     expected = {
         "1": 'F01HBOSXXXXAXXX9999999999',
         "2": 'I940HBOSXXXXXXXXN',
         "4": []
     }
     self.assertEqual(expected, parse(message))
예제 #4
0
 def test_header_block_one_and_two_and_four_with_multiple_fields(self):
     message = "{1:F01HBOSXXXXAXXX9999999999}{2:I940HBOSXXXXXXXXN}{4:\n:FOO:BLAH\n:FOD:FIB\n-}"
     expected = {"1": 'F01HBOSXXXXAXXX9999999999', "2": 'I940HBOSXXXXXXXXN', "4": [("FOO", "BLAH"), ("FOD", "FIB")]}
     self.assertEqual(expected, parse(message))
예제 #5
0
 def test_header_block_one_and_two_and_four_with_content(self):
     message = "{1:F01HBOSXXXXAXXX9999999999}{2:I940HBOSXXXXXXXXN}{4:\n:61:FOO\n-}"
     expected = {"1": 'F01HBOSXXXXAXXX9999999999', "2": 'I940HBOSXXXXXXXXN', "4": [("61", "FOO")]}
     self.assertEqual(expected, parse(message))
예제 #6
0
 def test_header_block_one_and_two_and_four(self):
     message = "{1:F01HBOSXXXXAXXX9999999999}{2:I940HBOSXXXXXXXXN}{4:\n-}"
     expected = {"1": 'F01HBOSXXXXAXXX9999999999', "2": 'I940HBOSXXXXXXXXN', "4": []}
     self.assertEqual(expected, parse(message))
예제 #7
0
 def test_header_block_one(self):
     message = "{1:F01HBOSXXXXAXXX9999999999}"
     expected = {"1": 'F01HBOSXXXXAXXX9999999999'}
     self.assertEqual(expected, parse(message))
예제 #8
0
 def test_fields_with_subfields(self):
     message = "{3:{108:X}}"
     expected = {"3": {"108": "X"}}
     self.assertEqual(expected, parse(message))
예제 #9
0
    def test_complex_message(self):
        message = pkg_resources.resource_string("mt940_tests", "sample_file.txt").decode("utf-8")

        pprint.pprint(message)
        result = parse(message)
        pprint.pprint(result)
예제 #10
0
 def test_block_four_with_alphanumeric_field_headers(self):
     message = "{1:X}{2:Y}{4:\n:28A:XXX\n:34D:YYY\n-}"
     expected = {"1": 'X', "2": 'Y', "4": [("28A", "XXX"), ("34D", "YYY")]}
     self.assertEqual(expected, parse(message))
예제 #11
0
 def test_header_block_four_with_commas_in_data(self):
     message = "{1:X}{2:Y}{4:\n:A:B, C\n-}"
     expected = {"1": 'X', "2": 'Y', "4": [("A", "B, C")]}
     self.assertEqual(expected, parse(message))
예제 #12
0
 def test_header_block_one(self):
     message = "{1:F01HBOSXXXXAXXX9999999999}"
     expected = {"1": 'F01HBOSXXXXAXXX9999999999'}
     self.assertEqual(expected, parse(message))
예제 #13
0
:61:1404010401D1,NMSCNONREF
000016
:61:1404010401C1,NMSCNONREF
FROM A/C              TFR00059618
:86:301775
:61:1404010401D1,NMSCNONREF
TO A/C                TFR00059707
:86:301775
:61:1404010401C1,NMSCNONREF
FROM A/C              TFR00059618
:86:301775
:61:1404010401D1,NMSCNONREF
TO A/C                TFR00059707
:86:301775
:61:1404010401C2,NMSCNONREF
INTEREST (NET)
:61:1404010401D1,NMSCNONREF
FT148090898341           FOREIGN E
:86:UR
:61:1404010401D1,NMSCNONREF
FT148090949341           FOREIGN U
:86:SD
:62F:C140401GBP10,10
:64:C140401GBP10,10
:65:C140402GBP10,10
:65:C140406GBP10,10
:65:C140407GBP10,10
-}"""

pprint.pprint(parse(message))
예제 #14
0
 def test_header_block_four_with_commas_in_data(self):
     message = "{1:X}{2:Y}{4:\n:A:B, C\n-}"
     expected = {"1": 'X', "2": 'Y', "4": [("A", "B, C")]}
     self.assertEqual(expected, parse(message))
예제 #15
0
 def test_header_block_one_and_colons_and_newlines_in_data(self):
     message = "{1:X}{2:Y}{4:\n:A:B:C\nD\n-}"
     expected = {"1": 'X', "2": 'Y', "4": [("A", "B:C\nD")]}
     self.assertEqual(expected, parse(message))
예제 #16
0
 def test_header_block_one_and_colons_and_newlines_in_data(self):
     message = "{1:X}{2:Y}{4:\n:A:B:C\nD\n-}"
     expected = {"1": 'X', "2": 'Y', "4": [("A", "B:C\nD")]}
     self.assertEqual(expected, parse(message))
예제 #17
0
 def test_block_four_with_alphanumeric_field_headers(self):
     message = "{1:X}{2:Y}{4:\n:28A:XXX\n:34D:YYY\n-}"
     expected = {"1": 'X', "2": 'Y', "4": [("28A", "XXX"), ("34D", "YYY")]}
     self.assertEqual(expected, parse(message))
예제 #18
0
 def test_fields_with_subfields(self):
     message = "{3:{108:X}}"
     expected = {"3": {"108": "X"}}
     self.assertEqual(expected, parse(message))
예제 #19
0
:61:1404010401D1,NMSCNONREF
000016
:61:1404010401C1,NMSCNONREF
FROM A/C              TFR00059618
:86:301775
:61:1404010401D1,NMSCNONREF
TO A/C                TFR00059707
:86:301775
:61:1404010401C1,NMSCNONREF
FROM A/C              TFR00059618
:86:301775
:61:1404010401D1,NMSCNONREF
TO A/C                TFR00059707
:86:301775
:61:1404010401C2,NMSCNONREF
INTEREST (NET)
:61:1404010401D1,NMSCNONREF
FT148090898341           FOREIGN E
:86:UR
:61:1404010401D1,NMSCNONREF
FT148090949341           FOREIGN U
:86:SD
:62F:C140401GBP10,10
:64:C140401GBP10,10
:65:C140402GBP10,10
:65:C140406GBP10,10
:65:C140407GBP10,10
-}"""

pprint.pprint(parse(message))