Beispiel #1
0
def testRentalRepository():
    rentalRepo = Repository()
    book1 = Book(0, "The Q", "Albert", "Heinrich")
    book2 = Book(1, "The D", "Elbert", "Reinsich")
    client1 = Client(0, "Mihai", 1854987548795)
    client2 = Client(1, "Alex", 1987548759658)

    rentalRepo.addElement(Rental(1, book1, 0))
    rentalRepo.addElement(Rental(0, book2, 1))

    # _find(_id) returns the Rental from the repository
    # that has the client Id equal to _id

    assert rentalRepo._find(0).getRentedBook() == book1
    assert rentalRepo._find(1).getId() == 1

    assert rentalRepo._find(1).getRentedBook() == book2
    assert rentalRepo._find(0).getId() == 0

    # findId() function for Repository class
    assert rentalRepo.findId(12) == False
    assert rentalRepo.findId(0) == True

    # elementFromId()
    assert rentalRepo.elementFromId(0).getRentedBook() == book1

    rentalRepo.addElement(Rental(1, book2, 2))

    print("Rental repository tests ran successfully!")
Beispiel #2
0
    def testRentalRepository(self):
        rentalRepo = Repository()
        book1 = Book(0, "The Q", "Albert", "Heinrich")
        book2 = Book(1, "The D", "Elbert", "Reinsich")
        client1 = Client(0, "Mihai", 1854987548795)
        client2 = Client(1, "Alex", 1987548759658)

        rentalRepo.addElement(Rental(1, book1, 0))
        rentalRepo.addElement(Rental(0, book2, 1))

        # _find(_id) returns the Rental from the repository
        # that has the client Id equal to _id

        self.assertEqual(rentalRepo._find(0).getRentedBook(), book1)
        self.assertEqual(rentalRepo._find(1).getId(), 1)

        self.assertEqual(rentalRepo._find(1).getRentedBook(), book2)
        self.assertEqual(rentalRepo._find(0).getId(), 0)

        # findId() function for Repository class
        self.assertEqual(rentalRepo.findId(12), False)
        self.assertEqual(rentalRepo.findId(0), True)

        # elementFromId()
        self.assertEqual(rentalRepo.elementFromId(0).getRentedBook(), book1)

        rentalRepo.addElement(Rental(1, book2, 2))
Beispiel #3
0
    def testRentalRepository(self):
        rentalRepo = Repository()
        book1 = Book(0, "The Q", "Albert", "Heinrich")
        book2 = Book(1, "The D", "Elbert", "Reinsich")
        client1 = Client(0, "Mihai", 1854987548795)
        client2 = Client(1, "Alex", 1987548759658)

        rentalRepo.addElement(Rental(1, book1, 0))
        rentalRepo.addElement(Rental(0, book2, 1))

        # _find(_id) returns the Rental from the repository
        # that has the client Id equal to _id

        self.assertEqual( rentalRepo._find(0).getRentedBook() ,  book1 ) 
        self.assertEqual( rentalRepo._find(1).getId() ,  1 )

        self.assertEqual( rentalRepo._find(1).getRentedBook() ,  book2 )
        self.assertEqual( rentalRepo._find(0).getId() ,  0 )

        # findId() function for Repository class
        self.assertEqual( rentalRepo.findId(12) ,  False )
        self.assertEqual( rentalRepo.findId(0) ,  True )

        # elementFromId()
        self.assertEqual( rentalRepo.elementFromId(0).getRentedBook() ,  book1 )

        rentalRepo.addElement(Rental(1, book2, 2)) 
Beispiel #4
0
def testRentalRepository():
    rentalRepo = Repository()
    book1 = Book(0, "The Q", "Albert", "Heinrich")
    book2 = Book(1, "The D", "Elbert", "Reinsich")
    client1 = Client(0, "Mihai", 1854987548795)
    client2 = Client(1, "Alex", 1987548759658)

    rentalRepo.addElement(Rental(1, book1, 0))
    rentalRepo.addElement(Rental(0, book2, 1))

    # _find(_id) returns the Rental from the repository
    # that has the client Id equal to _id

    assert rentalRepo._find(0).getRentedBook() == book1 
    assert rentalRepo._find(1).getId() == 1

    assert rentalRepo._find(1).getRentedBook() == book2
    assert rentalRepo._find(0).getId() == 0

    # findId() function for Repository class
    assert rentalRepo.findId(12) == False
    assert rentalRepo.findId(0) == True

    # elementFromId()
    assert rentalRepo.elementFromId(0).getRentedBook() == book1

    rentalRepo.addElement(Rental(1, book2, 2)) 

    print ("Rental repository tests ran successfully!")