mirror of https://github.com/snachodog/mybuddy.git
Add data import tests
This commit is contained in:
parent
8c64dd8cae
commit
959649f5f7
|
@ -0,0 +1,2 @@
|
|||
first_name,last_name,birth_date
|
||||
Emily,Huerta,2020-01-17
|
|
|
@ -0,0 +1,2 @@
|
|||
child_id,time,wet,solid,color,amount
|
||||
99,2020-02-17 03:54:09,0,1,,5
|
|
|
@ -0,0 +1,76 @@
|
|||
child_id,time,wet,solid,color,amount
|
||||
1,2020-02-17 03:54:09,1,0,,6.2
|
||||
1,2020-02-16 23:59:16,1,0,,0.8
|
||||
1,2020-02-16 23:58:16,1,0,,2.2
|
||||
1,2020-02-16 19:37:16,0,1,green,2.1
|
||||
1,2020-02-16 17:09:52,1,1,brown,1.7
|
||||
1,2020-02-16 14:35:41,1,0,,4.4
|
||||
1,2020-02-16 10:41:01,0,1,green,0.8
|
||||
1,2020-02-16 09:54:01,1,0,,5.9
|
||||
1,2020-02-16 09:05:01,1,0,,0.8
|
||||
1,2020-02-16 07:38:01,1,0,,3.1
|
||||
1,2020-02-16 03:07:01,1,1,brown,5.5
|
||||
1,2020-02-16 02:06:01,0,1,green,5.2
|
||||
1,2020-02-15 22:01:11,1,0,,3.6
|
||||
1,2020-02-15 20:49:21,1,0,,4.5
|
||||
1,2020-02-15 19:42:21,1,1,brown,6.1
|
||||
1,2020-02-15 17:37:21,1,0,,4.1
|
||||
1,2020-02-15 14:32:21,1,0,,0.8
|
||||
1,2020-02-15 10:39:45,1,0,,0.8
|
||||
1,2020-02-15 09:45:45,1,0,,3.4
|
||||
1,2020-02-15 08:49:45,1,0,,4.9
|
||||
1,2020-02-15 07:01:24,1,0,,3.8
|
||||
1,2020-02-15 06:58:24,0,1,green,4.9
|
||||
1,2020-02-15 02:21:58,1,0,,3.3
|
||||
1,2020-02-14 21:10:28,1,0,,2.2
|
||||
1,2020-02-14 20:39:28,1,1,yellow,1.8
|
||||
1,2020-02-14 18:41:28,1,0,,4.4
|
||||
1,2020-02-14 15:29:28,1,0,,1.9
|
||||
1,2020-02-14 13:54:28,1,0,,3.8
|
||||
1,2020-02-14 11:15:31,1,0,,3.3
|
||||
1,2020-02-14 10:40:40,0,1,black,0.8
|
||||
1,2020-02-14 09:39:40,1,0,,4.8
|
||||
1,2020-02-14 06:51:07,1,0,,1.5
|
||||
1,2020-02-14 01:38:46,1,0,,5.6
|
||||
1,2020-02-13 23:58:46,1,0,,1.1
|
||||
1,2020-02-13 21:06:46,1,1,green,3.7
|
||||
1,2020-02-13 19:57:46,1,0,,6.5
|
||||
1,2020-02-13 17:46:25,1,0,,4.4
|
||||
1,2020-02-13 16:31:54,1,0,,0.9
|
||||
1,2020-02-13 15:41:54,1,0,,1.4
|
||||
1,2020-02-13 13:26:40,1,0,,0.9
|
||||
1,2020-02-13 12:26:03,1,0,,5.6
|
||||
1,2020-02-13 09:12:42,0,1,brown,4.3
|
||||
1,2020-02-13 08:57:42,1,0,,1.8
|
||||
1,2020-02-13 03:32:50,1,0,,4.7
|
||||
1,2020-02-13 01:49:50,1,0,,5.5
|
||||
1,2020-02-12 21:46:05,1,0,,5.2
|
||||
1,2020-02-12 21:02:05,1,0,,2.5
|
||||
1,2020-02-12 18:17:05,1,0,,1.4
|
||||
1,2020-02-12 17:20:05,1,0,,1.6
|
||||
1,2020-02-12 14:48:01,1,0,,6.5
|
||||
1,2020-02-12 12:38:01,1,0,,6.2
|
||||
1,2020-02-12 04:59:14,1,0,,2.9
|
||||
1,2020-02-12 04:37:14,0,1,green,1.1
|
||||
1,2020-02-12 02:40:14,1,0,,0.7
|
||||
1,2020-02-11 20:39:04,1,0,,6.9
|
||||
1,2020-02-11 17:33:04,1,0,,5.6
|
||||
1,2020-02-11 15:47:04,1,0,,5.1
|
||||
1,2020-02-11 14:28:10,1,0,,5.9
|
||||
1,2020-02-11 13:57:10,1,0,,3.7
|
||||
1,2020-02-11 11:59:34,1,0,,1.2
|
||||
1,2020-02-11 11:11:34,1,0,,0.8
|
||||
1,2020-02-11 09:51:34,1,1,green,3.8
|
||||
1,2020-02-11 08:30:34,1,0,,2.6
|
||||
1,2020-02-11 06:35:34,1,0,,0.4
|
||||
1,2020-02-10 23:21:07,1,0,,6.4
|
||||
1,2020-02-10 21:57:49,1,0,,6.2
|
||||
1,2020-02-10 18:22:33,1,0,,0.5
|
||||
1,2020-02-10 17:39:33,0,1,green,5.4
|
||||
1,2020-02-10 14:06:19,1,0,,1.1
|
||||
1,2020-02-10 13:14:06,1,0,,2.9
|
||||
1,2020-02-10 10:03:55,1,0,,5.4
|
||||
1,2020-02-10 08:38:55,1,1,black,4.5
|
||||
1,2020-02-10 04:58:15,1,0,,3.5
|
||||
1,2020-02-10 04:14:19,1,0,,2.5
|
||||
1,2020-02-10 03:14:19,1,0,,4.7
|
|
|
@ -0,0 +1,41 @@
|
|||
child_id,start,end,type,method,amount,notes
|
||||
1,2020-02-17 03:04:09,2020-02-17 03:12:09,fortified breast milk,right breast,,
|
||||
1,2020-02-16 23:10:16,2020-02-16 23:24:16,fortified breast milk,bottle,3.4,Determine vote forget you myself. Worry game consumer traditional improve option pattern drop.
|
||||
1,2020-02-16 19:04:16,2020-02-16 19:17:16,fortified breast milk,bottle,6.1,
|
||||
1,2020-02-16 16:43:52,2020-02-16 17:03:52,fortified breast milk,bottle,6,
|
||||
1,2020-02-16 13:22:41,2020-02-16 13:42:41,fortified breast milk,both breasts,,
|
||||
1,2020-02-16 09:21:01,2020-02-16 09:38:01,formula,bottle,1.7,
|
||||
1,2020-02-16 06:53:01,2020-02-16 07:04:01,breast milk,right breast,,
|
||||
1,2020-02-16 02:32:01,2020-02-16 02:43:01,formula,bottle,,
|
||||
1,2020-02-15 20:15:21,2020-02-15 20:34:21,formula,bottle,,
|
||||
1,2020-02-15 16:33:21,2020-02-15 16:48:21,fortified breast milk,both breasts,,
|
||||
1,2020-02-15 13:35:21,2020-02-15 13:43:21,fortified breast milk,both breasts,,Respond church believe million always itself. Win artist forget director education for need. Especially professional this. Food wonder have response. Garden present son off turn face.
|
||||
1,2020-02-15 08:57:45,2020-02-15 09:07:45,formula,bottle,,
|
||||
1,2020-02-15 06:36:24,2020-02-15 06:45:24,breast milk,left breast,,
|
||||
1,2020-02-15 01:22:58,2020-02-15 01:37:58,breast milk,right breast,,
|
||||
1,2020-02-14 19:49:28,2020-02-14 19:57:28,formula,bottle,,
|
||||
1,2020-02-14 17:26:28,2020-02-14 17:42:28,fortified breast milk,both breasts,,Rather evening smile if difficult yes. Such stop federal light card phone light. Term not perhaps would fire himself throughout. Inside between begin role away life appear. Follow heavy exist site seek environmental myself sell.
|
||||
1,2020-02-14 14:34:28,2020-02-14 14:43:28,fortified breast milk,right breast,,Film school though. Soldier generation none mention issue thing avoid nearly. Then learn produce region own enough. Get month easy drive ok attack parent. Technology always wish forward business action along.
|
||||
1,2020-02-14 09:52:40,2020-02-14 10:01:40,fortified breast milk,both breasts,,
|
||||
1,2020-02-14 05:54:07,2020-02-14 06:01:07,breast milk,both breasts,,
|
||||
1,2020-02-14 00:56:46,2020-02-14 01:11:46,formula,bottle,,
|
||||
1,2020-02-13 20:24:46,2020-02-13 20:36:46,formula,bottle,,
|
||||
1,2020-02-13 16:10:54,2020-02-13 16:24:54,formula,bottle,,
|
||||
1,2020-02-13 12:08:03,2020-02-13 12:14:03,breast milk,right breast,,
|
||||
1,2020-02-13 08:24:42,2020-02-13 08:36:42,fortified breast milk,bottle,2.9,Election arm yet stop.
|
||||
1,2020-02-13 02:42:50,2020-02-13 03:01:50,fortified breast milk,right breast,,
|
||||
1,2020-02-12 20:18:05,2020-02-12 20:35:05,fortified breast milk,bottle,1.6,Friend fund base relate data lot. Me television tree almost entire explain. Oil fight church social.
|
||||
1,2020-02-12 17:50:05,2020-02-12 18:10:05,fortified breast milk,left breast,,
|
||||
1,2020-02-12 13:36:01,2020-02-12 13:54:01,formula,bottle,,Art loss product fact run both. Have against painting pay we. Never whom foot from.
|
||||
1,2020-02-12 03:31:14,2020-02-12 03:50:14,formula,bottle,,
|
||||
1,2020-02-11 20:02:04,2020-02-11 20:16:04,breast milk,left breast,,
|
||||
1,2020-02-11 16:43:04,2020-02-11 16:55:04,formula,bottle,,Response own note light. Point total dog fast. Career everything main wall movie a. Clear wall camera of line. See air yourself improve.
|
||||
1,2020-02-11 14:14:10,2020-02-11 14:20:10,fortified breast milk,both breasts,,
|
||||
1,2020-02-11 10:07:34,2020-02-11 10:24:34,formula,bottle,,
|
||||
1,2020-02-11 07:50:34,2020-02-11 07:58:34,fortified breast milk,right breast,,
|
||||
1,2020-02-11 05:25:34,2020-02-11 05:36:34,fortified breast milk,left breast,,
|
||||
1,2020-02-10 21:21:49,2020-02-10 21:32:49,breast milk,right breast,,
|
||||
1,2020-02-10 17:08:33,2020-02-10 17:25:33,fortified breast milk,bottle,1.8,
|
||||
1,2020-02-10 12:02:06,2020-02-10 12:22:06,formula,bottle,,Lawyer establish positive ten local smile. Space tough compare time truth sense his. Source voice morning one build main.
|
||||
1,2020-02-10 09:05:55,2020-02-10 09:17:55,formula,bottle,3.7,Carry hold most customer group task take. Hair usually friend. Experience human popular material tend benefit minute. Store clear when they.
|
||||
1,2020-02-10 03:48:19,2020-02-10 03:56:19,fortified breast milk,bottle,5.3,
|
|
|
@ -0,0 +1,2 @@
|
|||
child_id,note,time
|
||||
1,Night response author resource reduce evening.,2020-02-17 06:37:12
|
|
|
@ -0,0 +1,40 @@
|
|||
child_id,start,end,notes
|
||||
1,2020-02-17 00:14:09,2020-02-17 02:48:09,
|
||||
1,2020-02-16 19:37:16,2020-02-16 22:43:16,
|
||||
1,2020-02-16 17:19:16,2020-02-16 19:00:16,
|
||||
1,2020-02-16 14:42:52,2020-02-16 16:35:52,
|
||||
1,2020-02-16 11:28:41,2020-02-16 13:21:41,
|
||||
1,2020-02-16 07:38:01,2020-02-16 08:55:01,
|
||||
1,2020-02-16 03:12:01,2020-02-16 06:17:01,
|
||||
1,2020-02-15 22:53:01,2020-02-16 01:21:01,Experience charge from woman fight. Court direction watch particular. Society price air difference chance consider find. Include word office story official statement life. Street kid develop enough need necessary.
|
||||
1,2020-02-15 17:37:21,2020-02-15 19:04:21,
|
||||
1,2020-02-15 14:32:21,2020-02-15 16:02:21,
|
||||
1,2020-02-15 11:38:21,2020-02-15 13:10:21,
|
||||
1,2020-02-15 07:51:45,2020-02-15 08:25:45,
|
||||
1,2020-02-15 03:06:24,2020-02-15 05:41:24,
|
||||
1,2020-02-14 21:58:58,2020-02-15 01:02:58,
|
||||
1,2020-02-14 18:41:28,2020-02-14 19:23:28,Chance rate see consider still according. Technology series key recognize. Rise avoid growth weight.
|
||||
1,2020-02-14 15:29:28,2020-02-14 16:57:28,Million tough many debate price. Tend south my home training free actually same. Mr imagine international.
|
||||
1,2020-02-14 12:12:28,2020-02-14 13:51:28,
|
||||
1,2020-02-14 07:41:40,2020-02-14 09:30:40,Mrs politics risk million education reach spring.
|
||||
1,2020-02-14 02:18:07,2020-02-14 05:29:07,
|
||||
1,2020-02-13 21:06:46,2020-02-13 23:40:46,
|
||||
1,2020-02-13 18:05:46,2020-02-13 19:40:46,
|
||||
1,2020-02-13 14:15:54,2020-02-13 15:40:54,
|
||||
1,2020-02-13 09:39:03,2020-02-13 11:38:03,
|
||||
1,2020-02-13 04:00:42,2020-02-13 08:03:42,
|
||||
1,2020-02-12 22:15:50,2020-02-13 01:46:50,
|
||||
1,2020-02-12 18:17:05,2020-02-12 19:35:05,
|
||||
1,2020-02-12 15:23:05,2020-02-12 16:43:05,
|
||||
1,2020-02-12 05:54:01,2020-02-12 11:48:01,Edge fact officer any.
|
||||
1,2020-02-11 21:00:14,2020-02-12 01:58:14,
|
||||
1,2020-02-11 17:33:04,2020-02-11 19:21:04,
|
||||
1,2020-02-11 14:51:04,2020-02-11 15:46:04,
|
||||
1,2020-02-11 12:49:10,2020-02-11 13:20:10,
|
||||
1,2020-02-11 08:30:34,2020-02-11 09:17:34,
|
||||
1,2020-02-11 06:35:34,2020-02-11 07:10:34,
|
||||
1,2020-02-10 23:56:34,2020-02-11 05:00:34,Image last next important. Style oil season talk family television.
|
||||
1,2020-02-10 18:39:49,2020-02-10 20:39:49,
|
||||
1,2020-02-10 14:44:33,2020-02-10 16:31:33,
|
||||
1,2020-02-10 10:25:06,2020-02-10 11:37:06,Other area cover military. Personal art decade guy. Traditional majority time term on life north. Leg drop most message within believe.
|
||||
1,2020-02-10 05:36:55,2020-02-10 07:48:55,
|
|
|
@ -0,0 +1,24 @@
|
|||
child_id,temperature,time
|
||||
1,100.2,2020-02-17 09:31:49
|
||||
1,99.62,2020-02-17 04:11:09
|
||||
1,101.45,2020-02-17 00:14:09
|
||||
1,97.41,2020-02-16 14:42:52
|
||||
1,99.53,2020-02-16 11:28:41
|
||||
1,98.92,2020-02-16 07:38:01
|
||||
1,97.69,2020-02-15 22:53:01
|
||||
1,98.37,2020-02-15 17:37:21
|
||||
1,101.73,2020-02-15 07:51:45
|
||||
1,98.31,2020-02-15 03:06:24
|
||||
1,95.31,2020-02-14 12:12:28
|
||||
1,99.5,2020-02-14 07:41:40
|
||||
1,99.9,2020-02-13 18:05:46
|
||||
1,98.33,2020-02-13 14:15:54
|
||||
1,98.78,2020-02-13 09:39:03
|
||||
1,98.51,2020-02-12 18:17:05
|
||||
1,100.76,2020-02-12 05:54:01
|
||||
1,98.96,2020-02-11 21:00:14
|
||||
1,95.15,2020-02-11 17:33:04
|
||||
1,95.89,2020-02-11 14:51:04
|
||||
1,98.57,2020-02-11 08:30:34
|
||||
1,99.16,2020-02-11 06:35:34
|
||||
1,98.37,2020-02-10 10:25:06
|
|
|
@ -0,0 +1,37 @@
|
|||
child_id,start,end,milestone
|
||||
1,2020-02-17 04:08:09,2020-02-17 04:11:09,Finally laugh cover art example order.
|
||||
1,2020-02-17 00:03:16,2020-02-17 00:14:09,
|
||||
1,2020-02-16 17:14:52,2020-02-16 17:19:16,Parent pick away character sort prove.
|
||||
1,2020-02-16 14:39:41,2020-02-16 14:42:52,Particular enough picture.
|
||||
1,2020-02-16 11:20:01,2020-02-16 11:28:41,
|
||||
1,2020-02-16 03:09:01,2020-02-16 03:12:01,Party price computer inside.
|
||||
1,2020-02-15 22:47:11,2020-02-15 22:53:01,
|
||||
1,2020-02-15 21:43:21,2020-02-15 21:45:11,
|
||||
1,2020-02-15 11:30:45,2020-02-15 11:38:21,
|
||||
1,2020-02-15 07:47:24,2020-02-15 07:51:45,Grow pass plant positive approach.
|
||||
1,2020-02-15 02:55:58,2020-02-15 03:06:24,
|
||||
1,2020-02-14 21:57:28,2020-02-14 21:58:58,
|
||||
1,2020-02-14 12:06:31,2020-02-14 12:12:28,
|
||||
1,2020-02-14 10:51:40,2020-02-14 11:02:31,Seem sing work economy continue yet season.
|
||||
1,2020-02-14 07:35:07,2020-02-14 07:41:40,Air by street style for important.
|
||||
1,2020-02-14 02:13:46,2020-02-14 02:18:07,
|
||||
1,2020-02-13 17:58:25,2020-02-13 18:05:46,Themselves amount really drive final public old.
|
||||
1,2020-02-13 16:44:54,2020-02-13 16:53:25,Discover person somebody law pull as enjoy.
|
||||
1,2020-02-13 14:10:40,2020-02-13 14:15:54,
|
||||
1,2020-02-13 12:38:03,2020-02-13 12:40:40,
|
||||
1,2020-02-13 09:35:42,2020-02-13 09:39:03,Buy capital year.
|
||||
1,2020-02-13 03:49:50,2020-02-13 04:00:42,
|
||||
1,2020-02-12 22:10:05,2020-02-12 22:15:50,
|
||||
1,2020-02-12 15:17:01,2020-02-12 15:23:05,Management rather eye.
|
||||
1,2020-02-12 05:45:14,2020-02-12 05:54:01,
|
||||
1,2020-02-11 20:56:04,2020-02-11 21:00:14,
|
||||
1,2020-02-11 14:43:10,2020-02-11 14:51:04,
|
||||
1,2020-02-11 12:39:34,2020-02-11 12:49:10,
|
||||
1,2020-02-10 23:56:07,2020-02-10 23:56:34,Notice sound condition whether.
|
||||
1,2020-02-10 22:20:49,2020-02-10 22:24:07,
|
||||
1,2020-02-10 18:31:33,2020-02-10 18:39:49,Politics security although history thank.
|
||||
1,2020-02-10 14:42:19,2020-02-10 14:44:33,Difficult where race discover Democrat.
|
||||
1,2020-02-10 13:24:06,2020-02-10 13:26:19,
|
||||
1,2020-02-10 10:21:55,2020-02-10 10:25:06,Hotel kid I computer but entire.
|
||||
1,2020-02-10 05:30:15,2020-02-10 05:36:55,Scene two other ahead.
|
||||
1,2020-02-10 04:32:19,2020-02-10 04:43:15,Reduce any how seat level.
|
|
|
@ -0,0 +1,6 @@
|
|||
child_id,weight,date,notes
|
||||
1,10.45,2020-02-14,
|
||||
1,10.17,2020-02-07,Medical that leader line general marriage plan present. Good garden suggest no. Section than order little share property why. Prepare production imagine commercial seek teach over anything. Reason late consumer.
|
||||
1,10.04,2020-01-31,Drive usually end than forget. Option value either building car minute the. After resource worker response if. Include second property finish. Music event pick give wind.
|
||||
1,9.89,2020-01-24,
|
||||
1,9.68,2020-01-17,
|
|
|
@ -0,0 +1,67 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import datetime
|
||||
import importlib
|
||||
import os
|
||||
import tablib
|
||||
|
||||
from django.core.management import call_command
|
||||
from django.test import TestCase
|
||||
|
||||
from core import admin, models
|
||||
|
||||
|
||||
class ImportTestCase(TestCase):
|
||||
base_path = os.path.dirname(__file__) + '/import/'
|
||||
admin_module = importlib.import_module('core.admin')
|
||||
model_module = importlib.import_module('core.models')
|
||||
|
||||
def setUp(self):
|
||||
call_command('migrate', verbosity=0)
|
||||
# The data to be imported uses 2020-02-10 as a basis and Child ID 1.
|
||||
birth_date = datetime.date(year=2020, month=2, day=10)
|
||||
models.Child.objects.create(
|
||||
first_name='Child', last_name='One', birth_date=birth_date).save()
|
||||
|
||||
def get_dataset(self, model_name):
|
||||
file = open(self.base_path + model_name + '.csv')
|
||||
return tablib.Dataset().load(file.read())
|
||||
|
||||
def import_data(self, model, count):
|
||||
dataset = self.get_dataset(model._meta.model_name)
|
||||
resource_class = getattr(
|
||||
self.admin_module, model.__name__ + 'ImportExportResource')
|
||||
resource = resource_class()
|
||||
result = resource.import_data(dataset, dry_run=False)
|
||||
self.assertFalse(result.has_validation_errors())
|
||||
self.assertFalse(result.has_errors())
|
||||
self.assertEqual(model.objects.count(), count)
|
||||
|
||||
def test_child(self):
|
||||
self.import_data(models.Child, 2)
|
||||
|
||||
def test_diaperchange(self):
|
||||
self.import_data(models.DiaperChange, 75)
|
||||
|
||||
def test_feeding(self):
|
||||
self.import_data(models.Feeding, 40)
|
||||
|
||||
def test_note(self):
|
||||
self.import_data(models.Note, 1)
|
||||
|
||||
def test_sleep(self):
|
||||
self.import_data(models.Sleep, 39)
|
||||
|
||||
def test_temperature(self):
|
||||
self.import_data(models.Temperature, 23)
|
||||
|
||||
def test_tummytime(self):
|
||||
self.import_data(models.TummyTime, 36)
|
||||
|
||||
def test_weight(self):
|
||||
self.import_data(models.Weight, 5)
|
||||
|
||||
def test_invalid_child(self):
|
||||
dataset = self.get_dataset('diaperchange-invalid-child')
|
||||
resource = admin.DiaperChangeImportExportResource()
|
||||
result = resource.import_data(dataset, dry_run=False)
|
||||
self.assertTrue(result.has_validation_errors())
|
Loading…
Reference in New Issue