gnucash master: Make aqbanking kvp test really working.
Christian Stimming
cstim at code.gnucash.org
Sat Aug 30 15:19:16 EDT 2014
Updated via https://github.com/Gnucash/gnucash/commit/1ee4210b (commit)
from https://github.com/Gnucash/gnucash/commit/5b653811 (commit)
commit 1ee4210b5f521a66904bdec4beeb186f5c58a5cb
Author: Christian Stimming <christian at cstimming.de>
Date: Sat Aug 30 21:18:35 2014 +0200
Make aqbanking kvp test really working.
It now contains the part that is failing since 7faed6540162ccd1fe which
is disabled at the moment but can be seen by setting test-kvp:c:94 to
if (1).
diff --git a/src/import-export/aqb/test/Makefile.am b/src/import-export/aqb/test/Makefile.am
index e50fbe8..dcd0391 100644
--- a/src/import-export/aqb/test/Makefile.am
+++ b/src/import-export/aqb/test/Makefile.am
@@ -62,3 +62,7 @@ test_aqb_CFLAGS = \
${GTK_CFLAGS} \
${GLIB_CFLAGS} \
${AQBANKING_CFLAGS}
+
+TESTS_ENVIRONMENT = \
+ SRCDIR=${srcdir} \
+ G_DEBUG=
diff --git a/src/import-export/aqb/test/file-book-hbcislot.gnucash b/src/import-export/aqb/test/file-book-hbcislot.gnucash
index e7e1309..d51f11b 100644
--- a/src/import-export/aqb/test/file-book-hbcislot.gnucash
+++ b/src/import-export/aqb/test/file-book-hbcislot.gnucash
@@ -31,7 +31,6 @@
xmlns:vendor="http://www.gnucash.org/XML/vendor">
<gnc:book version="2.0.0">
<book:id type="guid">df401b548fd313dc40a50051277a0ae6</book:id>
-</gnc:book>
<book:slots>
<slot>
<slot:key>hbci</slot:key>
@@ -78,6 +77,7 @@
</slot:value>
</slot>
</book:slots>
+</gnc:book>
</gnc-v2>
<!-- Local variables: -->
diff --git a/src/import-export/aqb/test/test-aqb.c b/src/import-export/aqb/test/test-aqb.c
index ff96bf6..2e6d903 100644
--- a/src/import-export/aqb/test/test-aqb.c
+++ b/src/import-export/aqb/test/test-aqb.c
@@ -30,7 +30,7 @@ Write and link other test files */
#include "gnc-module/gnc-module.h"
#include "engine/gnc-engine.h"
-GTestSuite* test_suite_kvp ( void );
+void test_qofsession_aqb_kvp( void );
int
main (int argc,
@@ -51,8 +51,8 @@ main (int argc,
/* Add test functions and suites. See
* http://library.gnome.org/devel/glib/stable/glib-Testing.html for
* details. Unfortunately, GLib-Testing doesn't provide the automatic
- * registration features of more sophisitcated frameworks. */
- g_test_add_func ("/AQBANKING/Kvp", test_suite_kvp);
+ * registration features of more sophisticated frameworks. */
+ g_test_add_func ("/src/import-export/aqb/kvp", test_qofsession_aqb_kvp);
return g_test_run();
}
diff --git a/src/import-export/aqb/test/test-kvp.c b/src/import-export/aqb/test/test-kvp.c
index 8dc7586..5a54484 100644
--- a/src/import-export/aqb/test/test-kvp.c
+++ b/src/import-export/aqb/test/test-kvp.c
@@ -22,123 +22,107 @@
#include <config.h>
#include <glib.h>
-/* This is optional; you only need it if you have external fixtures or mocks. */
-//#include "test_module_support.h"
-/* Header for this module and any others that you need */
-//#include <module_1.h>
-#include "gnc-ab-kvp.h"
-
-/* Declare the test path for the suite. g_test_add_func automatically
- * creates a nested set of test suites for us based on this path. */
-static const gchar *suitename = "aqbanking/kvp";
-
-/* Test fixture: A struct, a setup function, and a teardown function are passed to g_test_add(); add getters, setters, and whatever other functions you need to call from your test functions. */
-typedef struct
-{
- gint foo;
- gdouble bar;
-} Fixture;
-static void
-setup_module_test(Fixture *fixture, gconstpointer pData)
-{
- /* Do something useful */
-}
+// for the gnc_ab_get_book_template_list() et al. functions
+#include "import-export/aqb/gnc-ab-kvp.h"
+#include "engine/gnc-hooks.h"
-static void
-teardown_module_test(Fixture *fixture, gconstpointer pData)
+static char* get_filepath(const char* filename)
{
- /* Clean up after ourselves */
-}
+ char *result;
-static void
-test_function( void )
-{
- /* A simple test function */
-}
+ const char *srcdir = g_getenv("SRCDIR");
+ if (!srcdir)
+ {
+ srcdir = ".";
+ }
-static void
-test_function_with_data( gconstpointer data )
-{
- /* a more complicated function that needs arguments at invocation */
+ result = g_strdup_printf("%s/%s", srcdir, filename);
+
+ g_test_message("Using file path %s\n", result);
+
+ // Test whether the file really exists
+ g_assert(g_file_test(result, G_FILE_TEST_EXISTS));
+
+ return result;
}
-/* Assert macros that you can use in your test functions. "cmp" is a
- * comparison operator, one of ==, !=, <, >, <=, >=.
- *
- * g_assert( boolean_expression )
- * g_assert_not_reached()
- * g_assert_cmpstr( gchar *s1, cmp, gchar *s2 )
- * g_assert_cmpint( int s1, cmp, int s2 )
- * g_assert_cmpuint( unsigned int s1, cmp, unsigned int s2 )
- * g_assert_cmphex( unsigned int s1, cmp, unsigned int s2 )
- * g_assert_cmpfloat( double s1, cmp, double s2 )
- * g_assert_no_error( GError *err )
- * g_assert_error( GError *err, GQuark domain, gint code )
- *
- * You can also emit arbitrary messages into the test report with
- * g_test_message( const char* format, ... )
- */
-GTestSuite*
-test_suite_kvp ( void )
+void
+test_qofsession_aqb_kvp( void )
{
-#define TOP_SRCDIR "../../../../../"
/* load the accounts from the users datafile */
/* but first, check to make sure we've got a session going. */
- QofSession *new_session;
- const char* newfile;
QofBackendError io_err;
+ char *file1 = get_filepath("file-book.gnucash");
+ char *file2 = get_filepath("file-book-hbcislot.gnucash");
-#if 0
- // A file with no content at all, but a valid XML file
- new_session = qof_session_new ();
- newfile = "file://" TOP_SRCDIR "src/import-export/aqb/test/file-book.gnucash";
- qof_session_begin (new_session, newfile, TRUE, FALSE, FALSE);
- io_err = qof_session_get_error (new_session);
- printf("io_err1 = %d\n", io_err);
- g_assert(io_err != ERR_BACKEND_NO_HANDLER); // Do not have no handler
+ if (1)
+ {
+ // A file with no content at all, but a valid XML file
+ QofSession *new_session = qof_session_new ();
+ char *newfile = g_strdup_printf("file://%s", file1);
- g_assert(io_err != ERR_BACKEND_NO_SUCH_DB); // DB must exist
- g_assert(io_err != ERR_BACKEND_LOCKED);
- g_assert(io_err == 0);
+ qof_session_begin (new_session, newfile, TRUE, FALSE, FALSE);
+ io_err = qof_session_get_error (new_session);
+ //printf("io_err1 = %d\n", io_err);
+ g_assert(io_err != ERR_BACKEND_NO_HANDLER); // Do not have no handler
- {
- GList *mylist = gnc_ab_get_book_template_list(qof_session_get_book(new_session));
- g_assert(mylist == 0);
- }
-#endif
+ g_assert(io_err != ERR_BACKEND_NO_SUCH_DB); // DB must exist
+ g_assert(io_err != ERR_BACKEND_LOCKED);
+ g_assert(io_err == 0);
- //qof_session_destroy(new_session);
+ qof_session_load (new_session, NULL);
+ io_err = qof_session_get_error (new_session);
+ //printf("io_err2 = %d\n", io_err);
+ g_assert(io_err == 0);
-#if 0
- // A file with no content except for the book_template_list kvp
- // slot
- new_session = qof_session_new ();
- newfile = "file://" TOP_SRCDIR "src/import-export/aqb/test/file-book-hbcislot.gnucash";
- qof_session_begin (new_session, newfile, TRUE, FALSE, FALSE);
- io_err = qof_session_get_error (new_session);
- printf("io_err1 = %d\n", io_err);
- g_assert(io_err != ERR_BACKEND_NO_HANDLER); // Do not have no handler
+ // No HBCI slot exists, of course
- g_assert(io_err != ERR_BACKEND_NO_SUCH_DB); // DB must exist
- g_assert(io_err != ERR_BACKEND_LOCKED);
- g_assert(io_err == 0);
+ {
+ // No HBCI slot exists, of course
+ GList *mylist = gnc_ab_get_book_template_list(qof_session_get_book(new_session));
+ g_assert(mylist == 0);
+ }
+ g_free(newfile);
+ g_free(file1);
+
+ gnc_hook_run(HOOK_BOOK_CLOSED, new_session);
+ //qof_session_destroy(new_session); // tries to delete the LCK file but it wasn't created in the first place
+ }
+
+ if (0)
{
- GList *mylist = gnc_ab_get_book_template_list(qof_session_get_book(new_session));
- g_assert(mylist != 0); // do we have the slot?!
+ // A file with no content except for the book_template_list kvp
+ // slot
+ QofSession *new_session = qof_session_new ();
+ char *newfile = g_strdup_printf("file://%s", file2);
+
+ qof_session_begin (new_session, newfile, TRUE, FALSE, FALSE);
+ io_err = qof_session_get_error (new_session);
+ //printf("io_err1 = %d\n", io_err);
+ g_assert(io_err != ERR_BACKEND_NO_HANDLER); // Do not have no handler
+
+ g_assert(io_err != ERR_BACKEND_NO_SUCH_DB); // DB must exist
+ g_assert(io_err != ERR_BACKEND_LOCKED);
+ g_assert(io_err == 0);
+
+ qof_session_load (new_session, NULL);
+ io_err = qof_session_get_error (new_session);
+ //printf("io_err2 = %d\n", io_err);
+ g_assert(io_err == 0);
+
+ {
+ GList *mylist = gnc_ab_get_book_template_list(qof_session_get_book(new_session));
+ g_assert(mylist != 0); // do we have the slot?!
+ }
+
+ g_free(newfile);
+ g_free(file2);
+
+ gnc_hook_run(HOOK_BOOK_CLOSED, new_session);
+ //qof_session_destroy(new_session); // tries to delete the LCK file but it wasn't created in the first place
}
-#endif
-
-#if 0
- g_test_add_func( suitename, test_function );
- g_test_add_data_func( suitename, (gconstpointer)(&data),
- test_function_with_data );
- g_test_add( suitename, Fixture,
- data,
- setup_module_test,
- test_function_with_fixture,
- teardown_module_test);
-#endif
+
}
Summary of changes:
src/import-export/aqb/test/Makefile.am | 4 +
.../aqb/test/file-book-hbcislot.gnucash | 2 +-
src/import-export/aqb/test/test-aqb.c | 6 +-
src/import-export/aqb/test/test-kvp.c | 180 ++++++++++-----------
4 files changed, 90 insertions(+), 102 deletions(-)
More information about the gnucash-changes
mailing list