def test_uncheckBook(self): patron = 'p1000' id = 'b1009' title = 'Hunger Games 6' Library().addBook(id, title) Library().borrow(patron, id) Library().uncheck(patron, id)
def test_eventJoin(self): eventId = 'e1001' pid = 'p1000' bid = 'b1000' Library().regEvent(eventId, pid, bid=bid) self.assertTrue(Library().getPatron(pid).bExists(bid)) self.assertTrue(Library().getPatron(pid).inE(eventId))
def test_checkOutSystem(self): patron = 'p1000' id = 'b1006' title = 'Hunger Games 6' Library().addBook(id, title) Library().borrow(patron, id) #TODO: must borrow book beforehand Library().checkOut(patron)
def test_event(self): #Event registering (with) borrowing book # runBG() s = sClient() s.send('patron,p1000') s.send('event,e1001,b1000') self.assertTrue(Library().getPatron('p1000').bExists('b1000')) self.assertTrue(Library().getPatron('p1000').inE('e1001'))
def test_cartAutoReturn(self): patron = 'p1000' id = 'b1012' title = 'Hunger Games 6' Library().addBook(id, title) Library().borrow(patron, id) time.sleep(31) self.assertFalse(Library().checked(id))
def test_bookCheckout(self): # runBG() s = sClient() s.send('patron,p1000') s.send("borrow,b1000") s.send("checkout") self.assertTrue(Library().getPatron('p1000').bExists( 'b1000')) #Here we see that patron has the bookk self.assertFalse(Library().bookExists( 'b1000')) #Here we check that the library doesnt have t he book
def step_impl(context): while not Library().getLab('l2020').checkLab(): None # Looping until the lab has been opened if Library().getLab('l2020').isIn('p1000') and Library().getLab( 'l2020').isIn('p1001'): logging.info( "(Two Patron queue to unopned lab) has executed successfully") else: raise SystemError( "(Two Patron queue to unopned lab) Either patrons didn't get in")
def step_impl(context): if not Library().getPatron('p1000').bExists('b2020'): raise SystemError( "(Patron registration of newly created Event with book b2020) Book hasn't been borrowed" ) elif not Library().getPatron('p1000').inE('e2020'): raise SystemError( "(Patron registration of newly created Event with book b2020) Patron hasn't registered in Event e2020" ) else: logging.info( "(Patron registration of newly created Event with book b2020) has executed successfully" )
def test_bookInsertion(self): # runBG() s = sClient() s.send('staff,s1000') s.send('addbook,b1001,Hunger Games') self.assertTrue(Library().bookExists('b1001')) s.send('exit')
def test_staffCreatePatron(self): # runBG() staff = sClient() staff.send('staff,s1000') staff.send('crpatron,p1001,jack') self.assertTrue(Library().patronExists("p1001")) staff.send('exit')
def test_adminCreateStaff(self): # runBG() admin = sClient() admin.send('admin') admin.send('crstaff,S1002') self.assertTrue(Library().staffExists("S1002")) admin.send('exit')
def test_bookReturn(self): # runBG() s = sClient() s.send('patron,p1000') s.send("borrow,b1000") #UPDATE AFTER ADDING CHECKOUT s.send("checkout") self.assertTrue(Library().getPatron('p1000').bExists( 'b1000')) #Here we see that patron has the bookk self.assertFalse(Library().bookExists( 'b1000')) #Here we check that the library doesnt have t he book s.send("return,b1000") self.assertFalse(Library().getPatron('p1000').bExists( 'b1000')) # here we see that patron doesnt have the book self.assertTrue(Library().bookExists( 'b1000')) # here we see that alibrary has gotten the book
def test_patronJoinLab(self): # runBG() staff = sClient() staff.send('staff,s1000') staff.send('clab,l1000') patron = sClient() patron.send('patron,p1000') patron.send( 'lab,l1000' ) #This will cause the code to be waiting to get in (30 seconds) self.assertTrue(Library().getLab('l1000').isIn('p1000'))
def step_impl(context): if Library().patronExists('p2020'): logging.info( "(Staff member creation of a Patron) has executed successfully") else: logging.fatal( "(Staff member creation of a Patron) has failed in Valid path testing!" ) raise SystemError( "(Staff member creation of a Patron) has failed in Valid path testing!" )
def __init__(self): Library() if self._mainSocket is None: #Creating socket using ipv4 and TCP self._mainSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ## This is added for the future upgrade to multithreaded server self._mainSocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) ##Binding the server to be the main reciever of requests self._mainSocket.bind((self._localAdd, self._port)) ## Server socket has been initilized there for we begin looping for requests self._mainSocket.listen() while True: clientSock, clientAdd = self._mainSocket.accept() x = asyncClient(clientSock, clientAdd) self._connected.append(x) x.start()
def test_eventCreation(self): eventID = 'e1000' Library().createEvent(eventID) self.assertTrue(Library().eventExists(eventID))
def test_eventJoinNoBorrow(self): eventId = 'e1001' pid = 'p1000' Library().regEvent(eventId, pid, bid=None) self.assertTrue(Library().getPatron(pid).inE(eventId))
def step_impl(context): while Library().checked('b1000'): None # Wait till it is removed
def step_impl(context): if Library().getPatron('p1000').bExists('b1000'): raise SystemError("(Patron Borrowing a Book) Book has been borrowed") logging.info( "(Patron checkout a book that has been unchecked) has executed successfully" ) #Observable in console or LOG
def test_staffCreation(self): x = Library() id = 'S1001' x.createStaff(id) self.assertTrue(x.staffExists(id))
def test_libraryAddingBook(self): id = 'b1008' title = 'Hunger Games 8' Library().addBook(id, title) self.assertTrue(Library().bookExists('b1008'))
def test_login(self): x = Library() #Provided the information, we check if this information exists in the library # if it exists then we reroute the state of the client accordingly info = ['admin'] self.assertEqual(x.userLogin(info), iD.A_MENU)
def test_staffCreateLab(self): # runBG() staff = sClient() staff.send('staff,s1000') staff.send('clab,l1010') self.assertTrue(Library().labExists('l1010'))
def step_impl(context): if Library().bookExists('b0404'): raise SystemError( "(Entering invalid id for staff login) Testing invalidity with existing staff ID" )
def test_labCreation(self): lab = 'l1000' openTime = 10 #Seconds Library().createLab(lab, openTime) self.assertTrue(Library().labExists(lab))
def step_impl(context): if not Library().bookExists('b1001'): raise SystemError( "(Patron Borrowing a Book) Book does not exists in the Library invalidating the scenario" )
def test_singleIns(self): x = Library() y = Library() self.assertTrue(x == y)
def test_staffEventCreation(self): # runBG() staff = sClient() staff.send('staff,s1000') staff.send('cevent,e1010') self.assertTrue(Library().eventExists('e1010'))
def test_labJoining(self): patron = 'p1000' lab = 'l1000' Library().createLab(lab, 10) self.assertTrue(Library().joinLab(patron, lab)) self.assertTrue(Library().getLab(lab).isIn(patron))
def test_bookBorrow(self): # runBG() s = sClient() s.send('patron,p1000') s.send("borrow,b1000") self.assertTrue(Library().getPatron('p1000').bExists('b1000'))