コード例 #1
0
    def testRepo(self):
        repo = Repository()
        assert repo.add(Student('1', 'Mihai Ionut', 10, 10)) == False
        assert repo.add(Student('2', 'Mihai Ionut', 10, 10)) == False
        assert repo.add(Student('3', 'Mihai Ionut', 10, 10)) == False

        repo.addBonus(Student('1', 'Mihai', 13, 9), 1)
        repo.addBonus(Student('2', 'Ionut', 5, 8), 1)
        for i in repo.getAll():
            if i.getID() == 1:
                assert i.getGrade() == 10
            if i.getID() == 2:
                assert i.getGrade() == 9

        assert len(repo.getAll()) == 10
コード例 #2
0
 def _storeToFile(self):
     f = open(self._fName, "w")
     cars = Repository.getAll(self)
     for c in cars:
         cf = str(c.getId()) + ";" + c.getCNP() + ";" + c.getName() + "\n"
         f.write(cf)
     f.close()
コード例 #3
0
 def _storeToFile(self):
     f = open(self._fName, "w")
     rentals = Repository.getAll(self)
     for r in rentals:
         rl = str(r.getId()) + ";" + str(r.getClient().getId()) + ";" + str(r.getCar().getId()) + ";" + r.getStart().strftime("%Y-%m-%d") + ";" + r.getEnd().strftime("%Y-%m-%d") + "\n"
         f.write(rl)
     f.close()
コード例 #4
0
 def _storeToFile(self):
     f = open(self._fName, "w")
     cars = Repository.getAll(self)
     for c in cars:
         cf = str(c.getId()) + ";" + c.getLicenseNumber() + ";" + c.getMake() + ";" + c.getModel() + "\n"
         f.write(cf)
     f.close()
コード例 #5
0
 def __storeToFile(self):
     f = open(self.__fName, "w")
     students = Repository.getAll(self)
     for stud in students:
         strf = str(stud.getId()) + "," + str(stud.getName()) + "," + str(
             stud.getGroup()) + "\n"
         f.write(strf)
     f.close()
コード例 #6
0
 def __storeToFile(self):
     f = open(self.__fName, "w")
     assignments = Repository.getAll(self)
     for ass in assignments:
         strf = str(ass.getId()) + "," + str(
             ass.getDescription()) + "," + str(ass.getDeadline()) + "\n"
         f.write(strf)
     f.close()
コード例 #7
0
    def __storeToFile(self):
        f = open(self.__f_name, "w")
        rentals = Repository.getAll(self)

        for rental in rentals:
            str_book = str(rental.id) + ", " + str(rental.bookId) + ", " + str(rental.clientId) + ", " + str(rental.renDate) + ", " + str(rental.dueDate) + ", " + str(rental.retDate) + "\n"
            f.write(str_book)

        f.close()
コード例 #8
0
 def __storeToFile(self):
     f = open(self.__fName, "w")
     grades = Repository.getAll(self)
     for gr in grades:
         strf = str(gr.getId()) + "," + str(
             gr.getAss().getId()) + "," + str(
                 gr.getStud().getId()) + "," + str(gr.getGrade()) + "\n"
         f.write(strf)
     f.close
コード例 #9
0
    def __storeToFile(self):
        f = open(self.__f_name, "w")
        clients = Repository.getAll(self)

        for client in clients:
            str_client = str(client.id) + ", " + client.name + "\n"
            f.write(str_client)

        f.close()
コード例 #10
0
 def _storeToFile(self):
     f = open(self._fName, "w")
     rentals = Repository.getAll(self)
     for r in rentals:
         rl = str(r.getId()) + ";" + str(r.getClient().getId()) + ";" + str(
             r.getCar().getId()) + ";" + r.getStart().strftime(
                 "%Y-%m-%d") + ";" + r.getEnd().strftime("%Y-%m-%d") + "\n"
         f.write(rl)
     f.close()
コード例 #11
0
ファイル: BookRepo.py プロジェクト: rzvpop/lab4
    def __storeToFile(self):
        f = open(self.__f_name, "w")
        books = Repository.getAll(self)

        for book in books:
            str_book = str(book.id) + ", " + book.title + ", " + book.desc + ", " + book.author + "\n"
            f.write(str_book)

        f.close()
コード例 #12
0
class ClientTestCase(unittest.TestCase):
    def setUp(self):
        self.v = ClientValidator()
        self.c = Client("1", "aaa")
        self.client = Repository()

    def testClient(self):
        self.assertTrue(self.v.validate, self.c)
        self.c.name = "bbb"
        self.assertTrue(self.v.validate, self.c.name == "bbb")
        self.c.name = ""
        self.assertRaises(ValidatorException, self.v.validate, self.c)
        z = Client("1", "Anna")
        self.client.add(z)
        self.client.remove(z)
        self.assertEqual(len(self.client.getAll()), 0)
コード例 #13
0
def testRent():
    b_repo = testBook()
    c_repo = testClient()
    r_repo = Repository()

    ctrl = Controller(b_repo, c_repo, r_repo)

    ctrl.addRental(["1", "3", "12"])
    try:
        ctrl.addRental(["2", "4", "42"])
    except LibraryException:
        pass

    rentals = r_repo.getAll()

    assert(rentals[0] == Rental(1, 4, 12, date.today(), date.today() + timedelta(days=10), False))
コード例 #14
0
class MovieControllerTest(unittest.TestCase):
    def setUp(self):
        self.v = MovieValidator()
        self.movie = Repository()
        self.c = Movie("1", "aaa", "bbb", "ccc")

    def testMovie(self):
        self.movie.add([1, "aaa", "bbb", "ccc"])
        self.assertTrue(self.v.validate, self.movie)
        self.assertEqual(len(self.movie.getAll()), 1)
        self.movie.add([])
        self.assertTrue(self.v.validate, self.c)
        self.c.genre = "aaa"
        self.assertTrue(self.v.validate, self.c.genre == "aaa")
        self.c.genre = ""
        self.assertRaises(ValidatorException, self.v.validate, self.c)
        self.c.description = "bbb"
        self.assertTrue(self.v.validate, self.c.description == "bbb")
        self.c.description = ""
        self.assertRaises(ValidatorException, self.v.validate, self.c)
        self.assertEqual(len(self.movie), 2)
コード例 #15
0
 def getAll(self):
     return Repository.getAll(self)