From 2c4cb83ffc0836e5c38ba7f4d994ac37f50c081c Mon Sep 17 00:00:00 2001 From: polsala Date: Thu, 11 Jun 2020 16:26:57 +0200 Subject: [PATCH 1/4] Try to test inher views --- destral/testing.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/destral/testing.py b/destral/testing.py index a6f870f..7dcc1fc 100644 --- a/destral/testing.py +++ b/destral/testing.py @@ -140,10 +140,22 @@ def test_all_views(self): if view.inherit_id: while view.inherit_id: view = view.inherit_id - model.fields_view_get(txn.cursor, txn.user, view.id, - view.type) - logger.info('Testing main view %s (id: %s)', - view.name, view.id) + if not view.inherit_id: + model.fields_view_get( + txn.cursor, txn.user, view.id, view.type + ) + logger.info( + 'Testing main view %s (id: %s)', + view.name, view.id + ) + else: + model.fields_view_get( + txn.cursor, txn.user, view.id, view.type + ) + logger.info( + 'Testing inherit view %s (id: %s)', + view.name, view.id + ) def test_access_rules(self): """Test access rules for all the models created in the module From f7f2c9f70bd3ff9a9fba40e41d82c96268c40399 Mon Sep 17 00:00:00 2001 From: polsala Date: Thu, 11 Jun 2020 17:39:31 +0200 Subject: [PATCH 2/4] imp 1 --- destral/testing.py | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/destral/testing.py b/destral/testing.py index 7dcc1fc..fd19a77 100644 --- a/destral/testing.py +++ b/destral/testing.py @@ -139,23 +139,36 @@ def test_all_views(self): view.type) if view.inherit_id: while view.inherit_id: - view = view.inherit_id - if not view.inherit_id: - model.fields_view_get( - txn.cursor, txn.user, view.id, view.type - ) - logger.info( - 'Testing main view %s (id: %s)', - view.name, view.id - ) - else: + try: + # print view.read([]) + # inh = imd_obj.read( + # txn.cursor, txn.user, view.id + # ) + model.fields_view_get( txn.cursor, txn.user, view.id, view.type ) - logger.info( - 'Testing inherit view %s (id: %s)', - view.name, view.id + except IndexError as ie: + err_mn = '{}.{}'.format(view.origin_module.name, view.name) + raise Exception( + 'Inherit View (xml id: %s) references model %s ' + 'which does ' + 'not exist' % ( + err_mn, view.model + ) ) + logger.info( + 'Testing inherit view %s (id: %s)', + view.name, view.id + ) + view = view.inherit_id + model.fields_view_get( + txn.cursor, txn.user, view.id, view.type + ) + logger.info( + 'Testing main view %s (id: %s)', + view.name, view.id + ) def test_access_rules(self): """Test access rules for all the models created in the module From 86663156a9a1c1ee7588bf746f2ae1960cf38adb Mon Sep 17 00:00:00 2001 From: polsala Date: Thu, 11 Jun 2020 17:51:35 +0200 Subject: [PATCH 3/4] imp 2 --- destral/testing.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/destral/testing.py b/destral/testing.py index fd19a77..ddec7d9 100644 --- a/destral/testing.py +++ b/destral/testing.py @@ -140,21 +140,18 @@ def test_all_views(self): if view.inherit_id: while view.inherit_id: try: - # print view.read([]) - # inh = imd_obj.read( - # txn.cursor, txn.user, view.id - # ) - + print view.read([]) model.fields_view_get( txn.cursor, txn.user, view.id, view.type ) except IndexError as ie: err_mn = '{}.{}'.format(view.origin_module.name, view.name) raise Exception( - 'Inherit View (xml id: %s) references model %s ' - 'which does ' - 'not exist' % ( - err_mn, view.model + 'Inherit View (xml id: %s) ' + 'references model %s ' + 'has non-existent field ' + 'in model %s' % ( + err_mn, view.model, view.model ) ) logger.info( From 3b03f47913e5c4d9714ed408c50b926e8edb8d05 Mon Sep 17 00:00:00 2001 From: polsala Date: Fri, 12 Jun 2020 15:22:25 +0200 Subject: [PATCH 4/4] less code because raise done in erp --- destral/testing.py | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/destral/testing.py b/destral/testing.py index ddec7d9..fcbf3e1 100644 --- a/destral/testing.py +++ b/destral/testing.py @@ -140,20 +140,11 @@ def test_all_views(self): if view.inherit_id: while view.inherit_id: try: - print view.read([]) model.fields_view_get( txn.cursor, txn.user, view.id, view.type ) - except IndexError as ie: - err_mn = '{}.{}'.format(view.origin_module.name, view.name) - raise Exception( - 'Inherit View (xml id: %s) ' - 'references model %s ' - 'has non-existent field ' - 'in model %s' % ( - err_mn, view.model, view.model - ) - ) + except ReferenceError as r_err: + raise r_err logger.info( 'Testing inherit view %s (id: %s)', view.name, view.id