Unit Test for App

Hi guys, 

I have seen all the unit tests written in the source code. 
Used to write these under GAE as well but still wondering if you guys have any quick guide to write and run those tests ? 

How could I use db stub ? I am still using the old https://github.com/frappe/frappe-bench, would it matter ?

Thanks a lot!



Note:

 

If you are posting an issue,

 

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/8e4c7b8a-b45c-41a7-95b7-9115f82b6dad%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.
Prepared a quick stub.

https://frappe.io/developers/api/writing-tests

Pls feel free to contribute!

https://github.com/frappe/frappe_io/blob/master/frappe_io/templates/statics/developers/api/writing-tests.md


On 01-Aug-2014, at 10:05 am, Nguyen Do Le Bao <na...@gmail.com> wrote:

Hi guys, 

I have seen all the unit tests written in the source code. 
Used to write these under GAE as well but still wondering if you guys have any quick guide to write and run those tests ? 

How could I use db stub ? I am still using the old https://github.com/frappe/frappe-bench, would it matter ?

Thanks a lot!



Note:

 

If you are posting an issue,

 

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/8e4c7b8a-b45c-41a7-95b7-9115f82b6dad%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.



Note:

 

If you are posting an issue,

 

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/4C5E8DE3-B4DD-4794-960D-3B6CCB85F68A%40gmail.com.

    For more options, visit https://groups.google.com/d/optout.
Sure, will test it out and add on to it if there is anything!

Can I check with you something ? Is there a way to run a test server on a Mac OS X ? 
I am developing using a Mac OS X but testing using a Ubuntu server. 

If we can test on the development environment, that will be much faster then transfer the file to server and run.
Thank you!

On Friday, August 1, 2014 7:22:28 PM UTC+8, rushabh wrote:
Prepared a quick stub.


Pls feel free to contribute!



On 01-Aug-2014, at 10:05 am, Nguyen Do Le Bao <na...@gmail.com> wrote:

Hi guys, 

I have seen all the unit tests written in the source code. 
Used to write these under GAE as well but still wondering if you guys have any quick guide to write and run those tests ? 

How could I use db stub ? I am still using the old https://github.com/frappe/frappe-bench, would it matter ?

Thanks a lot!



Note:

 

If you are posting an issue,

 

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/8e4c7b8a-b45c-41a7-95b7-9115f82b6dad%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.



Note:

 

If you are posting an issue,

 

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/809cd357-130d-468c-88d6-ab81da84d408%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.
frappe --serve will do it!

I develop and test on a MacOS too.


On 03-Aug-2014, at 2:27 pm, Nguyen Do Le Bao <na...@gmail.com> wrote:

Sure, will test it out and add on to it if there is anything!

Can I check with you something ? Is there a way to run a test server on a Mac OS X ? 
I am developing using a Mac OS X but testing using a Ubuntu server. 

If we can test on the development environment, that will be much faster then transfer the file to server and run.
Thank you!

On Friday, August 1, 2014 7:22:28 PM UTC+8, rushabh wrote:
Prepared a quick stub.


Pls feel free to contribute!



On 01-Aug-2014, at 10:05 am, Nguyen Do Le Bao <na...@gmail.com> wrote:

Hi guys, 

I have seen all the unit tests written in the source code. 
Used to write these under GAE as well but still wondering if you guys have any quick guide to write and run those tests ? 

How could I use db stub ? I am still using the old https://github.com/frappe/frappe-bench, would it matter ?

Thanks a lot!



Note:

 

If you are posting an issue,

 

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/8e4c7b8a-b45c-41a7-95b7-9115f82b6dad%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.




Note:

 

If you are posting an issue,

 

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/809cd357-130d-468c-88d6-ab81da84d408%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.



Note:

 

If you are posting an issue,

 

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/A219AED5-9A26-45B3-A5E1-3DC4DC028768%40gmail.com.

    For more options, visit https://groups.google.com/d/optout.
Cool, thanks a lot!

I followed the new bench setup and got it working on Mac. Wasn't able to do it with the previous frappe version, forgot why...
Btw, when you guys wrote the code for frappe APIs, did you have any unittest code for those ?

I am writing custom API code and wanna test it. The problem is more on setup the frappe.local, cos i make use of that quite heavily
If there are already test for the original APIs, I can just take a look and imitate the setup :D. It will be great!!! 

Thank you again!



On Monday, August 4, 2014 1:12:54 PM UTC+8, rushabh wrote:
frappe --serve will do it!

I develop and test on a MacOS too.


On 03-Aug-2014, at 2:27 pm, Nguyen Do Le Bao <na...@gmail.com> wrote:

Sure, will test it out and add on to it if there is anything!

Can I check with you something ? Is there a way to run a test server on a Mac OS X ? 
I am developing using a Mac OS X but testing using a Ubuntu server. 

If we can test on the development environment, that will be much faster then transfer the file to server and run.
Thank you!

On Friday, August 1, 2014 7:22:28 PM UTC+8, rushabh wrote:
Prepared a quick stub.


Pls feel free to contribute!



On 01-Aug-2014, at 10:05 am, Nguyen Do Le Bao <na...@gmail.com> wrote:

Hi guys, 

I have seen all the unit tests written in the source code. 
Used to write these under GAE as well but still wondering if you guys have any quick guide to write and run those tests ? 

How could I use db stub ? I am still using the old https://github.com/frappe/frappe-bench, would it matter ?

Thanks a lot!



Note:

 

If you are posting an issue,

 

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/8e4c7b8a-b45c-41a7-95b7-9115f82b6dad%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.




Note:

 

If you are posting an issue,

 

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/809cd357-130d-468c-88d6-ab81da84d408%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.



Note:

 

If you are posting an issue,

 

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/c9ff1ae7-6540-4c8f-9f01-6f27f3dfe6e0%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.
I do have another question: 
It seems like during these unit test, it does not connect to the test_db ? Cos it cannot recognise the custom field that I have added into the db.
Is there a way to add those in on the fly during setUp

Thanks!


On Tuesday, August 12, 2014 2:59:06 PM UTC+8, Nguyen Do Le Bao wrote:
Cool, thanks a lot!

I followed the new bench setup and got it working on Mac. Wasn't able to do it with the previous frappe version, forgot why...
Btw, when you guys wrote the code for frappe APIs, did you have any unittest code for those ?

I am writing custom API code and wanna test it. The problem is more on setup the frappe.local, cos i make use of that quite heavily
If there are already test for the original APIs, I can just take a look and imitate the setup :D. It will be great!!! 

Thank you again!



On Monday, August 4, 2014 1:12:54 PM UTC+8, rushabh wrote:
frappe --serve will do it!

I develop and test on a MacOS too.


On 03-Aug-2014, at 2:27 pm, Nguyen Do Le Bao <na...@gmail.com> wrote:

Sure, will test it out and add on to it if there is anything!

Can I check with you something ? Is there a way to run a test server on a Mac OS X ? 
I am developing using a Mac OS X but testing using a Ubuntu server. 

If we can test on the development environment, that will be much faster then transfer the file to server and run.
Thank you!

On Friday, August 1, 2014 7:22:28 PM UTC+8, rushabh wrote:
Prepared a quick stub.


Pls feel free to contribute!



On 01-Aug-2014, at 10:05 am, Nguyen Do Le Bao <na...@gmail.com> wrote:

Hi guys, 

I have seen all the unit tests written in the source code. 
Used to write these under GAE as well but still wondering if you guys have any quick guide to write and run those tests ? 

How could I use db stub ? I am still using the old https://github.com/frappe/frappe-bench, would it matter ?

Thanks a lot!



Note:

 

If you are posting an issue,

 

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/8e4c7b8a-b45c-41a7-95b7-9115f82b6dad%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.




Note:

 

If you are posting an issue,

 

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/809cd357-130d-468c-88d6-ab81da84d408%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.



Note:

 

If you are posting an issue,

 

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/581ce5dd-5ddc-43de-87eb-ab2853321dac%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.
Setup custom fields as "fixtures" in hooks

https://github.com/frappe/frappe_io/blob/master/frappe_io/hooks.py#L20

To export:

frappe --export_fixtures

They will be installed / updated automatically (on --latest)




On 12-Aug-2014, at 2:03 pm, Nguyen Do Le Bao <na...@gmail.com> wrote:

I do have another question: 
It seems like during these unit test, it does not connect to the test_db ? Cos it cannot recognise the custom field that I have added into the db.
Is there a way to add those in on the fly during setUp 

Thanks!


On Tuesday, August 12, 2014 2:59:06 PM UTC+8, Nguyen Do Le Bao wrote:
Cool, thanks a lot!

I followed the new bench setup and got it working on Mac. Wasn't able to do it with the previous frappe version, forgot why...
Btw, when you guys wrote the code for frappe APIs, did you have any unittest code for those ?

I am writing custom API code and wanna test it. The problem is more on setup the frappe.local, cos i make use of that quite heavily
If there are already test for the original APIs, I can just take a look and imitate the setup :D. It will be great!!! 

Thank you again!



On Monday, August 4, 2014 1:12:54 PM UTC+8, rushabh wrote:
frappe --serve will do it!

I develop and test on a MacOS too.


On 03-Aug-2014, at 2:27 pm, Nguyen Do Le Bao <na...@gmail.com> wrote:

Sure, will test it out and add on to it if there is anything!

Can I check with you something ? Is there a way to run a test server on a Mac OS X ? 
I am developing using a Mac OS X but testing using a Ubuntu server. 

If we can test on the development environment, that will be much faster then transfer the file to server and run.
Thank you!

On Friday, August 1, 2014 7:22:28 PM UTC+8, rushabh wrote:
Prepared a quick stub.


Pls feel free to contribute!



On 01-Aug-2014, at 10:05 am, Nguyen Do Le Bao <na...@gmail.com> wrote:

Hi guys, 

I have seen all the unit tests written in the source code. 
Used to write these under GAE as well but still wondering if you guys have any quick guide to write and run those tests ? 

How could I use db stub ? I am still using the old https://github.com/frappe/frappe-bench, would it matter ?

Thanks a lot!

-- 
Note:
 
If you are posting an issue,
 
1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
 
End of Note
--- 
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/8e4c7b8a-b45c-41a7-95b7-9115f82b6dad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


-- 
Note:
 
If you are posting an issue,
 
1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
 
End of Note
--- 
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/809cd357-130d-468c-88d6-ab81da84d408%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


-- 
Note:
 
If you are posting an issue,
 
1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
 
End of Note
--- 
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/581ce5dd-5ddc-43de-87eb-ab2853321dac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



Note:

 

If you are posting an issue,

 

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/85FE7DA7-4B16-4A12-A4ED-601C13C86C4E%40gmail.com.

    For more options, visit https://groups.google.com/d/optout.
Yeah, that works but the fixtures include all the data records as well. If there is no records, however, the csv file won't contain the custom field.

I am trying to set up mock data for the test, but it is really a pain cos of all the validation links... In order to add Item, I need to have Supplier -> Supplier Type ...... Is there a way to bypass the validations cos in the end that's not what I wanna test ?

This is the code @@: 
https://gist.github.com/nathando/4589cda7c6f8f91dda13

I actually wanna clear the db after finishing testing ... but still very messy trying to find a better way to test...

Thanks!





On Tuesday, August 12, 2014 5:54:46 PM UTC+8, rushabh wrote:
Setup custom fields as "fixtures" in hooks


To export:

frappe --export_fixtures

They will be installed / updated automatically (on --latest)




On 12-Aug-2014, at 2:03 pm, Nguyen Do Le Bao <na...@gmail.com> wrote:

I do have another question: 
It seems like during these unit test, it does not connect to the test_db ? Cos it cannot recognise the custom field that I have added into the db.
Is there a way to add those in on the fly during setUp 

Thanks!


On Tuesday, August 12, 2014 2:59:06 PM UTC+8, Nguyen Do Le Bao wrote:
Cool, thanks a lot!

I followed the new bench setup and got it working on Mac. Wasn't able to do it with the previous frappe version, forgot why...
Btw, when you guys wrote the code for frappe APIs, did you have any unittest code for those ?

I am writing custom API code and wanna test it. The problem is more on setup the frappe.local, cos i make use of that quite heavily
If there are already test for the original APIs, I can just take a look and imitate the setup :D. It will be great!!! 

Thank you again!



On Monday, August 4, 2014 1:12:54 PM UTC+8, rushabh wrote:
frappe --serve will do it!

I develop and test on a MacOS too.


On 03-Aug-2014, at 2:27 pm, Nguyen Do Le Bao <na...@gmail.com> wrote:

Sure, will test it out and add on to it if there is anything!

Can I check with you something ? Is there a way to run a test server on a Mac OS X ? 
I am developing using a Mac OS X but testing using a Ubuntu server. 

If we can test on the development environment, that will be much faster then transfer the file to server and run.
Thank you!

On Friday, August 1, 2014 7:22:28 PM UTC+8, rushabh wrote:
Prepared a quick stub.


Pls feel free to contribute!



On 01-Aug-2014, at 10:05 am, Nguyen Do Le Bao <na...@gmail.com> wrote:

Hi guys, 

I have seen all the unit tests written in the source code. 
Used to write these under GAE as well but still wondering if you guys have any quick guide to write and run those tests ? 

How could I use db stub ? I am still using the old https://github.com/frappe/frappe-bench, would it matter ?

Thanks a lot!

-- 
Note:
 
If you are posting an issue,
 
1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
 
End of Note
--- 
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/8e4c7b8a-b45c-41a7-95b7-9115f82b6dad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


-- 
Note:
 
If you are posting an issue,
 
1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
 
End of Note
--- 
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/809cd357-130d-468c-88d6-ab81da84d408%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


-- 
Note:
 
If you are posting an issue,
 
1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
 
End of Note
--- 
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/581ce5dd-5ddc-43de-87eb-ab2853321dac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



Note:

 

If you are posting an issue,

 

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/06710966-26c1-47c2-bc03-6135152e4c7b%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.

On 13-Aug-2014, at 3:44 pm, Nguyen Do Le Bao <na...@gmail.com> wrote:

Yeah, that works but the fixtures include all the data records as well. If there is no records, however, the csv file won't contain the custom field.

Should work - can't understand why...


I am trying to set up mock data for the test, but it is really a pain cos of all the validation links... In order to add Item, I need to have Supplier -> Supplier Type ...... Is there a way to bypass the validations cos in the end that's not what I wanna test ?

This is the code @@: 

I actually wanna clear the db after finishing testing ... but still very messy trying to find a better way to test...


What are you trying to test, API or PO (?) :)

API is the wiring and you have to assume it works. 

Whats wrong with this system ?


It automates most of the issues

Also the tests you write should not assume a clean slate - there could be previous balances you have to consider in your test cases...

Thanks!





On Tuesday, August 12, 2014 5:54:46 PM UTC+8, rushabh wrote:
Setup custom fields as "fixtures" in hooks


To export:

frappe --export_fixtures

They will be installed / updated automatically (on --latest)




On 12-Aug-2014, at 2:03 pm, Nguyen Do Le Bao <na...@gmail.com> wrote:

I do have another question: 
It seems like during these unit test, it does not connect to the test_db ? Cos it cannot recognise the custom field that I have added into the db.
Is there a way to add those in on the fly during setUp 

Thanks!


On Tuesday, August 12, 2014 2:59:06 PM UTC+8, Nguyen Do Le Bao wrote:
Cool, thanks a lot!

I followed the new bench setup and got it working on Mac. Wasn't able to do it with the previous frappe version, forgot why...
Btw, when you guys wrote the code for frappe APIs, did you have any unittest code for those ?

I am writing custom API code and wanna test it. The problem is more on setup the frappe.local, cos i make use of that quite heavily
If there are already test for the original APIs, I can just take a look and imitate the setup :D. It will be great!!! 

Thank you again!



On Monday, August 4, 2014 1:12:54 PM UTC+8, rushabh wrote:
frappe --serve will do it!

I develop and test on a MacOS too.


On 03-Aug-2014, at 2:27 pm, Nguyen Do Le Bao <na...@gmail.com> wrote:

Sure, will test it out and add on to it if there is anything!

Can I check with you something ? Is there a way to run a test server on a Mac OS X ? 
I am developing using a Mac OS X but testing using a Ubuntu server. 

If we can test on the development environment, that will be much faster then transfer the file to server and run.
Thank you!

On Friday, August 1, 2014 7:22:28 PM UTC+8, rushabh wrote:
Prepared a quick stub.


Pls feel free to contribute!



On 01-Aug-2014, at 10:05 am, Nguyen Do Le Bao <na...@gmail.com> wrote:

Hi guys, 

I have seen all the unit tests written in the source code. 
Used to write these under GAE as well but still wondering if you guys have any quick guide to write and run those tests ? 

How could I use db stub ? I am still using the old https://github.com/frappe/frappe-bench, would it matter ?

Thanks a lot!

-- 
Note:
 
If you are posting an issue,
 
1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
 
End of Note
--- 
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/8e4c7b8a-b45c-41a7-95b7-9115f82b6dad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


-- 
Note:
 
If you are posting an issue,
 
1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
 
End of Note
--- 
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/809cd357-130d-468c-88d6-ab81da84d408%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


-- 
Note:
 
If you are posting an issue,
 
1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
 
End of Note
--- 
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/581ce5dd-5ddc-43de-87eb-ab2853321dac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.




Note:

 

If you are posting an issue,

 

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/06710966-26c1-47c2-bc03-6135152e4c7b%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.



Note:

 

If you are posting an issue,

 

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/696B8C4A-0F34-4D36-B38D-D5107E2ACBE0%40gmail.com.

    For more options, visit https://groups.google.com/d/optout.
Yeah, I have no doubt that the default test for purchase_order works. 
Just that the ones I am testing is customised APIs written by me (aka the RPC calls in this doc: https://frappe.io/developers/api/rest_api).
So far, setting up all the data necessary for the testing is still quite a pain. 

So i am going with another solution, just use Postman Chrome App  to test the APIs (they do have automation tool)... Will get back to this some other time...

On Wednesday, August 13, 2014 11:50:00 PM UTC+8, rushabh wrote:

On 13-Aug-2014, at 3:44 pm, Nguyen Do Le Bao <na...@gmail.com> wrote:

Yeah, that works but the fixtures include all the data records as well. If there is no records, however, the csv file won't contain the custom field.

Should work - can't understand why...


I am trying to set up mock data for the test, but it is really a pain cos of all the validation links... In order to add Item, I need to have Supplier -> Supplier Type ...... Is there a way to bypass the validations cos in the end that's not what I wanna test ?

This is the code @@: 

I actually wanna clear the db after finishing testing ... but still very messy trying to find a better way to test...


What are you trying to test, API or PO (?) :)

API is the wiring and you have to assume it works. 

Whats wrong with this system ?


It automates most of the issues

Also the tests you write should not assume a clean slate - there could be previous balances you have to consider in your test cases...

Thanks!





On Tuesday, August 12, 2014 5:54:46 PM UTC+8, rushabh wrote:
Setup custom fields as "fixtures" in hooks


To export:

frappe --export_fixtures

They will be installed / updated automatically (on --latest)




On 12-Aug-2014, at 2:03 pm, Nguyen Do Le Bao <na...@gmail.com> wrote:

I do have another question: 
It seems like during these unit test, it does not connect to the test_db ? Cos it cannot recognise the custom field that I have added into the db.
Is there a way to add those in on the fly during setUp 

Thanks!


On Tuesday, August 12, 2014 2:59:06 PM UTC+8, Nguyen Do Le Bao wrote:
Cool, thanks a lot!

I followed the new bench setup and got it working on Mac. Wasn't able to do it with the previous frappe version, forgot why...
Btw, when you guys wrote the code for frappe APIs, did you have any unittest code for those ?

I am writing custom API code and wanna test it. The problem is more on setup the frappe.local, cos i make use of that quite heavily
If there are already test for the original APIs, I can just take a look and imitate the setup :D. It will be great!!! 

Thank you again!



On Monday, August 4, 2014 1:12:54 PM UTC+8, rushabh wrote:
frappe --serve will do it!

I develop and test on a MacOS too.


On 03-Aug-2014, at 2:27 pm, Nguyen Do Le Bao <na...@gmail.com> wrote:

Sure, will test it out and add on to it if there is anything!

Can I check with you something ? Is there a way to run a test server on a Mac OS X ? 
I am developing using a Mac OS X but testing using a Ubuntu server. 

If we can test on the development environment, that will be much faster then transfer the file to server and run.
Thank you!

On Friday, August 1, 2014 7:22:28 PM UTC+8, rushabh wrote:
Prepared a quick stub.


Pls feel free to contribute!



On 01-Aug-2014, at 10:05 am, Nguyen Do Le Bao <na...@gmail.com> wrote:

Hi guys, 

I have seen all the unit tests written in the source code. 
Used to write these under GAE as well but still wondering if you guys have any quick guide to write and run those tests ? 

How could I use db stub ? I am still using the old https://github.com/frappe/frappe-bench, would it matter ?

Thanks a lot!

-- 
Note:
 
If you are posting an issue,
 
1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
 
End of Note
--- 
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/8e4c7b8a-b45c-41a7-95b7-9115f82b6dad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


-- 
Note:
 
If you are posting an issue,
 
1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
 
End of Note
--- 
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/809cd357-130d-468c-88d6-ab81da84d408%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


-- 
Note:
 
If you are posting an issue,
 
1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
 
End of Note
--- 
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/581ce5dd-5ddc-43de-87eb-ab2853321dac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.




Note:

 

If you are posting an issue,

 

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/06710966-26c1-47c2-bc03-6135152e4c7b%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.



Note:

 

If you are posting an issue,

 

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/816149bb-0f7f-4c6a-b0c3-858a98d9323d%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.
A slightly different question: How to export an app and its db ? I can push to a git repo the code but how's about the default data ?

Thanks!! 


On Friday, August 15, 2014 5:01:03 PM UTC+8, Nguyen Do Le Bao wrote:
Yeah, I have no doubt that the default test for purchase_order works. 
Just that the ones I am testing is customised APIs written by me (aka the RPC calls in this doc: https://frappe.io/developers/api/rest_api).
So far, setting up all the data necessary for the testing is still quite a pain. 

So i am going with another solution, just use Postman Chrome App  to test the APIs (they do have automation tool)... Will get back to this some other time...

On Wednesday, August 13, 2014 11:50:00 PM UTC+8, rushabh wrote:

On 13-Aug-2014, at 3:44 pm, Nguyen Do Le Bao <na...@gmail.com> wrote:

Yeah, that works but the fixtures include all the data records as well. If there is no records, however, the csv file won't contain the custom field.

Should work - can't understand why...


I am trying to set up mock data for the test, but it is really a pain cos of all the validation links... In order to add Item, I need to have Supplier -> Supplier Type ...... Is there a way to bypass the validations cos in the end that's not what I wanna test ?

This is the code @@: 

I actually wanna clear the db after finishing testing ... but still very messy trying to find a better way to test...


What are you trying to test, API or PO (?) :)

API is the wiring and you have to assume it works. 

Whats wrong with this system ?


It automates most of the issues

Also the tests you write should not assume a clean slate - there could be previous balances you have to consider in your test cases...

Thanks!





On Tuesday, August 12, 2014 5:54:46 PM UTC+8, rushabh wrote:
Setup custom fields as "fixtures" in hooks


To export:

frappe --export_fixtures

They will be installed / updated automatically (on --latest)




On 12-Aug-2014, at 2:03 pm, Nguyen Do Le Bao <na...@gmail.com> wrote:

I do have another question: 
It seems like during these unit test, it does not connect to the test_db ? Cos it cannot recognise the custom field that I have added into the db.
Is there a way to add those in on the fly during setUp 

Thanks!


On Tuesday, August 12, 2014 2:59:06 PM UTC+8, Nguyen Do Le Bao wrote:
Cool, thanks a lot!

I followed the new bench setup and got it working on Mac. Wasn't able to do it with the previous frappe version, forgot why...
Btw, when you guys wrote the code for frappe APIs, did you have any unittest code for those ?

I am writing custom API code and wanna test it. The problem is more on setup the frappe.local, cos i make use of that quite heavily
If there are already test for the original APIs, I can just take a look and imitate the setup :D. It will be great!!! 

Thank you again!



On Monday, August 4, 2014 1:12:54 PM UTC+8, rushabh wrote:
frappe --serve will do it!

I develop and test on a MacOS too.


On 03-Aug-2014, at 2:27 pm, Nguyen Do Le Bao <na...@gmail.com> wrote:

Sure, will test it out and add on to it if there is anything!

Can I check with you something ? Is there a way to run a test server on a Mac OS X ? 
I am developing using a Mac OS X but testing using a Ubuntu server. 

If we can test on the development environment, that will be much faster then transfer the file to server and run.
Thank you!

On Friday, August 1, 2014 7:22:28 PM UTC+8, rushabh wrote:
Prepared a quick stub.


Pls feel free to contribute!



On 01-Aug-2014, at 10:05 am, Nguyen Do Le Bao <na...@gmail.com> wrote:

Hi guys, 

I have seen all the unit tests written in the source code. 
Used to write these under GAE as well but still wondering if you guys have any quick guide to write and run those tests ? 

How could I use db stub ? I am still using the old https://github.com/frappe/frappe-bench, would it matter ?

Thanks a lot!

-- 
Note:
 
If you are posting an issue,
 
1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
 
End of Note
--- 
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/8e4c7b8a-b45c-41a7-95b7-9115f82b6dad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


-- 
Note:
 
If you are posting an issue,
 
1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
 
End of Note
--- 
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/809cd357-130d-468c-88d6-ab81da84d408%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


-- 
Note:
 
If you are posting an issue,
 
1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
 
End of Note
--- 
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/581ce5dd-5ddc-43de-87eb-ab2853321dac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.




Note:

 

If you are posting an issue,

 

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/06710966-26c1-47c2-bc03-6135152e4c7b%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.



Note:

 

If you are posting an issue,

 

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/03198752-51eb-4327-9926-269b55d8e223%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.


On 12-Sep-2014, at 9:08 am, Nguyen Do Le Bao <na...@gmail.com> wrote:

A slightly different question: How to export an app and its db ? I can push to a git repo the code but how's about the default data ?

Thanks!! 

Add to fixtures in hooks.py as "fixtures = ["DocType1", "DocType2"]

and

frappe --export_fixtures app_name

fixtures will be synced / updated with frappe --latest



On Friday, August 15, 2014 5:01:03 PM UTC+8, Nguyen Do Le Bao wrote:
Yeah, I have no doubt that the default test for purchase_order works. 
Just that the ones I am testing is customised APIs written by me (aka the RPC calls in this doc: https://frappe.io/developers/api/rest_api).
So far, setting up all the data necessary for the testing is still quite a pain. 

So i am going with another solution, just use Postman Chrome App  to test the APIs (they do have automation tool)... Will get back to this some other time...

On Wednesday, August 13, 2014 11:50:00 PM UTC+8, rushabh wrote:

On 13-Aug-2014, at 3:44 pm, Nguyen Do Le Bao <na...@gmail.com> wrote:

Yeah, that works but the fixtures include all the data records as well. If there is no records, however, the csv file won't contain the custom field.

Should work - can't understand why...


I am trying to set up mock data for the test, but it is really a pain cos of all the validation links... In order to add Item, I need to have Supplier -> Supplier Type ...... Is there a way to bypass the validations cos in the end that's not what I wanna test ?

This is the code @@: 

I actually wanna clear the db after finishing testing ... but still very messy trying to find a better way to test...


What are you trying to test, API or PO (?) :)

API is the wiring and you have to assume it works. 

Whats wrong with this system ?


It automates most of the issues

Also the tests you write should not assume a clean slate - there could be previous balances you have to consider in your test cases...

Thanks!





On Tuesday, August 12, 2014 5:54:46 PM UTC+8, rushabh wrote:
Setup custom fields as "fixtures" in hooks


To export:

frappe --export_fixtures

They will be installed / updated automatically (on --latest)




On 12-Aug-2014, at 2:03 pm, Nguyen Do Le Bao <na...@gmail.com> wrote:

I do have another question: 
It seems like during these unit test, it does not connect to the test_db ? Cos it cannot recognise the custom field that I have added into the db.
Is there a way to add those in on the fly during setUp 

Thanks!


On Tuesday, August 12, 2014 2:59:06 PM UTC+8, Nguyen Do Le Bao wrote:
Cool, thanks a lot!

I followed the new bench setup and got it working on Mac. Wasn't able to do it with the previous frappe version, forgot why...
Btw, when you guys wrote the code for frappe APIs, did you have any unittest code for those ?

I am writing custom API code and wanna test it. The problem is more on setup the frappe.local, cos i make use of that quite heavily
If there are already test for the original APIs, I can just take a look and imitate the setup :D. It will be great!!! 

Thank you again!



On Monday, August 4, 2014 1:12:54 PM UTC+8, rushabh wrote:
frappe --serve will do it!

I develop and test on a MacOS too.


On 03-Aug-2014, at 2:27 pm, Nguyen Do Le Bao <na...@gmail.com> wrote:

Sure, will test it out and add on to it if there is anything!

Can I check with you something ? Is there a way to run a test server on a Mac OS X ? 
I am developing using a Mac OS X but testing using a Ubuntu server. 

If we can test on the development environment, that will be much faster then transfer the file to server and run.
Thank you!

On Friday, August 1, 2014 7:22:28 PM UTC+8, rushabh wrote:
Prepared a quick stub.


Pls feel free to contribute!



On 01-Aug-2014, at 10:05 am, Nguyen Do Le Bao <na...@gmail.com> wrote:

Hi guys, 

I have seen all the unit tests written in the source code. 
Used to write these under GAE as well but still wondering if you guys have any quick guide to write and run those tests ? 

How could I use db stub ? I am still using the old https://github.com/frappe/frappe-bench, would it matter ?

Thanks a lot!

-- 
Note:
 
If you are posting an issue,
 
1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
 
End of Note
--- 
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/8e4c7b8a-b45c-41a7-95b7-9115f82b6dad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


-- 
Note:
 
If you are posting an issue,
 
1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
 
End of Note
--- 
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/809cd357-130d-468c-88d6-ab81da84d408%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


-- 
Note:
 
If you are posting an issue,
 
1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
 
End of Note
--- 
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/581ce5dd-5ddc-43de-87eb-ab2853321dac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.




Note:

 

If you are posting an issue,

 

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/06710966-26c1-47c2-bc03-6135152e4c7b%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.




Note:

 

If you are posting an issue,

 

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/03198752-51eb-4327-9926-269b55d8e223%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.



Note:

 

If you are posting an issue,

 

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/6F03A328-84DA-4F35-962F-11A60A7D66C0%40gmail.com.

    For more options, visit https://groups.google.com/d/optout.
Hey sorry for bother you guys on this ... but I still cannot do this: 

Under frappe-bench/sites, I run: 
frappe --export_fixtures app_name

It return the following error:

Traceback (most recent call last):
  File "/Applications/MAMP/htdocs/source_code/MyProject/new-bench/frappe-bench/env/bin/frappe", line 9, in <module>
    load_entry_point('frappe==4.1.0', 'console_scripts', 'frappe')()
  File "/Applications/MAMP/htdocs/source_code/MyProject/new-bench/frappe-bench/apps/frappe/frappe/cli.py", line 53, in main
    return run(fn, parsed_args)
  File "/Applications/MAMP/htdocs/source_code/MyProject/new-bench/frappe-bench/apps/frappe/frappe/cli.py", line 83, in run
    out = globals().get(fn)(**args)
  File "/Applications/MAMP/htdocs/source_code/MyProject/new-bench/frappe-bench/apps/frappe/frappe/cli.py", line 67, in new_fn
    return fn(*args, **new_kwargs)
  File "/Applications/MAMP/htdocs/source_code/MyProject/new-bench/frappe-bench/apps/frappe/frappe/cli.py", line 669, in export_fixtures
    export_fixtures()
  File "/Applications/MAMP/htdocs/source_code/MyProject/new-bench/frappe-bench/apps/frappe/frappe/utils/fixtures.py", line 23, in export_fixtures
    for app in frappe.get_installed_apps():
  File "/Applications/MAMP/htdocs/source_code/MyProject/new-bench/frappe-bench/apps/frappe/frappe/__init__.py", line 416, in get_installed_apps
    installed = json.loads(db.get_global("installed_apps") or "[]")
  File "/Applications/MAMP/htdocs/source_code/MyProject/new-bench/frappe-bench/apps/frappe/frappe/database.py", line 444, in get_global
    return self.get_default(key, user)
  File "/Applications/MAMP/htdocs/source_code/MyProject/new-bench/frappe-bench/apps/frappe/frappe/database.py", line 457, in get_default
    d = frappe.defaults.get_defaults(parent).get(key)
  File "/Applications/MAMP/htdocs/source_code/MyProject/new-bench/frappe-bench/apps/frappe/frappe/defaults.py", line 52, in get_defaults
    userd = get_defaults_for(user)
  File "/Applications/MAMP/htdocs/source_code/MyProject/new-bench/frappe-bench/apps/frappe/frappe/defaults.py", line 140, in get_defaults_for
    defaults = frappe.cache().get_value("__defaults:" + parent)
  File "/Applications/MAMP/htdocs/source_code/MyProject/new-bench/frappe-bench/apps/frappe/frappe/memc.py", line 19, in get_value
    val = self.get(self.n(key))
  File "/Applications/MAMP/htdocs/source_code/MyProject/new-bench/frappe-bench/apps/frappe/frappe/memc.py", line 10, in n
    return (frappe.conf.db_name + ":" + key.replace(" ", "_")).encode('utf-8')
TypeError: unsupported operand type(s) for +: 'NoneType' and 'unicode'

Which i guess that it cannot find the db_name ? I did set the default site config using bench

Exporting fixtures from app doesn't work, but export from the site totally works:
frappe --export_fixtures site_name
Just that in that case I will need to put everything under frappe/hook.py, which certainly is not ideal. 

Thanks a lot! 

On Friday, September 12, 2014 1:29:21 PM UTC+8, rushabh wrote:


On 12-Sep-2014, at 9:08 am, Nguyen Do Le Bao <na...@gmail.com> wrote:

A slightly different question: How to export an app and its db ? I can push to a git repo the code but how's about the default data ?

Thanks!! 

Add to fixtures in hooks.py as "fixtures = ["DocType1", "DocType2"]

and

frappe --export_fixtures app_name

fixtures will be synced / updated with frappe --latest



On Friday, August 15, 2014 5:01:03 PM UTC+8, Nguyen Do Le Bao wrote:
Yeah, I have no doubt that the default test for purchase_order works. 
Just that the ones I am testing is customised APIs written by me (aka the RPC calls in this doc: https://frappe.io/developers/api/rest_api).
So far, setting up all the data necessary for the testing is still quite a pain. 

So i am going with another solution, just use Postman Chrome App  to test the APIs (they do have automation tool)... Will get back to this some other time...

On Wednesday, August 13, 2014 11:50:00 PM UTC+8, rushabh wrote:

On 13-Aug-2014, at 3:44 pm, Nguyen Do Le Bao <na...@gmail.com> wrote:

Yeah, that works but the fixtures include all the data records as well. If there is no records, however, the csv file won't contain the custom field.

Should work - can't understand why...


I am trying to set up mock data for the test, but it is really a pain cos of all the validation links... In order to add Item, I need to have Supplier -> Supplier Type ...... Is there a way to bypass the validations cos in the end that's not what I wanna test ?

This is the code @@: 

I actually wanna clear the db after finishing testing ... but still very messy trying to find a better way to test...


What are you trying to test, API or PO (?) :)

API is the wiring and you have to assume it works. 

Whats wrong with this system ?


It automates most of the issues

Also the tests you write should not assume a clean slate - there could be previous balances you have to consider in your test cases...

Thanks!





On Tuesday, August 12, 2014 5:54:46 PM UTC+8, rushabh wrote:
Setup custom fields as "fixtures" in hooks


To export:

frappe --export_fixtures

They will be installed / updated automatically (on --latest)




On 12-Aug-2014, at 2:03 pm, Nguyen Do Le Bao <na...@gmail.com> wrote:

I do have another question: 
It seems like during these unit test, it does not connect to the test_db ? Cos it cannot recognise the custom field that I have added into the db.
Is there a way to add those in on the fly during setUp 

Thanks!


On Tuesday, August 12, 2014 2:59:06 PM UTC+8, Nguyen Do Le Bao wrote:
Cool, thanks a lot!

I followed the new bench setup and got it working on Mac. Wasn't able to do it with the previous frappe version, forgot why...
Btw, when you guys wrote the code for frappe APIs, did you have any unittest code for those ?

I am writing custom API code and wanna test it. The problem is more on setup the frappe.local, cos i make use of that quite heavily
If there are already test for the original APIs, I can just take a look and imitate the setup :D. It will be great!!! 

Thank you again!



On Monday, August 4, 2014 1:12:54 PM UTC+8, rushabh wrote:
frappe --serve will do it!

I develop and test on a MacOS too.


On 03-Aug-2014, at 2:27 pm, Nguyen Do Le Bao <na...@gmail.com> wrote:

Sure, will test it out and add on to it if there is anything!

Can I check with you something ? Is there a way to run a test server on a Mac OS X ? 
I am developing using a Mac OS X but testing using a Ubuntu server. 

If we can test on the development environment, that will be much faster then transfer the file to server and run.
Thank you!

On Friday, August 1, 2014 7:22:28 PM UTC+8, rushabh wrote:
Prepared a quick stub.


Pls feel free to contribute!



On 01-Aug-2014, at 10:05 am, Nguyen Do Le Bao <na...@gmail.com> wrote:

Hi guys, 

I have seen all the unit tests written in the source code. 
Used to write these under GAE as well but still wondering if you guys have any quick guide to write and run those tests ? 

How could I use db stub ? I am still using the old https://github.com/frappe/frappe-bench, would it matter ?

Thanks a lot!

-- 
Note:
 
If you are posting an issue,
 
1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
 
End of Note
--- 
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/8e4c7b8a-b45c-41a7-95b7-9115f82b6dad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


-- 
Note:
 
If you are posting an issue,
 
1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
 
End of Note
--- 
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/809cd357-130d-468c-88d6-ab81da84d408%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


-- 
Note:
 
If you are posting an issue,
 
1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
 
End of Note
--- 
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/581ce5dd-5ddc-43de-87eb-ab2853321dac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.




Note:

 

If you are posting an issue,

 

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/06710966-26c1-47c2-bc03-6135152e4c7b%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.




Note:

 

If you are posting an issue,

 

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/03198752-51eb-4327-9926-269b55d8e223%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.



Note:

 

If you are posting an issue,

 

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/3df569d1-050d-4e30-9748-c8786e29fd3b%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.

On 15-Sep-2014, at 3:30 pm, Nguyen Do Le Bao <na...@gmail.com> wrote:

Hey sorry for bother you guys on this ... but I still cannot do this: 

Under frappe-bench/sites, I run: 
frappe --export_fixtures app_name

It return the following error:

Traceback (most recent call last):
  File "/Applications/MAMP/htdocs/source_code/MyProject/new-bench/frappe-bench/env/bin/frappe", line 9, in <module>
    load_entry_point('frappe==4.1.0', 'console_scripts', 'frappe')()
  File "/Applications/MAMP/htdocs/source_code/MyProject/new-bench/frappe-bench/apps/frappe/frappe/cli.py", line 53, in main
    return run(fn, parsed_args)
  File "/Applications/MAMP/htdocs/source_code/MyProject/new-bench/frappe-bench/apps/frappe/frappe/cli.py", line 83, in run
    out = globals().get(fn)(**args)
  File "/Applications/MAMP/htdocs/source_code/MyProject/new-bench/frappe-bench/apps/frappe/frappe/cli.py", line 67, in new_fn
    return fn(*args, **new_kwargs)
  File "/Applications/MAMP/htdocs/source_code/MyProject/new-bench/frappe-bench/apps/frappe/frappe/cli.py", line 669, in export_fixtures
    export_fixtures()
  File "/Applications/MAMP/htdocs/source_code/MyProject/new-bench/frappe-bench/apps/frappe/frappe/utils/fixtures.py", line 23, in export_fixtures
    for app in frappe.get_installed_apps():
  File "/Applications/MAMP/htdocs/source_code/MyProject/new-bench/frappe-bench/apps/frappe/frappe/__init__.py", line 416, in get_installed_apps
    installed = json.loads(db.get_global("installed_apps") or "[]")
  File "/Applications/MAMP/htdocs/source_code/MyProject/new-bench/frappe-bench/apps/frappe/frappe/database.py", line 444, in get_global
    return self.get_default(key, user)
  File "/Applications/MAMP/htdocs/source_code/MyProject/new-bench/frappe-bench/apps/frappe/frappe/database.py", line 457, in get_default
    d = frappe.defaults.get_defaults(parent).get(key)
  File "/Applications/MAMP/htdocs/source_code/MyProject/new-bench/frappe-bench/apps/frappe/frappe/defaults.py", line 52, in get_defaults
    userd = get_defaults_for(user)
  File "/Applications/MAMP/htdocs/source_code/MyProject/new-bench/frappe-bench/apps/frappe/frappe/defaults.py", line 140, in get_defaults_for
    defaults = frappe.cache().get_value("__defaults:" + parent)
  File "/Applications/MAMP/htdocs/source_code/MyProject/new-bench/frappe-bench/apps/frappe/frappe/memc.py", line 19, in get_value
    val = self.get(self.n(key))
  File "/Applications/MAMP/htdocs/source_code/MyProject/new-bench/frappe-bench/apps/frappe/frappe/memc.py", line 10, in n
    return (frappe.conf.db_name + ":" + key.replace(" ", "_")).encode('utf-8')
TypeError: unsupported operand type(s) for +: 'NoneType' and 'unicode'

Which i guess that it cannot find the db_name ? I did set the default site config using bench

Exporting fixtures from app doesn't work, but export from the site totally works:
frappe --export_fixtures site_name

Thats the way its supposed to work at the moment!

Just that in that case I will need to put everything under frappe/hook.py, which certainly is not ideal. 

Thanks a lot! 

On Friday, September 12, 2014 1:29:21 PM UTC+8, rushabh wrote:


On 12-Sep-2014, at 9:08 am, Nguyen Do Le Bao <na...@gmail.com> wrote:

A slightly different question: How to export an app and its db ? I can push to a git repo the code but how's about the default data ?

Thanks!! 

Add to fixtures in hooks.py as "fixtures = ["DocType1", "DocType2"]

and

frappe --export_fixtures app_name

fixtures will be synced / updated with frappe --latest



On Friday, August 15, 2014 5:01:03 PM UTC+8, Nguyen Do Le Bao wrote:
Yeah, I have no doubt that the default test for purchase_order works. 
Just that the ones I am testing is customised APIs written by me (aka the RPC calls in this doc: https://frappe.io/developers/api/rest_api).
So far, setting up all the data necessary for the testing is still quite a pain. 

So i am going with another solution, just use Postman Chrome App  to test the APIs (they do have automation tool)... Will get back to this some other time...

On Wednesday, August 13, 2014 11:50:00 PM UTC+8, rushabh wrote:

On 13-Aug-2014, at 3:44 pm, Nguyen Do Le Bao <na...@gmail.com> wrote:

Yeah, that works but the fixtures include all the data records as well. If there is no records, however, the csv file won't contain the custom field.

Should work - can't understand why...


I am trying to set up mock data for the test, but it is really a pain cos of all the validation links... In order to add Item, I need to have Supplier -> Supplier Type ...... Is there a way to bypass the validations cos in the end that's not what I wanna test ?

This is the code @@: 

I actually wanna clear the db after finishing testing ... but still very messy trying to find a better way to test...


What are you trying to test, API or PO (?) :)

API is the wiring and you have to assume it works. 

Whats wrong with this system ?


It automates most of the issues

Also the tests you write should not assume a clean slate - there could be previous balances you have to consider in your test cases...

Thanks!





On Tuesday, August 12, 2014 5:54:46 PM UTC+8, rushabh wrote:
Setup custom fields as "fixtures" in hooks


To export:

frappe --export_fixtures

They will be installed / updated automatically (on --latest)




On 12-Aug-2014, at 2:03 pm, Nguyen Do Le Bao <na...@gmail.com> wrote:

I do have another question: 
It seems like during these unit test, it does not connect to the test_db ? Cos it cannot recognise the custom field that I have added into the db.
Is there a way to add those in on the fly during setUp 

Thanks!


On Tuesday, August 12, 2014 2:59:06 PM UTC+8, Nguyen Do Le Bao wrote:
Cool, thanks a lot!

I followed the new bench setup and got it working on Mac. Wasn't able to do it with the previous frappe version, forgot why...
Btw, when you guys wrote the code for frappe APIs, did you have any unittest code for those ?

I am writing custom API code and wanna test it. The problem is more on setup the frappe.local, cos i make use of that quite heavily
If there are already test for the original APIs, I can just take a look and imitate the setup :D. It will be great!!! 

Thank you again!



On Monday, August 4, 2014 1:12:54 PM UTC+8, rushabh wrote:
frappe --serve will do it!

I develop and test on a MacOS too.


On 03-Aug-2014, at 2:27 pm, Nguyen Do Le Bao <na...@gmail.com> wrote:

Sure, will test it out and add on to it if there is anything!

Can I check with you something ? Is there a way to run a test server on a Mac OS X ? 
I am developing using a Mac OS X but testing using a Ubuntu server. 

If we can test on the development environment, that will be much faster then transfer the file to server and run.
Thank you!

On Friday, August 1, 2014 7:22:28 PM UTC+8, rushabh wrote:
Prepared a quick stub.


Pls feel free to contribute!



On 01-Aug-2014, at 10:05 am, Nguyen Do Le Bao <na...@gmail.com> wrote:

Hi guys, 

I have seen all the unit tests written in the source code. 
Used to write these under GAE as well but still wondering if you guys have any quick guide to write and run those tests ? 

How could I use db stub ? I am still using the old https://github.com/frappe/frappe-bench, would it matter ?

Thanks a lot!

-- 
Note:
 
If you are posting an issue,
 
1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
 
End of Note
--- 
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/8e4c7b8a-b45c-41a7-95b7-9115f82b6dad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


-- 
Note:
 
If you are posting an issue,
 
1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
 
End of Note
--- 
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/809cd357-130d-468c-88d6-ab81da84d408%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


-- 
Note:
 
If you are posting an issue,
 
1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
 
End of Note
--- 
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/581ce5dd-5ddc-43de-87eb-ab2853321dac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.




Note:

 

If you are posting an issue,

 

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/06710966-26c1-47c2-bc03-6135152e4c7b%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.




Note:

 

If you are posting an issue,

 

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/03198752-51eb-4327-9926-269b55d8e223%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.




Note:

 

If you are posting an issue,

 

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/3df569d1-050d-4e30-9748-c8786e29fd3b%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.



Note:

 

If you are posting an issue,

 

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/84DBD911-18FD-43E7-9A11-29DC9CBCCA36%40gmail.com.

    For more options, visit https://groups.google.com/d/optout.