gnucash master: Add failing unittest for aqbanking lookup of trans_retrieval date.

Christian Stimming cstim at code.gnucash.org
Sun Sep 7 17:03:15 EDT 2014


Updated	 via  https://github.com/Gnucash/gnucash/commit/67155158 (commit)
	from  https://github.com/Gnucash/gnucash/commit/80aa327a (commit)



commit 671551585eb636554f955f4ed095d5d8106bdd8d
Author: Christian Stimming <christian at cstimming.de>
Date:   Sun Sep 7 22:58:07 2014 +0200

    Add failing unittest for aqbanking lookup of trans_retrieval date.
    
    The lookup of the "ab-trans-retrieval" property somehow fails to
    return the correct value. This is somewhat surprising as this
    property is already checked in the test-engine-kvp-properties.c and
    there it works fine. What's the problem here...?

diff --git a/src/import-export/aqb/test/file-book-hbcislot.gnucash b/src/import-export/aqb/test/file-book-hbcislot.gnucash
index d51f11b..e4b6c00 100644
--- a/src/import-export/aqb/test/file-book-hbcislot.gnucash
+++ b/src/import-export/aqb/test/file-book-hbcislot.gnucash
@@ -77,6 +77,45 @@
     </slot:value>
   </slot>
 </book:slots>
+<gnc:account version="2.0.0">
+  <act:name>Root Account</act:name>
+  <act:id type="guid">4674e1c45a07c85461d59c72b19d8263</act:id>
+  <act:type>ROOT</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:commodity-scu>100</act:commodity-scu>
+  <act:slots>
+    <slot>
+      <slot:key>hbci</slot:key>
+      <slot:value type="frame">
+        <slot>
+          <slot:key>account-id</slot:key>
+          <slot:value type="string">1234567890</slot:value>
+        </slot>
+        <slot>
+          <slot:key>account-uid</slot:key>
+          <slot:value type="integer">123</slot:value>
+        </slot>
+        <slot>
+          <slot:key>bank-code</slot:key>
+          <slot:value type="string">10020034</slot:value>
+        </slot>
+        <slot>
+          <slot:key>country-code</slot:key>
+          <slot:value type="integer">280</slot:value>
+        </slot>
+        <slot>
+          <slot:key>trans-retrieval</slot:key>
+          <slot:value type="timespec">
+            <ts:date>2014-08-29 20:47:36 +0200</ts:date>
+          </slot:value>
+        </slot>
+      </slot:value>
+    </slot>
+  </act:slots>
+</gnc:account>
 </gnc:book>
 </gnc-v2>
 
diff --git a/src/import-export/aqb/test/test-kvp.c b/src/import-export/aqb/test/test-kvp.c
index d6a3236..a001f1b 100644
--- a/src/import-export/aqb/test/test-kvp.c
+++ b/src/import-export/aqb/test/test-kvp.c
@@ -35,6 +35,7 @@ static char* get_filepath(const char* filename)
     const char *srcdir = g_getenv("SRCDIR");
     if (!srcdir)
     {
+        g_test_message("No env variable SRCDIR exists, assuming \".\"\n");
         srcdir = ".";
     }
 
@@ -156,6 +157,54 @@ test_qofsession_aqb_kvp( void )
             }
         }
 
+        {
+            // Check the kvp slots of a aqbanking-enabled account
+            QofBook *book = qof_session_get_book(new_session);
+            Account* account = gnc_book_get_root_account(book);
+            GDate retrieved_date, original_date;
+            gchar buff[MAX_DATE_LENGTH];
+
+            g_assert(account);
+
+            if (0)
+            {
+                Timespec retrieved_ts = gnc_ab_get_account_trans_retrieval(account);
+                g_test_message("retrieved_ts=%s\n", gnc_print_date(retrieved_ts));
+                printf("Time=%s\n", gnc_print_date(retrieved_ts));
+
+                retrieved_date = timespec_to_gdate(retrieved_ts);
+                g_date_set_dmy(&original_date, 29, 8, 2014);
+
+                g_assert_cmpint(g_date_compare(&retrieved_date, &original_date), ==, 0);
+            }
+
+            if (1)
+            {
+                Timespec original_ts = timespec_now(), retrieved_ts;
+
+                // Check whether the "ab-trans-retrieval" property of Account
+                // is written and read again correctly.
+                gnc_ab_set_account_trans_retrieval(account, original_ts);
+                retrieved_ts = gnc_ab_get_account_trans_retrieval(account);
+
+                printf("original_ts=%s = %d  retrieved_ts=%s = %d\n",
+                       gnc_print_date(original_ts), original_ts.tv_sec,
+                       gnc_print_date(retrieved_ts), retrieved_ts.tv_sec);
+
+                original_date = timespec_to_gdate(original_ts);
+                retrieved_date = timespec_to_gdate(retrieved_ts);
+
+                qof_print_gdate (buff, sizeof (buff), &original_date);
+                printf("original_date=%s\n", buff);
+                qof_print_gdate (buff, sizeof (buff), &retrieved_date);
+                printf("retrieved_date=%s\n", buff);
+
+                // Is the retrieved date identical to the one written
+                g_assert_cmpint(g_date_compare(&retrieved_date, &original_date), ==, 0);
+            }
+
+        }
+
         g_free(newfile);
         g_free(file2);
 



Summary of changes:
 .../aqb/test/file-book-hbcislot.gnucash            | 39 +++++++++++++++++
 src/import-export/aqb/test/test-kvp.c              | 49 ++++++++++++++++++++++
 2 files changed, 88 insertions(+)



More information about the gnucash-changes mailing list