1
0
mirror of https://github.com/aclindsa/ofxgo.git synced 2025-07-01 19:58:37 -04:00

Rename ofxgo_test package to ofxgo and remove self-imports/references

* Fix package in generate_constants.py
* Update generate_constants.py to use the new imports
This commit is contained in:
John Starich
2020-03-30 23:19:18 -05:00
committed by Aaron Lindsay
parent f19189de45
commit 8ad638c7e2
15 changed files with 712 additions and 721 deletions

View File

@ -1,7 +1,6 @@
package ofxgo_test
package ofxgo
import (
"github.com/aclindsa/ofxgo"
"strings"
"testing"
"time"
@ -41,31 +40,31 @@ func TestMarshalCCStatementRequest(t *testing.T) {
</CREDITCARDMSGSRQV1>
</OFX>`
var client = ofxgo.BasicClient{
var client = BasicClient{
AppID: "OFXGO",
AppVer: "0001",
SpecVersion: ofxgo.OfxVersion203,
SpecVersion: OfxVersion203,
}
var request ofxgo.Request
var request Request
request.Signon.UserID = "myusername"
request.Signon.UserPass = "Pa$$word"
request.Signon.Org = "BNK"
request.Signon.Fid = "1987"
statementRequest := ofxgo.CCStatementRequest{
statementRequest := CCStatementRequest{
TrnUID: "913846",
CCAcctFrom: ofxgo.CCAcct{
CCAcctFrom: CCAcct{
AcctID: "XXXXXXXXXXXX1234",
},
DtStart: ofxgo.NewDateGMT(2017, 1, 1, 0, 0, 0, 0),
DtStart: NewDateGMT(2017, 1, 1, 0, 0, 0, 0),
Include: true,
}
request.CreditCard = append(request.CreditCard, &statementRequest)
request.SetClientFields(&client)
// Overwrite the DtClient value set by SetClientFields to time.Now()
request.Signon.DtClient = *ofxgo.NewDateGMT(2017, 3, 31, 15, 38, 48, 0)
request.Signon.DtClient = *NewDateGMT(2017, 3, 31, 15, 38, 48, 0)
marshalCheckRequest(t, &request, expectedString)
}
@ -82,45 +81,45 @@ OLDFILEUID:NONE
NEWFILEUID:NONE
<OFX><SIGNONMSGSRSV1><SONRS><STATUS><CODE>0<SEVERITY>INFO<MESSAGE>SUCCESS</STATUS><DTSERVER>20170331154648.331[-4:EDT]<LANGUAGE>ENG<FI><ORG>01<FID>81729</FI></SONRS></SIGNONMSGSRSV1><CREDITCARDMSGSRSV1><CCSTMTTRNRS><TRNUID>59e850ad-7448-b4ce-4b71-29057763b306<STATUS><CODE>0<SEVERITY>INFO</STATUS><CCSTMTRS><CURDEF>USD<CCACCTFROM><ACCTID>9283744488463775</CCACCTFROM><BANKTRANLIST><DTSTART>20161201154648.688[-5:EST]<DTEND>20170331154648.688[-4:EDT]<STMTTRN><TRNTYPE>DEBIT<DTPOSTED>20170209120000[0:GMT]<TRNAMT>-7.96<FITID>2017020924435657040207171600195<NAME>SLICE OF NY</STMTTRN><STMTTRN><TRNTYPE>CREDIT<DTPOSTED>20161228120000[0:GMT]<TRNAMT>3830.46<FITID>2016122823633637200000258482730<NAME>Payment Thank You Electro</STMTTRN><STMTTRN><TRNTYPE>DEBIT<DTPOSTED>20170327120000[0:GMT]<TRNAMT>-17.7<FITID>2017032724445727085300442885680<NAME>KROGER FUEL #9999</STMTTRN></BANKTRANLIST><LEDGERBAL><BALAMT>-9334<DTASOF>20170331080000.000[-4:EDT]</LEDGERBAL><AVAILBAL><BALAMT>7630.17<DTASOF>20170331080000.000[-4:EDT]</AVAILBAL></CCSTMTRS></CCSTMTTRNRS></CREDITCARDMSGSRSV1></OFX>`)
var expected ofxgo.Response
var expected Response
EDT := time.FixedZone("EDT", -4*60*60)
EST := time.FixedZone("EST", -5*60*60)
expected.Version = ofxgo.OfxVersion102
expected.Version = OfxVersion102
expected.Signon.Status.Code = 0
expected.Signon.Status.Severity = "INFO"
expected.Signon.Status.Message = "SUCCESS"
expected.Signon.DtServer = *ofxgo.NewDate(2017, 3, 31, 15, 46, 48, 331000000, EDT)
expected.Signon.DtServer = *NewDate(2017, 3, 31, 15, 46, 48, 331000000, EDT)
expected.Signon.Language = "ENG"
expected.Signon.Org = "01"
expected.Signon.Fid = "81729"
var trnamt1, trnamt2, trnamt3 ofxgo.Amount
var trnamt1, trnamt2, trnamt3 Amount
trnamt1.SetFrac64(-796, 100)
trnamt2.SetFrac64(383046, 100)
trnamt3.SetFrac64(-1770, 100)
banktranlist := ofxgo.TransactionList{
DtStart: *ofxgo.NewDate(2016, 12, 1, 15, 46, 48, 688000000, EST),
DtEnd: *ofxgo.NewDate(2017, 3, 31, 15, 46, 48, 688000000, EDT),
Transactions: []ofxgo.Transaction{
banktranlist := TransactionList{
DtStart: *NewDate(2016, 12, 1, 15, 46, 48, 688000000, EST),
DtEnd: *NewDate(2017, 3, 31, 15, 46, 48, 688000000, EDT),
Transactions: []Transaction{
{
TrnType: ofxgo.TrnTypeDebit,
DtPosted: *ofxgo.NewDateGMT(2017, 2, 9, 12, 0, 0, 0),
TrnType: TrnTypeDebit,
DtPosted: *NewDateGMT(2017, 2, 9, 12, 0, 0, 0),
TrnAmt: trnamt1,
FiTID: "2017020924435657040207171600195",
Name: "SLICE OF NY",
},
{
TrnType: ofxgo.TrnTypeCredit,
DtPosted: *ofxgo.NewDateGMT(2016, 12, 28, 12, 0, 0, 0),
TrnType: TrnTypeCredit,
DtPosted: *NewDateGMT(2016, 12, 28, 12, 0, 0, 0),
TrnAmt: trnamt2,
FiTID: "2016122823633637200000258482730",
Name: "Payment Thank You Electro",
},
{
TrnType: ofxgo.TrnTypeDebit,
DtPosted: *ofxgo.NewDateGMT(2017, 3, 27, 12, 0, 0, 0),
TrnType: TrnTypeDebit,
DtPosted: *NewDateGMT(2017, 3, 27, 12, 0, 0, 0),
TrnAmt: trnamt3,
FiTID: "2017032724445727085300442885680",
Name: "KROGER FUEL #9999",
@ -128,34 +127,34 @@ NEWFILEUID:NONE
},
}
var balamt, availbalamt ofxgo.Amount
var balamt, availbalamt Amount
balamt.SetFrac64(-933400, 100)
availbalamt.SetFrac64(763017, 100)
usd, err := ofxgo.NewCurrSymbol("USD")
usd, err := NewCurrSymbol("USD")
if err != nil {
t.Fatalf("Unexpected error creating CurrSymbol for USD\n")
}
statementResponse := ofxgo.CCStatementResponse{
statementResponse := CCStatementResponse{
TrnUID: "59e850ad-7448-b4ce-4b71-29057763b306",
Status: ofxgo.Status{
Status: Status{
Code: 0,
Severity: "INFO",
},
CurDef: *usd,
CCAcctFrom: ofxgo.CCAcct{
CCAcctFrom: CCAcct{
AcctID: "9283744488463775",
},
BankTranList: &banktranlist,
BalAmt: balamt,
DtAsOf: *ofxgo.NewDate(2017, 3, 31, 8, 0, 0, 0, EDT),
DtAsOf: *NewDate(2017, 3, 31, 8, 0, 0, 0, EDT),
AvailBalAmt: &availbalamt,
AvailDtAsOf: ofxgo.NewDate(2017, 3, 31, 8, 0, 0, 0, EDT),
AvailDtAsOf: NewDate(2017, 3, 31, 8, 0, 0, 0, EDT),
}
expected.CreditCard = append(expected.CreditCard, &statementResponse)
response, err := ofxgo.ParseResponse(responseReader)
response, err := ParseResponse(responseReader)
if err != nil {
t.Fatalf("Unexpected error unmarshalling response: %s\n", err)
}