This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #use of an external API using Python mock objects. | |
| #A mock is a fake object that you construct to look and act like real data. | |
| # Why Mock | |
| """You cannot test live data, | |
| and even if you could, the tests would return unreliable results as the data was updated through use. | |
| Also, you never want your automated tests to connect to an external server, | |
| an error on their side could bring a halt to your development if | |
| releasing your code depends on whether your tests pass.""" | |
| # ===========project/services.py file============= |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from datetime import datetime, timedelta | |
| from healthid.apps.products.models import BatchInfo | |
| start_date = datetime.now() | |
| # Expiring today | |
| expire_today = BatchInfo.objects.filter( | |
| expiry_date__exact=datetime.now()).exclude(quantity_received__exact='0') | |
| expire_today_count = expire_today.count() | |
| # Expiring in the next 7 day |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.db import models | |
| class Category(models.Model): | |
| name = models.CharField(max_length=100) | |
| def __str__(self): | |
| return self.name | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- coding: utf-8 -*- | |
| # from __future__ import unicode_literals | |
| from django.test import TestCase, Client | |
| # Create your tests here. | |
| # test user creation | |
| # from django.test import TestCase | |
NewerOlder