Saturday, October 14, 2017

Django 1.6 tests issue . Tests which are related to GET APIs run when its test class is run, however fails when all the tests are run on whole.

When I run the tests of my django app with the command
python manage.py test <app_name> OR
python manage.py test

all the test cases where I am fetching some data by calling the api, they seem to fail because there is no data in the response in spite of there being in the test data. The structure which I have followed in my test suite is there is a base class of django rest framework's  APITestCase and a set_up method which creates test objects of different models used in the apis and I inherit this class in my app's test_views class for any particular api 
such as

class BaseTest(APITestCase):
      def set_up():
            '''' create the test objects which can be accessed by the main test class . eg self.person1=  Person.objects.create(.......) ''
 
     

class PipelineViewTestCase(BaseTest):
      def setUp(self):
            self.set_up()


So whenever I run the test as 
./manage.py test sales.test_views.PipelineViewTestCase
it works fine, but when I run as
./manage.py test sales or ./manage.py test
all the tests fail.
(sales is the app_name)

How can I ensure that my tests run fine as a whole? 
Please let me know if I am missing anything. Also if there are other options which I can explore. 

Thanks,
Akshay

--
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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c206c82b-0683-4a79-928b-4c21078cda7a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment