facing issue on unit test

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

facing issue on unit test

Arulselvam K
Have hosted the code @ "https://github.com/tbone230590/plib"
Here is the problem I have two models Book and IssuedBook, IssuedBook have foreign key relation to Book object.Those models are defined @ "/api/data/models" I have unit tests for testing those models and are available @ "/api/unit_tests/models".
I am able to test Book model successfully. But I have a test for IssuedBook model which is referring Book model is getting failed.
It seems cause of the problem is referring Book object created in BookTestCase that was previously run. But I dont understand that why Book record getting deleted after first testcase execution.
Could you educate me on this to solve the problem?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/cf28d61d-8582-4148-a14a-9349fdfcca8f%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: facing issue on unit test

Vinicius Assef
The database is cleared after each test method.

So, in a new testcase your database is empty.

On Tue, 13 Aug 2019 at 00:34, Arulselvam K <[hidden email]> wrote:
Have hosted the code @ "https://github.com/tbone230590/plib"
Here is the problem I have two models Book and IssuedBook, IssuedBook have foreign key relation to Book object.Those models are defined @ "/api/data/models" I have unit tests for testing those models and are available @ "/api/unit_tests/models".
I am able to test Book model successfully. But I have a test for IssuedBook model which is referring Book model is getting failed.
It seems cause of the problem is referring Book object created in BookTestCase that was previously run. But I dont understand that why Book record getting deleted after first testcase execution.
Could you educate me on this to solve the problem?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/cf28d61d-8582-4148-a14a-9349fdfcca8f%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFmXjSDqk2mahFjnKB-GJOAx6h9kJMGGo1aW29K%3DcOAk6mwP9g%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: facing issue on unit test

Arulselvam K
Thanks!, So for each test , do i need to add same test data? or do we have any other way not to repeat the same test data?

On Tuesday, 13 August 2019 20:32:16 UTC+5:30, Vinicius Assef wrote:
The database is cleared after each test method.

So, in a new testcase your database is empty.

On Tue, 13 Aug 2019 at 00:34, Arulselvam K <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="HoN-7OfiDgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">tbone...@...> wrote:
Have hosted the code @ "<a rel="nofollow" href="https://github.com/tbone230590/plib" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Ftbone230590%2Fplib\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFvVj98lIU4B3_a8R5YaSXvTrHLmg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Ftbone230590%2Fplib\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFvVj98lIU4B3_a8R5YaSXvTrHLmg&#39;;return true;">https://github.com/tbone230590/plib"
Here is the problem I have two models Book and IssuedBook, IssuedBook have foreign key relation to Book object.Those models are defined @ "/api/data/models" I have unit tests for testing those models and are available @ "/api/unit_tests/models".
I am able to test Book model successfully. But I have a test for IssuedBook model which is referring Book model is getting failed.
It seems cause of the problem is referring Book object created in BookTestCase that was previously run. But I dont understand that why Book record getting deleted after first testcase execution.
Could you educate me on this to solve the problem?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="HoN-7OfiDgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">django...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/django-users/cf28d61d-8582-4148-a14a-9349fdfcca8f%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/django-users/cf28d61d-8582-4148-a14a-9349fdfcca8f%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/django-users/cf28d61d-8582-4148-a14a-9349fdfcca8f%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/django-users/cf28d61d-8582-4148-a14a-9349fdfcca8f%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3bd0af6e-7e6d-4115-9c95-f92c4d9ca60d%40googlegroups.com.