Skip to content

Instantly share code, notes, and snippets.

View okellogabrielinnocent's full-sized avatar
🖥️
Work with Ethics

Gabriel Okello okellogabrielinnocent

🖥️
Work with Ethics
View GitHub Profile
#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=============
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
from django.db import models
class Category(models.Model):
name = models.CharField(max_length=100)
def __str__(self):
return self.name
import React, { Component } from 'react';
import { Redirect } from 'react-router-dom';
// import logo from './logo.svg';
import './App.scss';
import FacebookLogin from 'react-facebook-login';
import GoogleLogin from 'react-google-login';
import TwitterLogin from 'react-twitter-auth';
import { PostData } from './views/PostData';
class App extends Component {
# -*- 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