def __loadClientsFromFile(self): file = open(self.__fileName, "r") oneLine = file.readline().strip() while oneLine != "": attributes = oneLine.split(" ; ") client = Client(attributes[0], attributes[1]) client._Client__addClient(self.__list) oneLine = file.readline().strip() file.close()
def testAddClient(self): ''' Function that checks whether a client is added correctly to the list or not input:- preconditions:- output:- postcondition: If a client is not added correctly, an error will appear. ''' mylist = [] client = Client(3, "Luna Lovegood") client._Client__addClient(mylist) self.assertEqual(mylist, [client])
def testRemoveClient(self): ''' Function that checks whether a client is correctly removed from the list of clients or not input:- preconditions:- output:- postconditions: If the client is not removed correctly from the list, or the list is already empty, or the client isn't in the list, an error will appear. ''' mylist = [] client = Client(4, "George Weasley") client._Client__addClient(mylist) client._Client__removeClient(mylist) self.assertEqual(mylist, [])
def testUpdateClient(self): ''' Function that checks whether a client is correctly updated or not. input:- preconditions:- output:- postconditions: If the client is not correctly updated, an error will appear. ''' mylist = [] client = Client(5, "Cho Chang") client._Client__addClient(mylist) client._Client__updateClient(5, 3, "Hermione Granger", mylist) self.assertEqual(client._Client__getId(), 3) self.assertEqual(client._Client__getName(), "Hermione Granger")