1
0
mirror of https://github.com/aclindsa/ofxgo.git synced 2024-12-25 22:43:21 -05:00

Test parsing of some sample responses

This commit is contained in:
Aaron Lindsay 2017-04-10 20:01:01 -04:00
parent 384d24b3d0
commit ff18c86aea
6 changed files with 166 additions and 0 deletions

View File

@ -4,6 +4,8 @@ import (
"fmt"
"github.com/aclindsa/go/src/encoding/xml"
"github.com/aclindsa/ofxgo"
"os"
"path/filepath"
"reflect"
"testing"
)
@ -133,3 +135,24 @@ func checkEqual(t *testing.T, fieldName string, expected, actual reflect.Value)
func checkResponsesEqual(t *testing.T, expected, actual *ofxgo.Response) {
checkEqual(t, "", reflect.ValueOf(expected), reflect.ValueOf(actual))
}
func TestValidSamples(t *testing.T) {
fn := func(path string, info os.FileInfo, err error) error {
if info.IsDir() {
return nil
} else if filepath.Ext(path) != ".ofx" {
return nil
}
file, err := os.Open(path)
if err != nil {
t.Fatalf("Unexpected error opening %s: %s\n", path, err)
}
_, err = ofxgo.ParseResponse(file)
if err != nil {
t.Fatalf("Unexpected error parsing OFX response in %s: %s\n", path, err)
}
return nil
}
filepath.Walk("samples/valid_responses", fn)
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,75 @@
OFXHEADER:100
DATA:OFXSGML
VERSION:103
SECURITY:NONE
ENCODING:USASCII
CHARSET:1252
COMPRESSION:NONE
OLDFILEUID:NONE
NEWFILEUID:NONE
<OFX>
<SIGNONMSGSRSV1><SONRS>
<STATUS>
<CODE>0
<SEVERITY>INFO
</STATUS>
<DTSERVER>20170407001840.607[0:GMT]
<LANGUAGE>ENG
<FI>
<ORG>UJKDO
<FID>3534
</FI>
</SONRS>
</SIGNONMSGSRSV1>
<BANKMSGSRSV1>
<STMTTRNRS>
<TRNUID>e1707dfd-695d-4451-8d9c-0e142fdc456a
<STATUS>
<CODE>0
<SEVERITY>INFO
</STATUS>
<STMTRS>
<CURDEF>USD
<BANKACCTFROM>
<BANKID>598813374
<ACCTID>35342483513
<ACCTTYPE>MONEYMRKT
</BANKACCTFROM>
<BANKTRANLIST>
<DTSTART>20170107011841.262[0:GMT]
<DTEND>20170407001841.262[0:GMT]
<STMTTRN>
<TRNTYPE>CREDIT
<DTPOSTED>20170117120000.000[0:GMT]
<TRNAMT>-995.4190396554627
<FITID>2fb2640c-cee3-4643-8ba3-ea21a4d18954
<NAME>Dividend Earned
</STMTTRN>
<STMTTRN>
<TRNTYPE>CREDIT
<DTPOSTED>20170215120000.000[0:GMT]
<TRNAMT>788.5385340523635
<FITID>c9d856df-339c-47c6-9f6a-8c2e2910f62e
<NAME>Dividend Earned
</STMTTRN>
<STMTTRN>
<TRNTYPE>CREDIT
<DTPOSTED>20170315120000.000[0:GMT]
<TRNAMT>3070.1328011762807
<FITID>1107ace0-048b-4c0c-b5f3-45b6be4cd71d
<NAME>Dividend Earned
</STMTTRN>
</BANKTRANLIST>
<LEDGERBAL>
<BALAMT>2607.1664944585727
<DTASOF>20170407001841.262[0:GMT]
</LEDGERBAL>
<AVAILBAL>
<BALAMT>4503.683156768119
<DTASOF>20170407001841.262[0:GMT]
</AVAILBAL>
</STMTRS>
</STMTTRNRS>
</BANKMSGSRSV1>
</OFX>

View File

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="utf-16"?>
<?OFX OFXHEADER="200" VERSION="203" SECURITY="NONE" OLDFILEUID="NONE" NEWFILEUID="NONE"?>
<OFX>
<SIGNONMSGSRSV1><SONRS>
<STATUS>
<CODE>0</CODE>
<SEVERITY>INFO</SEVERITY>
</STATUS>
<DTSERVER>20170407001504.765[0:GMT]</DTSERVER>
<LANGUAGE>ENG</LANGUAGE>
<FI>
<ORG>EHPDK</ORG>
<FID>4881</FID>
</FI>
</SONRS></SIGNONMSGSRSV1>
<BANKMSGSRSV1>
<STMTTRNRS>
<TRNUID>262e39f1-e698-48cb-b2a2-b2f8ac2478fa</TRNUID>
<STATUS>
<CODE>0</CODE>
<SEVERITY>INFO</SEVERITY>
</STATUS>
<STMTRS>
<CURDEF>USD</CURDEF>
<BANKACCTFROM>
<BANKID>188545178</BANKID>
<ACCTID>83483499583</ACCTID>
<ACCTTYPE>MONEYMRKT</ACCTTYPE>
</BANKACCTFROM>
<BANKTRANLIST>
<DTSTART>20170107011505.296[0:GMT]</DTSTART>
<DTEND>20170407001505.296[0:GMT]</DTEND>
<STMTTRN>
<TRNTYPE>CREDIT</TRNTYPE>
<DTPOSTED>20170117120000.000[0:GMT]</DTPOSTED>
<TRNAMT>1303.7355652284177</TRNAMT>
<FITID>fa603343-dd05-434e-9ffc-933f51f8cedf</FITID>
<NAME>Dividend Earned</NAME>
</STMTTRN>
<STMTTRN>
<TRNTYPE>CREDIT</TRNTYPE>
<DTPOSTED>20170215120000.000[0:GMT]</DTPOSTED>
<TRNAMT>4321.245210194117</TRNAMT>
<FITID>061f8fb0-8b56-4938-a45e-5db0e42d74f7</FITID>
<NAME>Dividend Earned</NAME>
</STMTTRN>
<STMTTRN>
<TRNTYPE>CREDIT</TRNTYPE>
<DTPOSTED>20170315120000.000[0:GMT]</DTPOSTED>
<TRNAMT>-850.1196618322863</TRNAMT>
<FITID>a43dfadf-350b-4bb1-85d7-8be57ad0ef82</FITID>
<NAME>Dividend Earned</NAME>
</STMTTRN>
</BANKTRANLIST>
<LEDGERBAL>
<BALAMT>3317.738651126686</BALAMT>
<DTASOF>20170407001505.296[0:GMT]</DTASOF>
</LEDGERBAL>
<AVAILBAL>
<BALAMT>658.9377225082694</BALAMT>
<DTASOF>20170407001505.296[0:GMT]</DTASOF>
</AVAILBAL>
</STMTRS></STMTTRNRS>
</BANKMSGSRSV1>
</OFX>