Haven completed the very insightful and fun-filled community bonding period, the most important phase of GSoC 2018, the Coding Phase begun on the 14th of May 2018. This is my first report blog for the coding phase. For the rest of the summer, I shall post report blogs at the end of every week that will mention that weeks activity and what has actually changed on the project/repository am working on. These blogs will essentially be like change logs.
Project Name : Infrastructure Automation – Systers Portal
Repository : Systers Portal Repository -GitHub
Task(s) : Move meetup tests from automated-testing repo to portal repository (main task)
Issue : #383
Status : Completed
The portal repository has some automated tests that were written in Java using mainly Junit + Selenium. It started as a 2014 GSoC project to automated testing on all systers repositories continued till GSoC 2017 where Naman Rajput from IIT extended the project. However the tests for each project is isolated in an extra repository different from the projects repository itself, running these test required “third party tools” as the projects are written in diverse languages and platforms but the centralized automated tests are written in Java and it expects each repo that needs to be tested to be running before it’s this means the test cannot start/stop (running) of the project as required during testing. My task for the entire GSoC is about decentralizing these tests at least for the portal repository. This means I have to move and rewrite (in python) all tests in the automated testing repository (written in Java) to the portal repository. Coding week 1 particularly comprised of moving tests for a single Django app/module, meetup. The tests were moved from here to here.
What has changed
+8 new selenium automated tests have been introduced into the portal repository for the meetup module, please watch this 6 minutes video for details.
With computers, we are only limited by how much we know as we have endless possibilities. Due to such limitations fueled by my lack of knowledge in particular areas and the absence of comprehensive aid challenges where bound.
The use of pytest :
Django has it’s own testing classes and framework the base of which is the TestCase so in Django default guidelines are applied in the writing of tests, however, I wanted to use the pytest testing framework which has evidently been proven more robust and faster challenges came at the level of:
- Pytest uses fixtures which prevent us from using classes when they are not necessary but then the Django test runner does not pick up configurations from the conftest.py configuration file this means more work like writing a new test runner or use two separate tests runners. Pytest test runner for running the selenium tests and Django test runner for the rests of the tests. Also, a limitation of pytest as of writing is that the conftest.py configurations cannot be used globally it must be placed in a single test directory. For Django, this means I would have to create several copies of the file for each app which would have led to the violation of DRY.
- Due to 1 above, I had to employ classes to enforce DRY for all tests files. The use of classes is not motivated in pytest.
- Codacy forced me to remove pythons legitimate assert statements from test to helper classes from TestCase this removed every iota of pytest from my test and reduced them to nothing but standard Django tests.
- Finally, I haven’t extensively worked with selenium before hence am doing a lot of code reading, general reading and having first-time issues which waste a significant amount of time not leaving out all the time I spent trying to find a workaround for challenge one above.
I leave you with this needless piece of code! See you next week!
self.browser.get('%s%s' % (self.live_server_url, '/thanks_for_reading'))
self.assertTrue('Come Back Next Time' in self.browser.title)