Пример #1
0
    def test_points_chaining(self):
        sim = Simulation(users_count=2, max_books_per_user=2, exchange_points_count=3)
        sim.exchange_point_capacity = 5
        sim.generate_items()
        test_point = sim.get_last_exchange_point()

        for _ in range(0,15):
            test_point.put_book(simulation_item_factory.create_simulation_book())

        for point in sim.all_exchange_points:
            self.assertTrue(len(point.stored_books)>0)
Пример #2
0
    def test_otp_execution(self):
        simulation = Simulation(users_count=2, max_books_per_user=2, exchange_points_count=1)
        simulation.generate_items()

        TransactionsLogic.move_books_from_owners_to_points(simulation)
        point = simulation.get_last_exchange_point()
        self.assertTrue(len(point.stored_books) > 0)  # point received some books as result of transaction

        moved_book = point.stored_books[0]
        one_user = simulation.all_users[0]
        self.assertTrue(moved_book not in one_user.own_books)  # user has no book which is moved to exchange point
Пример #3
0
    def test_points_chaining(self):
        sim = Simulation(users_count=2,
                         max_books_per_user=2,
                         exchange_points_count=3)
        sim.exchange_point_capacity = 5
        sim.generate_items()
        test_point = sim.get_last_exchange_point()

        for _ in range(0, 15):
            test_point.put_book(
                simulation_item_factory.create_simulation_book())

        for point in sim.all_exchange_points:
            self.assertTrue(len(point.stored_books) > 0)
Пример #4
0
    def test_otp_execution(self):
        simulation = Simulation(users_count=2,
                                max_books_per_user=2,
                                exchange_points_count=1)
        simulation.generate_items()

        TransactionsLogic.move_books_from_owners_to_points(simulation)
        point = simulation.get_last_exchange_point()
        self.assertTrue(
            len(point.stored_books) >
            0)  # point received some books as result of transaction

        moved_book = point.stored_books[0]
        one_user = simulation.all_users[0]
        self.assertTrue(moved_book not in one_user.own_books
                        )  # user has no book which is moved to exchange point