Ejemplo n.º 1
0
 def test_uncheckBook(self):
     patron = 'p1000'
     id = 'b1009'
     title = 'Hunger Games 6'
     Library().addBook(id, title)
     Library().borrow(patron, id)
     Library().uncheck(patron, id)
Ejemplo n.º 2
0
 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))
Ejemplo n.º 3
0
 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)
Ejemplo n.º 4
0
 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'))
Ejemplo n.º 5
0
 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))
Ejemplo n.º 6
0
 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
Ejemplo n.º 7
0
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")
Ejemplo n.º 8
0
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"
        )
Ejemplo n.º 9
0
 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')
Ejemplo n.º 10
0
 def test_staffCreatePatron(self):
     # runBG()
     staff = sClient()
     staff.send('staff,s1000')
     staff.send('crpatron,p1001,jack')
     self.assertTrue(Library().patronExists("p1001"))
     staff.send('exit')
Ejemplo n.º 11
0
 def test_adminCreateStaff(self):
     # runBG()
     admin = sClient()
     admin.send('admin')
     admin.send('crstaff,S1002')
     self.assertTrue(Library().staffExists("S1002"))
     admin.send('exit')
Ejemplo n.º 12
0
 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
Ejemplo n.º 13
0
 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'))
Ejemplo n.º 14
0
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!"
        )
Ejemplo n.º 15
0
    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()
Ejemplo n.º 16
0
 def test_eventCreation(self):
     eventID = 'e1000'
     Library().createEvent(eventID)
     self.assertTrue(Library().eventExists(eventID))
Ejemplo n.º 17
0
 def test_eventJoinNoBorrow(self):
     eventId = 'e1001'
     pid = 'p1000'
     Library().regEvent(eventId, pid, bid=None)
     self.assertTrue(Library().getPatron(pid).inE(eventId))
Ejemplo n.º 18
0
def step_impl(context):
    while Library().checked('b1000'):
        None  # Wait till it is removed
Ejemplo n.º 19
0
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
Ejemplo n.º 20
0
 def test_staffCreation(self):
     x = Library()
     id = 'S1001'
     x.createStaff(id)
     self.assertTrue(x.staffExists(id))
Ejemplo n.º 21
0
 def test_libraryAddingBook(self):
     id = 'b1008'
     title = 'Hunger Games 8'
     Library().addBook(id, title)
     self.assertTrue(Library().bookExists('b1008'))
Ejemplo n.º 22
0
 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)
Ejemplo n.º 23
0
 def test_staffCreateLab(self):
     # runBG()
     staff = sClient()
     staff.send('staff,s1000')
     staff.send('clab,l1010')
     self.assertTrue(Library().labExists('l1010'))
Ejemplo n.º 24
0
def step_impl(context):
    if Library().bookExists('b0404'):
        raise SystemError(
            "(Entering invalid id for staff login) Testing invalidity with existing staff ID"
        )
Ejemplo n.º 25
0
 def test_labCreation(self):
     lab = 'l1000'
     openTime = 10  #Seconds
     Library().createLab(lab, openTime)
     self.assertTrue(Library().labExists(lab))
Ejemplo n.º 26
0
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"
        )
Ejemplo n.º 27
0
 def test_singleIns(self):
     x = Library()
     y = Library()
     self.assertTrue(x == y)
Ejemplo n.º 28
0
 def test_staffEventCreation(self):
     # runBG()
     staff = sClient()
     staff.send('staff,s1000')
     staff.send('cevent,e1010')
     self.assertTrue(Library().eventExists('e1010'))
Ejemplo n.º 29
0
 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))
Ejemplo n.º 30
0
 def test_bookBorrow(self):
     # runBG()
     s = sClient()
     s.send('patron,p1000')
     s.send("borrow,b1000")
     self.assertTrue(Library().getPatron('p1000').bExists('b1000'))