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
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
def run(self, simulation): # Step 1: Create random exchange points, users and their books simulation.generate_items() # Step 2: Owners giving their books to Exchange Points TransactionsLogic.move_books_from_owners_to_points(simulation) simulation.state = ExecutedSimulationState()