Search code examples
djangogithubpinax

What does the test directories implies in a source code on github?


When you go through some source code in github like source codes for pinax-notification, elasticsearch-dsl, and many more, you normally see a folder called 'Test'. What is the function of this folder? Is it an example of how to use the source code and its functionality in your own code or what?

For example, I saw a 'test' folder in pinax-notification repository does this give an example on how to use this in my code? Also if not, please someone share an example with me on how to use pinax-notification to send email notification and display a notification to users through django template?


Solution

  • The folder you refer to contains tests which (hopefully) prove that all parts of the code work as intended. All Pinax applications use a folder named "tests". Here is the pinax-notifications tests folder contents:

    pinax-notifications tests folder

    Tests are useful several ways. Besides proving code intent, they can also show how the application is used. In the case of pinax-notifications, the tests ensure various model methods and views operate as expected. However, these tests do not show how to achieve your goal.

    Pinax-notifications use is illuminated in the Cloudspotting2 demonstration project. In particular please reference receivers.py invocations of "send()" for sending notifications. As for displaying notification to users through Django templates, please see any of the three notifications templates in Cloudspotting2 such as invite_accepted/full.txt.

    Finally the pinax-notifications documentation contains useful guidance about usage here https://github.com/pinax/pinax-notifications#usage.