Example #1
0
 def setup(self):
     """
     Sets up a test database 
     """
     campus1 = Campus(1, 'test campus')
     rest1 = Restaurant(1, 'test r1', 'student centre', 1, time(hour=8),
                        time(hour=17), 750)
     rest2 = Restaurant(2, 'test r2', 'ballymun road', 1, time(hour=9),
                        time(hour=18), 250)
     campus1.save()
     rest1.save()
     rest2.save()
Example #2
0
 def setup(self):
     """
     Sets up a test database
     """
     campus1 = Campus(1, 'test campus')
     campus2 = Campus(2, 'another test campus')
     campus3 = Campus(3, 'yet another test campus')
     rest1 = Restaurant(1, 'test r1', 'student centre', 1, time(hour=8),
                        time(hour=17), 750)
     rest2 = Restaurant(2, 'test r2', 'ballymun road', 1, time(hour=9),
                        time(hour=18), 250)
     rest3 = Restaurant(3, 'test r3', 'in library', 1, time(hour=10),
                        time(hour=17), 300)
     rest4 = Restaurant(4, 'test r4', 'beside entrance', 3, time(hour=10),
                        time(hour=16), 200)
     campus1.save()
     campus2.save()
     campus3.save()
     rest1.save()
     rest2.save()
     rest3.save()
     rest4.save()
Example #3
0
 def part3_setup(self):
     """
     Sets up a test database - for testing part three
     """
     campus1 = Campus(1, 'test campus')
     campus2 = Campus(2, 'another test campus')
     campus3 = Campus(3, 'yet another test campus')
     rest1 = Restaurant(1, 'test r1', 'student centre', 1, time(hour=8),
                        time(hour=16), 750, False, True,
                        time(hour=7, minute=15), time(hour=17, minute=34))
     rest2 = Restaurant(2, 'test r2', 'ballymun road', 1, time(hour=9),
                        time(hour=18), 250, False, True,
                        time(hour=6, minute=12), time(hour=19, minute=42))
     rest3 = Restaurant(3, 'test r3', 'in library', 2, time(hour=10),
                        time(hour=17), 300)
     rest4 = Restaurant(4, 'test r4', 'beside entrance', 3, time(hour=10),
                        time(hour=16), 200, True, False)
     campus1.save()
     campus2.save()
     campus3.save()
     rest1.save()
     rest2.save()
     rest3.save()
     rest4.save()
Example #4
0
 def part2_setup(self):
     """
     Sets up a test database - for testing part two
     """
     campus1 = Campus(1, 'test campus')
     campus2 = Campus(2, 'another test campus')
     rest1 = Restaurant(1, 'test r1', 'student centre', 1, time(hour=8),
                        time(hour=17), 750, False)
     rest2 = Restaurant(2, 'test r2', 'ballymun road', 1, time(hour=9),
                        time(hour=18), 250, True)
     rest3 = Restaurant(3, 'test r3', 'in library', 1, time(hour=10),
                        time(hour=17), 300, False)
     rest4 = Restaurant(4, 'test r4', 'beside entrance', 2, time(hour=10),
                        time(hour=16), 200, True)
     campus1.save()
     campus2.save()
     rest1.save()
     rest2.save()
     rest3.save()
     rest4.save()
Example #5
0
import csv
from datetime import time
from eatatdcu.models import Campus, Restaurant

with open('../data/campus.csv') as ca:
    reader = csv.reader(ca)
    for row in reader:
        campus = Campus(int(row[0]), row[1], row[2])
        campus.save()

with open('../data/restaurant.csv') as re:
    reader = csv.reader(re)
    for row in reader:
        opening = row[4].split(':')
        closing = row[5].split(':')
        we_opening = row[9].split(':')
        we_closing = row[10].split(':')
        restaurant = Restaurant(
            int(row[0]), row[1], row[2], int(row[3]),
            time(hour=int(opening[0]), minute=int(opening[1])),
            time(hour=int(closing[0]), minute=int(closing[1])), int(row[6]),
            int(row[7]), int(row[8]),
            time(hour=int(we_opening[0]), minute=int(we_opening[1])),
            time(hour=int(we_closing[0]), minute=int(we_closing[1])))
        restaurant.save()
Example #6
0
 def part3_setup_weekends(self):
     campus1 = Campus(1, 'test campus')
     campus2 = Campus(2, 'another test campus')
     campus3 = Campus(3, 'yet another test campus')
     rest1 = Restaurant(1, 'test r1', 'student centre', 1, time(hour=8),
                        time(hour=16), 750, 0, 1, 1, time(hour=7,
                                                          minute=15),
                        time(hour=17, minute=34))
     rest2 = Restaurant(2, 'test r2', 'ballymun road', 1, time(hour=9),
                        time(hour=18), 250, 0, 0, 1, time(hour=6,
                                                          minute=12),
                        time(hour=19, minute=42))
     rest3 = Restaurant(3, 'test r3', 'in library', 1, time(hour=10),
                        time(hour=17), 300)
     rest4 = Restaurant(4, 'test r4', 'beside entrance', 3, time(hour=10),
                        time(hour=16), 200)
     campus1.save()
     campus2.save()
     campus3.save()
     rest1.save()
     rest2.save()
     rest3.save()
     rest4.save()
from datetime import time
from eatatdcu.models import Campus, Restaurant

with open('../data/campus.csv') as ca:
    reader = csv.reader(ca)
    for row in reader:
        campus = Campus(int(row[0]), row[1])
        campus.save()

with open('../data/restaurant.csv') as re:
    reader = csv.reader(re)
    for row in reader:
        opening = row[4].split(':')
        closing = row[5].split(':')
        opening_wknd = row[9].split(':')
        closing_wknd = row[10].split(':')
        restaurant = Restaurant(
            int(row[0]),
            row[1],
            row[2],
            int(row[3]),
            time(hour=int(opening[0]), minute=int(opening[1])),
            time(hour=int(closing[0]), minute=int(closing[1])),
            int(row[6]),
            row[7],
            row[8],
            time(hour=int(opening_wknd[0]), minute=int(opening_wknd[1])),
            time(hour=int(closing_wknd[0]), minute=int(closing_wknd[1])),
        )
        restaurant.save()