Пример #1
0
    def test_updateClient(self):
        with self.assertRaises(Exception):
            self.clientService.updateClient(Client(555, "Jhon"))

        self.clientService.updateClient(tuple([Client(1, "Jhon")]))
        self.clientService.updateClient(Client(1, "Jhon"))
        c = self.clientService.getClient(1)
        self.assertEqual(c.attrs, {Utils.CLIENT_ID: 1, Utils.CLIENT_NAME: "Jhon"})
Пример #2
0
    def test_addClient(self):
        with self.assertRaises(Exception):
            self.clientService.addClient(Client(1, "Jhon"))

        self.clientService.addClient(tuple([Client(33, "Name")]))
        self.clientService.addClient(Client(55, "Name"))
        c = self.clientService.getClient(55)
        self.assertEqual(c.attrs, {Utils.CLIENT_ID: 55, Utils.CLIENT_NAME: "Name"}, "Error add client")
Пример #3
0
 def test_Client(self):
     c = Client(1, "Name 1")
     self.assertEqual(c.ID, 1, "ID error")
     c.ID = 2
     self.assertEqual(c.ID, 2, "ID setting error")
     self.assertEqual(c.clientNAME, "Name 1", "Name error")
     c.clientNAME = "Name 2"
     self.assertEqual(c.clientNAME, "Name 2", "Name setting error")
     self.assertEqual(c.attrs, {Utils.CLIENT_ID: 2, Utils.CLIENT_NAME: "Name 2"}, "Attrs error")
Пример #4
0
    def test_queryList(self):
        c1 = Client(1, "Jhon")
        c2 = Client(2, "Jhonny")
        l = {1: c1, 2: c2}
        with self.assertRaises(Exception):
            Utils.queryList(l, "asdsdasda")
        self.assertEqual(Utils.queryList(l, "Jhonny"), {1: c2})

        r1 = Rental(1, 1, 1, 10000.0, 20000.0, None)
        r2 = Rental(2, 2, 2, 20000.0, 30000.0, None)
        l2 = {1: r1, 2: r2}
        with self.assertRaises(Exception):
            Utils.queryList(l2, "iwafmieafimfae")
Пример #5
0
    def test_validate(self):
        c1 = Client("asd", "abcd")

        with self.assertRaises(Exception):
            ClientValidator.validate(c1)

        c1 = Client(1, "ab")

        with self.assertRaises(Exception):
            ClientValidator.validate(c1)

        c1 = Client(1, "abcd")

        ClientValidator.validate(c1)
Пример #6
0
 def readClient():
     """
     Reads the data for a new client
     or for updating an existing client
     ValueError will be raised if the ID is not an int
     :return: client attributes as a dictionary
     """
     cID = input("Client ID:")
     cID = int(cID)
     name = input("Client name:")
     return Client(cID, name)
Пример #7
0
    def addClientsMoviesRentals(self):
        for i in range(1, 10):
            self.__clientService.addClient(Client(i, "Name" + str(i)))
            self.__movieService.addMovie(
                Movie(i, "Title" + str(i), "Desc" + str(i), "Genre" + str(i)))

        for i in range(1, 10):
            rDate = Utils.timestampFromDate(
                str(randint(1, 12)) + "/" + str(randint(1, 12)) + "/" +
                str(randint(2015, 2019)))
            self.__rentalService.addRental(
                Rental(i, randint(1, 9), randint(1, 9), rDate,
                       rDate + Utils.CST_RENTAL_PERIOD, None))
Пример #8
0
    def setUp(self):
        self.dataManager = DataManager(ClientValidator)
        self.clientService = ClientService(self.dataManager)

        for i in range(1, 10):
            self.clientService.addClient(Client(i, "Name" + str(i)))