-- adapted webapp to connect to remote eXist instances
[Bookkeeping.git] / test / bk / httpFunctionalTest.bk
blobc37e8e49d0365c8822c8f82fb09fd566f3192d4a
3 ...TODO 
4 create ( <account xmlns='com/interrupt/bookkeeping/account' type="asset" id="expense" name="modified expeses" counterWeight="debit" /> ); 
5 create ( <account xmlns='com/interrupt/bookkeeping/account' type="asset" id="expense@tim.com" name="modified expeses" counterWeight="debit" /> ); 
6 create ( <account xmlns='com/interrupt/bookkeeping/account' type="asset" id="create" name="modified expeses" counterWeight="debit" /> ); 
7 create ( <account xmlns='com/interrupt/bookkeeping/account' type="asset" id="create:id" name="modified expeses" counterWeight="debit" /> ); 
9 var abc = create ( <debit xmlns='com/interrupt/bookkeeping/account' id='abc' amount='10.00' entryid='e1' accountid='1' currency='CDN' /> ); 
10 update ( (@abc) <debit xmlns='com/interrupt/bookkeeping/account' id='def' amount='10.00' entryid='e1' accountid='1' currency='CDN' /> ); 
13 create ( 
14         <entries id='' xmlns='com/interrupt/bookkeeping/journal' 
15                 xmlns:account='com/interrupt/bookkeeping/account' 
16                 xmlns:journal='com/interrupt/bookkeeping/journal' > 
17                 
18                 <journal:entry id='e1' entrynum='' state='' journalid='' date='' currency='CDN' >  
19                     <account:debit id='abc' amount='10.00' entryid='e1' accountid='1' currency='CDN' />  
20                     <account:debit id='def' amount='1.50' entryid='e1' accountid='2' currency='CDN' />  
21                     <account:credit id='ghi' amount='11.50' entryid='e1' accountid='3' currency='CDN' />  
22                 </journal:entry> 
23         </entries>
24 ); 
27 login ( user -username root -password password ); 
28 find ( ( load ( user -id twashing ) ) profileDetails -id user.details ); 
29 create ( debit ); 
30 print ( @previous ); 
33 list ( ( load ( bookkeeping -id main.bookkeeping ) ) accounts -id main.accounts ); 
37 ###
38 # expr to login 
39 login ( user -username root -password password ); 
42 ###
43 # expr to add a user 
44 #var aauthUsers = add ( (load ( users -id aauth.users ))
45 var aauthUsers = add ( (load ( `/system[ @id='main.system' ]/aauthentication[ @id='main.authentication' ]/users[ @id='aauth.users' ]` ))
46                 <user xmlns='com/interrupt/bookkeeping/users' id='twashing' username='twashing' password='password' >
47                         <profileDetails xmlns='com/interrupt/bookkeeping/users' id='user.details' >
48                                 <profileDetail xmlns='com/interrupt/bookkeeping/users' name='first.name' value='Timothy' />
49                                 <profileDetail xmlns='com/interrupt/bookkeeping/users' name='last.name' value='Washington' />
50                                 <profileDetail xmlns='com/interrupt/bookkeeping/users' name='email' value='twashing-gmail.com' />
51                                 <profileDetail xmlns='com/interrupt/bookkeeping/users' name='country' value='U.S.A' />
52                         </profileDetails>
53                 </user>
54         ); 
56 commit ( ( `/system[ @id='main.system' ]/aauthentication[ @id='main.authentication' ]/users[ @id='aauth.users' ]` ) @aauthUsers ); 
59 var mainSystem = add ( (load ( system -id main.system ) )
60                 <user xmlns='com/interrupt/bookkeeping/users' id='twashing' username='twashing' password='password' >
61                         <profileDetails xmlns='com/interrupt/bookkeeping/users' id='user.details' >
62                                 <profileDetail xmlns='com/interrupt/bookkeeping/users' name='first.name' value='Timothy' />
63                                 <profileDetail xmlns='com/interrupt/bookkeeping/users' name='last.name' value='Washington' />
64                                 <profileDetail xmlns='com/interrupt/bookkeeping/users' name='email' value='twashing-gmail.com' />
65                                 <profileDetail xmlns='com/interrupt/bookkeeping/users' name='country' value='U.S.A' />
66                         </profileDetails>
67                 </user>
68         ); 
70 ...TODO: var aauthUsers = add ( (load ( users -id aauth.users ))
71                 <user xmlns='com/interrupt/bookkeeping/users' id='twashing' username='twashing' password='password' >
72                         <profileDetails xmlns='com/interrupt/bookkeeping/users' id='user.details' >
73                                 <profileDetail xmlns='com/interrupt/bookkeeping/users' name='first.name' value='Timothy' />
74                                 <profileDetail xmlns='com/interrupt/bookkeeping/users' name='last.name' value='Washington' />
75                                 <profileDetail xmlns='com/interrupt/bookkeeping/users' name='email' value='twashing-gmail.com' />
76                                 <profileDetail xmlns='com/interrupt/bookkeeping/users' name='country' value='U.S.A' />
77                         </profileDetails>
78                         <profileDetails xmlns='com/interrupt/bookkeeping/users' id='group.details' >
79                                 <profileDetail xmlns='com/interrupt/bookkeeping/users' name='defaultCurrency' value='USD' />
80                         </profileDetails>
81                 </user>
82         ); 
84 ###
85 # expr to logout 
86 logout; 
90 ###
91 # expr to list account details 
92 var timUserDetails = find ( ( find ((@aauthUsers) user -username twashing) ) profileDetails -id user.details ); 
93 var timGroupDetails = find ( ( find ((@aauthUsers) group -username twashing) ) profileDetails -id user.details ); 
97 ###
98 # exprs to update account details 
99 update ( ( @timUserDetails ) 
100                         <profileDetails xmlns='com/interrupt/bookkeeping/users' id='user.details' >
101                                 <profileDetail name='first.name' value='Timothy' />
102                                 <profileDetail name='last.name' value='Washington' />
103                                 <profileDetail name='email' value='timothyjwashington-yahoo.ca' />
104                                 <profileDetail name='country' value='Canada' />
105                         </profileDetails>
106                 ); 
108 update ( ( load ( group -id group.twashing ) ) 
109                         <profileDetails id='group.details' >
110                                 <profileDetail name='defaultCurrency' value='CDN' />
111                         </profileDetails>
112                 ); 
117 # expressions to list account(s) / find / update / create / remove 
118 var mainAccounts = load ( accounts -id main.accounts ); 
119 add ( ( @mainAccounts ) 
120                 <account xmlns='com/interrupt/bookkeeping/account' type="asset" id="expense" name="regular expeses" counterWeight="debit" /> ); 
121 var expenseAccount = find ( (@mainAccounts) account -id expense ); 
122 update ( (@expenseAccount) 
123                 <account xmlns='com/interrupt/bookkeeping/account' type="asset" id="expense" name="modified expeses" counterWeight="debit" /> ); 
124 remove ( (load ( accounts -id main.accounts )) account -id expense ); 
127 # expressions to list journal(s) / find / update / create / remove 
128 var mainJournals = load ( journals -id main.journals ); 
129 add ( (@mainJournals) 
130                 <journal xmlns='com/interrupt/bookkeeping/journal' id='specialledger' name='specialledger' type='' balance='' /> ); 
131 var specialLedger = find ( (@mainJournals) journal -id specialledger ); 
132 update ( (@specialLedger) 
133                 <journal xmlns='com/interrupt/bookkeeping/journal' id='specialledger' name='modified ledger' type='' balance='' /> ); 
134 remove ( (load ( journals -id main.journals )) journal -id specialledger ); 
137 login ( user -username root -password password ); 
140 # expressions to list entry(s) / find / update / create / remove 
141 var mainEntries = find ( ( load ( journals -id main.journals ) ) entries -id main.entries ); 
142 add ( ( @mainEntries ) 
143                         <entry xmlns='com/interrupt/bookkeeping/journal' id='' entrynum='' state='' journalid='' date='2/1/2006' currency='CDN' >  
144                             <debit xmlns='com/interrupt/bookkeeping/account' id='' amount='10.00' entryid='' accountid='1' account='office equipment' currency='CDN' />  
145                             <debit xmlns='com/interrupt/bookkeeping/account' id='' amount='1.50' entryid='' accountid='2' account='tax' currency='CDN' />  
146                             <credit xmlns='com/interrupt/bookkeeping/account' id='' amount='11.50' entryid='' accountid='3' account='bank' currency='CDN' />  
147                         </entry>  
148         ); 
150 find ( ( load ( ( load ( journals -id main.journals ) ) entries -id main.entries ) ) ) 
151                 entry -id ... ); 
152 update ( ( load ( ( load ( journals -id main.journals ) ) entry -id ... ) ) ) 
153                         <entry xmlns='com/interrupt/bookkeeping/journal' id='' entrynum='' state='' journalid='' date='2/11/2006' >  
154                             <debit xmlns='com/interrupt/bookkeeping/account' id='' amount='10.00' entryid='' accountid='1' account="office equipment" />  
155                             <debit xmlns='com/interrupt/bookkeeping/account' id='' amount='2.50' entryid='' accountid='2' account="tax" />  
156                             <credit xmlns='com/interrupt/bookkeeping/account' id='' amount='12.50' entryid='' accountid='3' account="bank" />  
157                         </entry>  
158         );
159 remove ( ( load ( ( load ( journals -id main.journals ) ) entries -id main.entries ) ) ) 
160                 entry -id ... );