Skip to main content

Tickling with tests

Hello everyone, So finally we have been at the end of the project and I really enjoyed each and every part of it. So after unit testing the transform its time to write functional tests and integration tests or we can say the browser tests for our add-on.

I have written the functional tests to ensure that the new add-on is imported and all the profiles are installed and the editor is using our new transform and not the old transform. So for that we have already implemented the registration of new add-on to replace it with old one and we also have to make tinyMCE uses our new transform.

How to make tinyMCE uses our new transform in place of old transfrom ?
So for understanding that we should have the idea how tinyMCE calls for the transform script. So it uses getToolByName in portal_transform to get the required transform. So tinyMCE search for safe_html in portal_transform and the old transform was named safe_html.

So here we had two ways to proceed :-
1) Either change tinyMCE configuration such that it calls for exp_safe_html instead of safe_html
2) Or we can just rename our transform same as safe_html and not some other name.

We choose the second one because lets assume the case(first one) when user just deregistered our add-on and wants to filter HTML with old transform and now lets assume we have changed the tinyMCE configuration such that it calls for exp_safe_html then it will cause error in that case and the tinyMCE will fail to create new page.

So finally we changed the name of our transform same as old one so that tinyMCE sense it like a normal thing and no change. :P

After that I tried to add my new add-on to new plone instance and tried to install that add-on in my plone site and it worked!!

Yayayay!!! So things going good and then also I tried to import the new add-on from the portal_transform and checked the terminal and it shows that all the required things are importing and then also tried to create a new page and the filtering is working perfectly.

Here is the screen shot of terminal

Its always great to get a good feedback from mentor :P

Hope you like it.

Cheers,

Comments

Popular posts from this blog

Summarizing Summer

It was a great pleasure to work with great coders/developers at Plone Foundation and learning a lot from them during the course of the program. This blog is about summarizing the whole work I have done during this summer under Google summer of code 2016 under Plone Foundation. So my project mainly focuses on improving forms in plone for dexterity. We already have forms in plone for archetype. So there is a project named collective.easyform which basically provide forms for Plone as dexterity contenttype. The main focus of the project was to improve that code base. Make this stable for plone 5.0 and above. Make all the test cases passing for the code base. Try to cover tests as much as possible code base. Also implement functionalities for fields/actions of the forms in correct place. Make the plone more user friendly. Finally for users who want to migrate their already present forms in Plone Form Gen (PFG) which is archetype to easyforms which are dexterity based forms Plone. This w

Testing the transform

Hello everyone, now the transform for filtering html is ready and the main task is to test the transform. For that purpose I have set up the whole test environment for my add-on using testing.py for unit tests and robot tests. After setting up the environment, now its time to first write unit test for transform that we have just created to check if they are all passing and the transform is working properly or not. For creating unit test I first created test class and in that class I just call the convert function that we have created in the transform and give the input as a data stream and pass it to convert function and then get the output as required. After writing few simple test cases like 30-35 then just ran these test cases and they ran successfully. Test cases ran successfully locally :- Travis is also happy ;) Yayayay!!! Finally test cases were passing so its like a milestone for the project and its completed. The PR got merged and things working good as expect

Introduction to Code Base for easyform

So its been the end of community bonding period and I have been looking into the code base for which I will be working for this summer's project. Collective.easyform , A project for Plone which helps in create forms for plone using dexterity content type. So the project mainly focuses on Improving this add-on to work for properly for Plone5. Current Status of collective easyforms :- Wooh!! It's breaking and failing at lot of the parts. So right now the project is failing for tests and one of the main task of the project is the improve tests to make them work for project. Improving tests help us in tracking the future changes of the project so that we can see if new things/features are working properly in the code. Work done till now :- So till now I have done the setup for the project and did one feature correction, the basic mailer_template which is the default one is not able to render properly and it was showing error , so to make it fix everytime, we have to co