mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Assert on entry to qof_instance_set() if editlevel is 0
To ensure that change will be forwarded to the backend
This commit is contained in:
parent
291a3abfa3
commit
d0be95f2c6
@ -60,7 +60,7 @@ typedef struct
|
||||
/* Prototype to shut clang up */
|
||||
void test_suite_engine_kvp_properties (void);
|
||||
|
||||
/* Private QofInstance function needed for testing */
|
||||
/* Private QofInstance functions needed for testing */
|
||||
extern void qof_instance_mark_clean (QofInstance*);
|
||||
|
||||
const gchar *suitename = "/engine/kvp-properties";
|
||||
@ -147,7 +147,7 @@ test_account_kvp_properties (Fixture *fixture, gconstpointer pData)
|
||||
Timespec trans_retr = timespec_now ();
|
||||
Timespec *trans_retr_r;
|
||||
|
||||
|
||||
xaccAccountBeginEdit (fixture->acct);
|
||||
qof_instance_set (QOF_INSTANCE (fixture->acct),
|
||||
"lot-next-id", next_id,
|
||||
"online-id", online_id,
|
||||
@ -189,6 +189,7 @@ test_trans_kvp_properties (Fixture *fixture, gconstpointer pData)
|
||||
gchar *online_id = "my online id";
|
||||
gchar *online_id_r;
|
||||
|
||||
xaccTransBeginEdit (fixture->trans);
|
||||
qof_instance_set (QOF_INSTANCE (fixture->trans),
|
||||
"invoice", invoice,
|
||||
"from-sched-xaction", from_sx,
|
||||
@ -229,6 +230,7 @@ test_split_kvp_properties (Fixture *fixture, gconstpointer pData)
|
||||
gnc_numeric credit_numeric = gnc_numeric_create (789, 456);
|
||||
gnc_numeric *debit_numeric_r, *credit_numeric_r;
|
||||
|
||||
qof_begin_edit (QOF_INSTANCE (fixture->split));
|
||||
qof_instance_set (QOF_INSTANCE (fixture->split),
|
||||
"sx-debit-formula", debit_formula,
|
||||
"sx-debit-numeric", &debit_numeric,
|
||||
@ -263,6 +265,7 @@ test_split_kvp_properties (Fixture *fixture, gconstpointer pData)
|
||||
g_free (debit_numeric_r);
|
||||
g_free (credit_formula_r);
|
||||
g_free (credit_numeric_r);
|
||||
qof_begin_edit (QOF_INSTANCE (fixture->split));
|
||||
qof_instance_set (QOF_INSTANCE (fixture->split),
|
||||
"sx-credit-formula", NULL,
|
||||
NULL);
|
||||
@ -286,6 +289,7 @@ test_lot_kvp_properties (Fixture *fixture, gconstpointer pData)
|
||||
GncGUID *owner = guid_malloc ();
|
||||
GncGUID *owner_r;
|
||||
|
||||
qof_begin_edit (QOF_INSTANCE (fixture->lot));
|
||||
qof_instance_set (QOF_INSTANCE (fixture->lot),
|
||||
"invoice", invoice,
|
||||
"owner-type", owner_type,
|
||||
@ -319,6 +323,7 @@ test_customer_kvp_properties (Fixture *fixture, gconstpointer pData)
|
||||
GncGUID *pmt_acct = guid_malloc ();
|
||||
GncGUID *inv_acct_r, *pmt_acct_r;
|
||||
|
||||
qof_begin_edit (QOF_INSTANCE (fixture->cust));
|
||||
qof_instance_set (QOF_INSTANCE (fixture->cust),
|
||||
"export-pdf-dir", pdf_dir,
|
||||
"invoice-last-posted-account", inv_acct,
|
||||
@ -354,6 +359,7 @@ test_employee_kvp_properties (Fixture *fixture, gconstpointer pData)
|
||||
GncGUID *pmt_acct = guid_malloc ();
|
||||
GncGUID *inv_acct_r, *pmt_acct_r;
|
||||
|
||||
qof_begin_edit (QOF_INSTANCE (fixture->emp));
|
||||
qof_instance_set (QOF_INSTANCE (fixture->emp),
|
||||
"export-pdf-dir", pdf_dir,
|
||||
"invoice-last-posted-account", inv_acct,
|
||||
@ -386,6 +392,7 @@ test_job_kvp_properties (Fixture *fixture, gconstpointer pData)
|
||||
gchar *pdf_dir = "/foo/bar/baz";
|
||||
gchar *pdf_dir_r;
|
||||
|
||||
qof_begin_edit (QOF_INSTANCE (fixture->job));
|
||||
qof_instance_set (QOF_INSTANCE (fixture->job),
|
||||
"export-pdf-dir", pdf_dir,
|
||||
NULL);
|
||||
@ -411,6 +418,7 @@ test_vendor_kvp_properties (Fixture *fixture, gconstpointer pData)
|
||||
GncGUID *pmt_acct = guid_malloc ();
|
||||
GncGUID *inv_acct_r, *pmt_acct_r;
|
||||
|
||||
qof_begin_edit (QOF_INSTANCE (fixture->vend));
|
||||
qof_instance_set (QOF_INSTANCE (fixture->vend),
|
||||
"export-pdf-dir", pdf_dir,
|
||||
"invoice-last-posted-account", inv_acct,
|
||||
|
@ -1137,9 +1137,11 @@ test_xaccSplitOrder (Fixture *fixture, gconstpointer pData)
|
||||
|
||||
/* create correct slot path */
|
||||
g_test_message( "Testing with use-split-action-for-num set to true - t" );
|
||||
qof_book_begin_edit (book);
|
||||
qof_instance_set (QOF_INSTANCE (book),
|
||||
"split-action-num-field", "t",
|
||||
NULL);
|
||||
qof_book_commit_edit (book);
|
||||
g_assert(qof_book_use_split_action_for_num_field(xaccSplitGetBook(split)) == TRUE);
|
||||
|
||||
g_assert_cmpint (xaccSplitOrder (split, o_split), ==, -1);
|
||||
@ -1151,9 +1153,11 @@ test_xaccSplitOrder (Fixture *fixture, gconstpointer pData)
|
||||
o_split->action = NULL;
|
||||
split->action = "foo";
|
||||
o_split->parent = NULL;
|
||||
qof_book_begin_edit (book);
|
||||
qof_instance_set (QOF_INSTANCE (book),
|
||||
"split-action-num-field", "f",
|
||||
NULL);
|
||||
qof_book_commit_edit (book);
|
||||
g_assert(qof_book_use_split_action_for_num_field(xaccSplitGetBook(split)) == FALSE);
|
||||
split->parent = NULL;
|
||||
/* This should return > 0 because o_split has no memo string */
|
||||
@ -1782,9 +1786,11 @@ test_xaccSplitGetOtherSplit (Fixture *fixture, gconstpointer pData)
|
||||
g_assert (kvp_frame_get_slot (split->inst.kvp_data, "lot-split") == NULL);
|
||||
kvp_frame_set_slot (split1->inst.kvp_data, "lot-split", NULL);
|
||||
g_assert (kvp_frame_get_slot (split1->inst.kvp_data, "lot-split") == NULL);
|
||||
qof_book_begin_edit (book);
|
||||
qof_instance_set (QOF_INSTANCE (book),
|
||||
"trading-accts", "t",
|
||||
NULL);
|
||||
qof_book_commit_edit (book);
|
||||
g_assert (xaccTransUseTradingAccounts (txn));
|
||||
g_assert (xaccSplitGetOtherSplit (split) == NULL);
|
||||
split2->acc = acc2;
|
||||
|
@ -1048,10 +1048,11 @@ test_xaccTransGetImbalance_trading (Fixture *fixture,
|
||||
Account *acc2 = xaccMallocAccount (book);
|
||||
gnc_numeric value;
|
||||
MonetaryList *mlist;
|
||||
|
||||
qof_book_begin_edit (book);
|
||||
qof_instance_set (QOF_INSTANCE (book),
|
||||
"trading-accts", "t",
|
||||
NULL);
|
||||
qof_book_commit_edit (book);
|
||||
|
||||
/* Without trading splits, the list is unbalanced */
|
||||
mlist = xaccTransGetImbalance (fixture->txn);
|
||||
@ -1134,9 +1135,12 @@ test_xaccTransIsBalanced_trading (Fixture *fixture, gconstpointer pData)
|
||||
Account *acc1 = xaccMallocAccount (book);
|
||||
Account *acc2 = xaccMallocAccount (book);
|
||||
|
||||
qof_book_begin_edit (book);
|
||||
qof_instance_set (QOF_INSTANCE (book),
|
||||
"trading-accts", "t",
|
||||
NULL);
|
||||
qof_book_commit_edit (book);
|
||||
|
||||
xaccAccountSetCommodity (acc1, fixture->curr);
|
||||
xaccAccountSetCommodity (acc2, fixture->comm);
|
||||
xaccAccountSetType (acc1, ACCT_TYPE_TRADING);
|
||||
@ -1639,10 +1643,6 @@ test_xaccTransCommitEdit (void)
|
||||
xaccTransSetCurrency (txn, curr);
|
||||
xaccSplitSetParent (split1, txn);
|
||||
xaccSplitSetParent (split2, txn);
|
||||
/* xaccTransCommitEdit doesn't do anything with kvp
|
||||
kvp_frame_set_double (frame, "/qux/quux/corge", 123.456);
|
||||
qof_instance_set_slots (QOF_INSTANCE (txn), frame);
|
||||
*/
|
||||
}
|
||||
/* Setup's done, now test: */
|
||||
xaccTransCommitEdit (txn);
|
||||
|
@ -940,8 +940,10 @@ void
|
||||
qof_instance_set (QofInstance *inst, const gchar *first_prop, ...)
|
||||
{
|
||||
va_list ap;
|
||||
QofInstancePrivate *priv = GET_PRIVATE(inst);
|
||||
g_return_if_fail (QOF_IS_INSTANCE (inst));
|
||||
|
||||
g_assert (priv->editlevel > 0);
|
||||
qof_instance_set_dirty (inst);
|
||||
va_start (ap, first_prop);
|
||||
g_object_set_valist (G_OBJECT (inst), first_prop, ap);
|
||||
|
@ -361,6 +361,7 @@ test_book_use_trading_accounts( Fixture *fixture, gconstpointer pData )
|
||||
g_assert( qof_book_use_trading_accounts( fixture-> book ) == FALSE );
|
||||
|
||||
g_test_message( "Testing with existing trading accounts set to true - t" );
|
||||
qof_book_begin_edit (fixture->book);
|
||||
qof_instance_set (QOF_INSTANCE (fixture->book),
|
||||
"trading-accts", "t",
|
||||
NULL);
|
||||
@ -371,6 +372,7 @@ test_book_use_trading_accounts( Fixture *fixture, gconstpointer pData )
|
||||
"trading-accts", "tt",
|
||||
NULL);
|
||||
g_assert( qof_book_use_trading_accounts( fixture-> book ) == FALSE );
|
||||
qof_book_commit_edit (fixture->book);
|
||||
|
||||
}
|
||||
|
||||
@ -384,6 +386,7 @@ test_book_get_num_days_autofreeze( Fixture *fixture, gconstpointer pData )
|
||||
g_assert( qof_book_uses_autoreadonly( fixture-> book ) == FALSE );
|
||||
g_assert( qof_book_get_num_days_autoreadonly( fixture-> book ) == 0 );
|
||||
|
||||
qof_book_begin_edit (fixture->book);
|
||||
qof_instance_set (QOF_INSTANCE (fixture->book),
|
||||
"autoreadonly-days", (gdouble)17,
|
||||
NULL);
|
||||
@ -404,6 +407,7 @@ test_book_get_num_days_autofreeze( Fixture *fixture, gconstpointer pData )
|
||||
g_assert( qof_book_uses_autoreadonly( fixture-> book ) == TRUE );
|
||||
g_assert( qof_book_get_num_days_autoreadonly( fixture-> book ) == 32 );
|
||||
|
||||
qof_book_commit_edit (fixture->book);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -414,6 +418,7 @@ test_book_use_split_action_for_num_field( Fixture *fixture, gconstpointer pData
|
||||
|
||||
g_test_message( "Testing with existing use split action for num set to true - t" );
|
||||
|
||||
qof_book_begin_edit (fixture->book);
|
||||
qof_instance_set (QOF_INSTANCE (fixture->book),
|
||||
"split-action-num-field", "t",
|
||||
NULL);
|
||||
@ -424,6 +429,7 @@ test_book_use_split_action_for_num_field( Fixture *fixture, gconstpointer pData
|
||||
"split-action-num-field", "tt",
|
||||
NULL);
|
||||
g_assert( qof_book_use_split_action_for_num_field( fixture-> book ) == FALSE );
|
||||
qof_book_commit_edit (fixture->book);
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user