-
Notifications
You must be signed in to change notification settings - Fork 0
Backend Testing Part of Milestone 2 Review
Testing for the backend is managed using a combination of unit tests and integration tests. For every backend endpoint, unit tests and integration tests are implemented to cover success and failure scenarios, including edge cases.
-
Test Placement: All test cases are organized within the
test.py
file, which inherits fromdjango.test.TestCase
. -
Test Execution: Tests can be executed using the command
python manage.py test
.
Unit tests focus on verifying individual components or functions to ensure they work correctly in isolation. They are designed to validate the behavior of specific parts of the code, such as serializers, models, or methods within views, without relying on external dependencies. For instance:
-
News Endpoint Unit Tests:
- A unit test simulates the retrieval of news from external RSS feeds, mocking the
feedparser
library to ensure accurate handling of RSS data. - These tests verify that the backend returns the correct response structure, including fields like
title
,link
,author
, andpublished
.
- A unit test simulates the retrieval of news from external RSS feeds, mocking the
Integration tests validate the interaction between different parts of the application to ensure they function correctly as a cohesive system. These tests cover the end-to-end functionality of features, such as views, serializers, and external services.
-
News Endpoint Integration Tests:
- These tests cover scenarios where valid and invalid feed names are submitted to the API.
- They validate that the API returns the correct status codes (
200
,404
,400
) and appropriate error messages when handling valid, invalid, or missing input parameters.
News Endpoint:
Integration and unit tests for the news_feed
endpoint are implemented to ensure reliable functionality. For example:
- Valid RSS feeds such as "financial times" are processed, and the API response structure is verified.
- Invalid feed names are rejected with appropriate error messages.
- Missing required parameters result in a
400 BAD REQUEST
status.
To facilitate testing and development, a data population strategy using Faker has been outlined. While not implemented yet, the plan includes:
- Defining data requirements for models like
Currency
,Stock
,Tag
,Portfolio
,Post
, andComment
. - Creating a
populate.py
script to handle mock data generation, including foreign key relationships. - Automating data population during Docker container startup via
docker-compose.yml
and migrations.
This strategy will ensure realistic mock data for tests, improving their reliability.
- Lab Report #1,24.09.2024
- Lab Report #2,01.10.2024
- Lab Report #3,08.10.2024
- Lab Report #4,15.10.2024
- Lab Report #5,06.11.2024
- Lab Report #9,10.12.2024
- 1st Meeting, 24.09.2024
- 2nd Meeting, 01.10.2024
- 3rd Meeting, 08.10.2024
- 4th Meeting, 15.10.2024
- 5th Meeting, 06.11.2024
- 8th Meeting, 03.12.2024
- 1st Meeting, 03.10.2024
- 2nd Meeting, 10.10.2024
- 3rd Meeting, 17.10.2024
- 4th Meeting, 19.10.2024
- 5th Meeting, 24.10.2024
- 6th Meeting, 02.11.2024
- 8th Meeting, 15.11.2024
- 9th Meeting, 28.11.2024
- 10th Meeting, 04.12.2024
- 11th Meeting, 12.12.2024
- Halil İbrahim Kasapoğlu
- Rukiye Aslan
- Kamil Deniz Coşkuner
- Mahmut Buğra Mert
- Furkan Şenkal
- Muhammed Erkam Gökcepınar
- Cem Güngör
- Oğuz Pançuk
Orkun Mahir Kılıç
SemanticFlix Archieve
- 1st Meeting,19.02.2024
- 2nd Meeting,21.02.2024
- 3rd Meeting,03.03.2024
- 4th Meeting,07.03.2024
- 5th Meeting,10.03.2024
- 6th Meeting,14.03.2024
- 7th Meeting,21.03.2024
- 8th Meeting,01.04.2024
- 9th Meeting,17.04.2024
- 10th Meeting,18.04.2024
- 11th Meeting,25.04.2024
- 12th Meeting,02.05.2024
- 13th Meeting,09.05.2024
- Halil İbrahim Kasapoğlu (Communicator)
- Rukiye Aslan
- Kamil Deniz Coşkuner
- Mahmut Buğra Mert
- İrem Nur Yıldırım
- Furkan Şenkal
- Muhammed Erkam Gökcepınar
- Osman Yasin Baştuğ
Okay DemirSait Hızlı