From 9ba3e71dc01ea4bc0e0079f4cc7433a60ac313c8 Mon Sep 17 00:00:00 2001 From: Sachin Maharjan Date: Mon, 18 Sep 2017 16:19:07 +0545 Subject: [PATCH] [#1022] mock data for course (connects #1022) (#1023) --- tests/course_mock_data | 240 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 240 insertions(+) create mode 100644 tests/course_mock_data diff --git a/tests/course_mock_data b/tests/course_mock_data new file mode 100644 index 000000000..816dc340f --- /dev/null +++ b/tests/course_mock_data @@ -0,0 +1,240 @@ +var util = require('util') +var fs = require('fs') +var exec = require('child_process').exec; +var program = require('commander'); +var databases = [] +program + .version('0.0.2') + .parse(process.argv); +if (!program.args[0]) return console.log('No CouchDB URL provided. Quiting now.') +var couchUrl = program.args[0] +var nano = require('nano')(couchUrl) + +function start() { + increaseLimits() +} + +// Increase Limits so couchapp push works correctly +function increaseLimits() { + exec('sudo launchctl limit maxfiles 150056 150056', function doneWithLaunchCtl() { + exec('sudo ulimit -n 150056', function doneWithUlimit() { + return createDummyCourses() + }) + }) +} + +var n_courses = 2 ; //Number of Iteration to run for courses +var defaultCourses = []; //Contains only CourseID and MemberList +var defaultCoursestep = []; +var defaultCoursequestion = []; +var defaultResources = []; + +function createDummyCourses() { + var courses = nano.db.use('courses'); + var coursestep = nano.db.use('coursestep'); + var coursequestion = nano.db.use('coursequestion'); + + for(course = 0; course < n_courses; course++){ + course_number = course + 1; + var subjectLevel; + if (course <=3){ + subjectLevel = "Amateur"; + }else if(course>=4 && course<=8){ + subjectLevel = "Mid"; + }else{ + subjectLevel = "Beginner"; + } + defaultCourses.push({ + "CourseTitle": "Course " +course_number, + "Day": "0", + "backgroundColor": "", + "courseLeader": "", + "description": "This is Course " +course_number+" .", + "endDate": "12/12/2017", + "endTime": "17:00", + "foregroundColor": "", + "gradeLevel": "1", + "kind": "Course", + "languageOfInstruction": "English", + "location": "Alberta", + "memberLimit": "20", + "members": [], + "method": "Theory and Practical", + "name": "Course " +course_number, + "startDate": "01/01/2017", + "startTime": "10:00", + "subjectLevel": subjectLevel + }); + } + + //insert into courses + courses.bulk({"docs":defaultCourses}, function(err, res) { + if (err) + return console.log(err); + else { + course_id = []; + console.log(res.length); + for(var i=0;i