class TestReservations(unittest.TestCase):
    def setUp(self):
        unittest.TestCase.setUp(self)
        from repo import FileRepo
        from domain import ReservationValidator
        self.RoomsRepo = FileRepo("rooms.txt", Room.readRoom, Room.writeRoom)
        self.ResRepo = FileRepo("test.txt",Reservation.readReservation,Reservation.writeReservation)
        self.srv = Service(self.RoomsRepo,self.ResRepo,ReservationValidator)
        self.y = datetime.date.today().year

    def tearDown(self):
        unittest.TestCase.tearDown(self)

    def testCheckAvailableRoom(self):
        self.assertTrue(self.srv.checkAvailableRoom(3,datetime.date(self.y,3,3),datetime.date(self.y,4,4)))
        self.assertFalse(self.srv.checkAvailableRoom(1,datetime.date(self.y,1,2),datetime.date(self.y,1,12)))

    def testCreateReservation(self):
        self.srv.createReservation('Test',4,4,datetime.date(self.y,11,11),datetime.date(self.y,11,12))
        reservations = self.srv.getReservations()
        lastRes = reservations[-1]
        self.assertEqual(lastRes.getFam(),'Test')
        self.srv.deleteRsv(lastRes.getID())

    def testDeleteReservation(self):
        firstRes = self.srv.getReservations()[0]
        ID = firstRes.getID()
        self.srv.deleteRsv(ID)
        self.assertTrue(firstRes not in self.srv.getReservations())
        self.ResRepo.add(firstRes)
 def setUp(self):
     unittest.TestCase.setUp(self)
     from repo import FileRepo
     from domain import ReservationValidator
     self.RoomsRepo = FileRepo("rooms.txt", Room.readRoom, Room.writeRoom)
     self.ResRepo = FileRepo("test.txt",Reservation.readReservation,Reservation.writeReservation)
     self.srv = Service(self.RoomsRepo,self.ResRepo,ReservationValidator)
     self.y = datetime.date.today().year
 def testGetNearAdr(self):
     repo = FileRepo("test.txt", Address.fileRead, Address.fileWrite)
     a1 = Address(1, 'adr1', 1, 4, 0)
     a2 = Address(2, 'adr2', 4, 5, 0)
     repo.add(a1)
     repo.add(a2)
     srv = Service(repo)
     fAdr = srv.getNearAdr(0, 0, 10)
     self.assertEqual(len(fAdr), 2)
     self.assertEqual(fAdr[0][0], a1)
     self.assertEqual(fAdr[1][0], a2)
 def testAddRepo(self):
     repo = FileRepo("test.txt", Assignment.fileRead, Assignment.fileWrite)
     a1 = Assignment(1, 'Ass1', 'Y.O.L.O.')
     a2 = Assignment(2, 'Ass2', 'MarianaMaria')
     repo.add(a1)
     self.assertEqual(repo.getAll(), [a1])
     repo.add(a2)
     self.assertEqual(repo.getAll(), [a1, a2])
Esempio n. 5
0
 def testGetBusesOfRoute(self):
     BusRepo = FileRepo("testBuses.txt", Bus.fileRead, Bus.fileWrite)
     b1 = Bus(1, 1, 'b1', 2)
     BusRepo.addObj(b1)
     RouteRepo = FileRepo("testRoutes.txt", Route.fileRead, Route.fileWrite)
     r1 = Route(1, 12)
     RouteRepo.addObj(r1)
     srv = BusSrv(BusRepo, RouteRepo)
     buses = srv.getBusesOfRoute(1)
     self.assertEqual(buses, [b1])
Esempio n. 6
0
 def testIncreaseUsage(self):
     BusRepo = FileRepo("testBuses.txt", Bus.fileRead, Bus.fileWrite)
     b1 = Bus(1, 1, 'b1', 2)
     BusRepo.addObj(b1)
     RouteRepo = FileRepo("testRoutes.txt", Route.fileRead, Route.fileWrite)
     srv = BusSrv(BusRepo, RouteRepo)
     srv.increaseUsage(1,1)
     self.assertEqual(b1.getTimesUsedRoute(),3)
     BusRepo.clearRepo()
 def testAdd(self):
     repo = FileRepo("test.txt", Assignment.fileRead, Assignment.fileWrite)
     srv = Service(repo)
     srv.addAssignment(1, 'Ass1', 'Y.O.L.O.')
     self.assertEqual(len(repo.getAll()), 1)
     srv.addAssignment(2, 'Ass2', 'MarianaMaria')
     self.assertEqual(len(repo.getAll()), 2)
     repo.clearRepo()
Esempio n. 8
0
 def testAddStud(self):
     repo = FileRepo("testStuds.txt", Student.fileRead, Student.fileWrite)
     srv = ExamSrv(repo)
     srv.addStud(12, 'Stud1 Stud1', 10, 9)
     self.assertEqual(len(repo.getAll()), 1)
     srv.addStud(13, 'Stud2 Stud2', 10, 9)
     self.assertEqual(len(repo.getAll()), 2)
     repo.clearRepo()
Esempio n. 9
0
    def testMostUsedBuses(self):
        BusRepo = FileRepo("testBuses.txt", Bus.fileRead, Bus.fileWrite)
        b1 = Bus(1, 1, 'b1', 2)
        b2 = Bus(2, 1, 'b1', 3)
        BusRepo.addObj(b1)
        BusRepo.addObj(b2)
        RouteRepo = FileRepo("testRoutes.txt", Route.fileRead, Route.fileWrite)
        r1 = Route(1, 12)
        RouteRepo.addObj(r1)
        srv = BusSrv(BusRepo, RouteRepo)
        buses = srv.MostUsedBuses()
        self.assertEqual(buses,[b2,b1])


    #self.assertEqual(2 elements)
    #with self.assertRaises(Exception): something that raises an exception
Esempio n. 10
0
 def testSimulateNewDay(self):
     repo = FileRepo("test.txt", Person.fileRead, Person.fileWrite)
     srv = Service(repo)
     p1 = Person(1, 'nonvaccinated', 'ill')
     p2 = Person(2, 'nonvaccinated', 'healthy')
     p3 = Person(3, 'nonvaccinated', 'healthy')
     repo.add(p1)
     repo.add(p2)
     repo.add(p3)
     srv.simulateNewDay()
     self.assertEqual(p2.getStatus(), 'ill')
     srv.simulateNewDay()
     self.assertEqual(p3.getStatus(), 'ill')
     with self.assertRaises(AssertionError):
         assert p1.getStatus() == 'healthy'
     repo.clearRepo()
from ui import ConsoleMenu
from srv import SongService
from repo import FileRepo
from entities import Song

if __name__ == '__main__':
    repository = FileRepo("songs.txt", Song.fileRead, Song.fileWrite)
    appUI = ConsoleMenu(SongService(repository))
    appUI.run()
Esempio n. 12
0
from UI import ConsoleMenu
from controller import Service
from repo import FileRepo
from entities import Assignment

if __name__ == '__main__':
    repo = FileRepo("assignments.txt", Assignment.fileRead,
                    Assignment.fileWrite)
    srv = Service(repo)
    appUI = ConsoleMenu(srv)
    appUI.run()
Esempio n. 13
0
 def testRepoAddStud(self):
     repo = FileRepo("testStuds.txt", Student.fileRead, Student.fileWrite)
     s1 = Student(1, "stud stud", 9, 9)
     repo.add(s1)
     self.assertEqual(repo.getAll(), [s1])
     repo.clearRepo()
Esempio n. 14
0
from UI import Console
from controller import Service
from repo import FileRepo

if __name__ == '__main__':
    wordsRepo = FileRepo('input.txt')
    srv = Service(wordsRepo)
    app_UI = Console(srv)
    app_UI.run()
'''
Demo
word = 'abracad'
l = list(word[1:-1])
for lit in l:
    print(lit)
'''
Esempio n. 15
0
from UI import ConsoleMenu
from controller import BusSrv
from repo import FileRepo
from entities import Bus,Route

if __name__ == '__main__':
    BusRepo = FileRepo('buses.txt',Bus.fileRead,Bus.fileWrite)
    RouteRepo = FileRepo('routes.txt',Route.fileRead,Route.fileWrite)
    service = BusSrv(BusRepo,RouteRepo)
    appUI = ConsoleMenu(service)
    appUI.run()
from UI import UI
from controller import Service
from repo import FileRepo
from domain import Question

if __name__ == '__main__':
    questionsRepo = FileRepo("questionsMaster.txt", Question.readQ,
                             Question.writeQ)
    srv = Service(questionsRepo)
    app_UI = UI(srv)
    app_UI.run()
 def testEuclidDist(self):
     repo = FileRepo("test.txt", Address.fileRead, Address.fileWrite)
     srv = Service(repo)
     d = srv.EuclidDist(6, 6, 2, 3)
     self.assertEqual(d, 5)
Esempio n. 18
0
from UI import ConsoleMenu
from controller import Service
from repo import FileRepo
from entities import Person

if __name__ == '__main__':
    repo = FileRepo("persons.txt", Person.fileRead, Person.fileWrite)
    srv = Service(repo)
    appUI = ConsoleMenu(srv)
    appUI.run()
Esempio n. 19
0
from UI import UI
from service import Service
from repo import FileRepo
from domain import Room, Reservation, ReservationValidator

if __name__ == "__main__":
    RoomsRepo = FileRepo("rooms.txt", Room.readRoom, Room.writeRoom)
    ReservationsRepo = FileRepo("reservations.txt",
                                Reservation.readReservation,
                                Reservation.writeReservation)
    srv = Service(RoomsRepo, ReservationsRepo, ReservationValidator)
    app_UI = UI(srv)
    app_UI.run()
Esempio n. 20
0
from UI import ConsoleMenu
from controller import ExamSrv
from repo import FileRepo
from entities import Student

if __name__ == '__main__':
    studRepo = FileRepo("students.txt", Student.fileRead, Student.fileWrite)
    examContr = ExamSrv(studRepo)
    appUI = ConsoleMenu(examContr)
    appUI.run()