Re: [Freeipa-devel] [PATCH] 314 Fixed entity definition in test cases.

2011-11-18 Thread Petr Vobornik

On 11/17/2011 08:25 PM, Endi Sukma Dewata wrote:

The test cases have been updated to use the new extensible mechanism
for defining and registering entities.

Ticket #2043



1) In the tests is a call of entity_init method which isn't defined 
anywhere. It leads to JS error and test fail.


--
Petr Vobornik

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


Re: [Freeipa-devel] [PATCH] 314 Fixed entity definition in test cases.

2011-11-18 Thread Endi Sukma Dewata

On 11/18/2011 4:29 AM, Petr Vobornik wrote:

1) In the tests is a call of entity_init method which isn't defined
anywhere. It leads to JS error and test fail.


Fixed. It was defined in another patch:

diff --git a/install/ui/entity.js b/install/ui/entity.js
index f7bf992..4e5c724 100644
--- a/install/ui/entity.js
+++ b/install/ui/entity.js
@@ -217,6 +217,7 @@ IPA.entity = function(spec) {
 return [that.name + '-pkey'];
 };

+that.entity_init = that.init;

 return that;
 };

--
Endi S. Dewata
From e392e48e0586eff0b117497b83d8bab173abc80a Mon Sep 17 00:00:00 2001
From: Endi Sukma Dewata edew...@redhat.com
Date: Thu, 17 Nov 2011 12:09:00 -0600
Subject: [PATCH] Fixed entity definition in test cases.

The test cases have been updated to use the new extensible mechanism
for defining and registering entities.

Ticket #2043
---
 install/ui/entity.js |1 +
 install/ui/ipa.js|   73 -
 install/ui/test/details_tests.js |   74 ++
 install/ui/test/entity_tests.js  |   29 ---
 4 files changed, 107 insertions(+), 70 deletions(-)

diff --git a/install/ui/entity.js b/install/ui/entity.js
index 
f7bf992aada9070ea81fb0271a4dce41706a7914..4e5c724472a6c2eac1bd6c562f75e408d3d9828e
 100644
--- a/install/ui/entity.js
+++ b/install/ui/entity.js
@@ -217,6 +217,7 @@ IPA.entity = function(spec) {
 return [that.name + '-pkey'];
 };
 
+that.entity_init = that.init;
 
 return that;
 };
diff --git a/install/ui/ipa.js b/install/ui/ipa.js
index 
c6d39478a35b9ab8d19065572c9b469a84722d06..1ebf1acc4293fd83ff5971541b58560801922d32
 100644
--- a/install/ui/ipa.js
+++ b/install/ui/ipa.js
@@ -167,9 +167,47 @@ var IPA = function() {
 };
 
 that.register = function(name, factory) {
+that.remove_entity(name);
 that.entity_factories[name] = factory;
 };
 
+that.create_entity = function(name) {
+var factory = that.entity_factories[name];
+if (!factory) return null;
+
+try {
+var builder = that.entity_builder();
+
+builder.entity({
+factory: factory,
+name: name
+});
+
+var entity = builder.build();
+
+entity.init({
+builder: builder
+});
+
+return entity;
+
+} catch (e) {
+if (e.expected) {
+/*expected exceptions thrown by builder just mean that
+  entities are not to be registered. */
+return null;
+}
+
+if (e.message) {
+alert(e.message);
+} else {
+alert(e);
+}
+
+return null;
+}
+};
+
 that.get_entities = function() {
 return that.entities.values;
 };
@@ -177,39 +215,8 @@ var IPA = function() {
 that.get_entity = function(name) {
 var entity = that.entities.get(name);
 if (!entity) {
-var factory = that.entity_factories[name];
-if (!factory) {
-return null;
-}
-
-try {
-var builder = that.entity_builder();
-
-builder.entity({
-factory: factory,
-name: name
-});
-
-entity = builder.build();
-entity.init({
-builder: builder
-});
-
-that.add_entity(entity);
-
-} catch (e) {
-if (e.expected) {
-/*expected exceptions thrown by builder just mean that
-  entities are not to be registered. */
-return null;
-}
-if (e.message) {
-alert(e.message);
-} else {
-alert(e);
-}
-return null;
-}
+entity = that.create_entity(name);
+if (entity) that.add_entity(entity);
 }
 return entity;
 };
diff --git a/install/ui/test/details_tests.js b/install/ui/test/details_tests.js
index 
c6a55cda9046fa74a8c08f646f6288972f96ae58..80136649b9624c32867e639f6de82ec6f68d30f1
 100644
--- a/install/ui/test/details_tests.js
+++ b/install/ui/test/details_tests.js
@@ -156,30 +156,58 @@ test(Testing details lifecycle: create, load., 
function(){
 return widget;
 }
 
-var entity =   IPA.
-entity_builder().
-entity('user').
-details_facet({sections:[
-{
-name: 'identity',
-label: IPA.messages.details.identity,
-fields:['title','givenname','sn','cn','displayname', 
'initials']
-},
-{
-name: 'contact',
-label:'contact',
-fields:
-[  {factory: test_widget,name:'test'},
-  

Re: [Freeipa-devel] [PATCH] 314 Fixed entity definition in test cases.

2011-11-18 Thread Endi Sukma Dewata

On 11/18/2011 9:01 AM, Petr Vobornik wrote:

1) In the tests is a call of entity_init method which isn't defined
anywhere. It leads to JS error and test fail.


Fixed. It was defined in another patch:


ACK


Pushed to master.


--
Endi S. Dewata

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


[Freeipa-devel] [PATCH] 314 Fixed entity definition in test cases.

2011-11-17 Thread Endi Sukma Dewata

The test cases have been updated to use the new extensible mechanism
for defining and registering entities.

Ticket #2043

--
Endi S. Dewata
From e22c9a97e0853f19e93e278c3299e242e8f7034e Mon Sep 17 00:00:00 2001
From: Endi Sukma Dewata edew...@redhat.com
Date: Thu, 17 Nov 2011 12:09:00 -0600
Subject: [PATCH] Fixed entity definition in test cases.

The test cases have been updated to use the new extensible mechanism
for defining and registering entities.

Ticket #2043
---
 install/ui/ipa.js|   73 -
 install/ui/test/details_tests.js |   74 ++
 install/ui/test/entity_tests.js  |   29 ---
 3 files changed, 106 insertions(+), 70 deletions(-)

diff --git a/install/ui/ipa.js b/install/ui/ipa.js
index 
c6d39478a35b9ab8d19065572c9b469a84722d06..1ebf1acc4293fd83ff5971541b58560801922d32
 100644
--- a/install/ui/ipa.js
+++ b/install/ui/ipa.js
@@ -167,9 +167,47 @@ var IPA = function() {
 };
 
 that.register = function(name, factory) {
+that.remove_entity(name);
 that.entity_factories[name] = factory;
 };
 
+that.create_entity = function(name) {
+var factory = that.entity_factories[name];
+if (!factory) return null;
+
+try {
+var builder = that.entity_builder();
+
+builder.entity({
+factory: factory,
+name: name
+});
+
+var entity = builder.build();
+
+entity.init({
+builder: builder
+});
+
+return entity;
+
+} catch (e) {
+if (e.expected) {
+/*expected exceptions thrown by builder just mean that
+  entities are not to be registered. */
+return null;
+}
+
+if (e.message) {
+alert(e.message);
+} else {
+alert(e);
+}
+
+return null;
+}
+};
+
 that.get_entities = function() {
 return that.entities.values;
 };
@@ -177,39 +215,8 @@ var IPA = function() {
 that.get_entity = function(name) {
 var entity = that.entities.get(name);
 if (!entity) {
-var factory = that.entity_factories[name];
-if (!factory) {
-return null;
-}
-
-try {
-var builder = that.entity_builder();
-
-builder.entity({
-factory: factory,
-name: name
-});
-
-entity = builder.build();
-entity.init({
-builder: builder
-});
-
-that.add_entity(entity);
-
-} catch (e) {
-if (e.expected) {
-/*expected exceptions thrown by builder just mean that
-  entities are not to be registered. */
-return null;
-}
-if (e.message) {
-alert(e.message);
-} else {
-alert(e);
-}
-return null;
-}
+entity = that.create_entity(name);
+if (entity) that.add_entity(entity);
 }
 return entity;
 };
diff --git a/install/ui/test/details_tests.js b/install/ui/test/details_tests.js
index 
c6a55cda9046fa74a8c08f646f6288972f96ae58..80136649b9624c32867e639f6de82ec6f68d30f1
 100644
--- a/install/ui/test/details_tests.js
+++ b/install/ui/test/details_tests.js
@@ -156,30 +156,58 @@ test(Testing details lifecycle: create, load., 
function(){
 return widget;
 }
 
-var entity =   IPA.
-entity_builder().
-entity('user').
-details_facet({sections:[
-{
-name: 'identity',
-label: IPA.messages.details.identity,
-fields:['title','givenname','sn','cn','displayname', 
'initials']
-},
-{
-name: 'contact',
-label:'contact',
-fields:
-[  {factory: test_widget,name:'test'},
-   {factory: IPA.multivalued_text_widget, name:'mail'},
-   {factory: IPA.multivalued_text_widget,
-name:'telephonenumber'},
-   {factory: IPA.multivalued_text_widget, name:'pager'},
-   {factory: IPA.multivalued_text_widget, name:'mobile'},
-   {factory: IPA.multivalued_text_widget,
-name:'facsimiletelephonenumber'}]
-}
-]}).build();
+IPA.register('user', function(spec) {
 
+var that = IPA.entity(spec);
+
+that.init = function(params) {
+that.entity_init(params);
+
+params.builder.details_facet({
+sections: [
+{
+name: 'identity',
+