def test_pre_fill(self): from farnsworth.pre_fill import main, REQUESTS, MANAGERS main([]) for title in [i[0] for i in MANAGERS]: self.assertEqual(1, Manager.objects.filter(title=title).count()) for name in [i[0] for i in REQUESTS]: self.assertEqual(1, RequestType.objects.filter(name=name).count())
def test_pre_fill(self): from farnsworth.pre_fill import main from managers.fill import REQUESTS, MANAGERS main(["--requests", "--managers"]) for title in [i[0] for i in MANAGERS]: self.assertEqual(1, Manager.objects.filter(title=title).count()) for name in [i[0] for i in REQUESTS]: self.assertEqual(1, RequestType.objects.filter(name=name).count())
def test_pre_fill_and_assign(self): """ Tests that shifts can be correctly assigned after farnsworth/pre_fill.py is run. This is a good test of how the assignment code functions "in the wild," rather than with many duplicates of the same shift. """ users = [] for i in range(1, 50): users.append(User.objects.create_user(username="******".format(i))) pre_fill.main(["--managers", "--workshift"]) utils.make_workshift_pool_hours(semester=self.semester) # Assign manager shifts beforehand for user, manager in zip(users, Manager.objects.all()): manager.incumbent = UserProfile.objects.get(user=user) manager.save() unfinished = utils.auto_assign_shifts(self.semester) self.assertEqual([], unfinished)
def _test_pre_fill_and_assign_humor(self): """ Tests that humor shifts can be correctly assigned after farnsworth/pre_fill.py is run. """ for i in range(1, 50): User.objects.create_user(username="******".format(i)) pre_fill.main(["--managers", "--workshift"]) utils.make_workshift_pool_hours(semester=self.semester) # Assign manager shifts beforehand manager_shifts = RegularWorkshift.objects.filter( pool=self.p1, workshift_type__auto_assign=False, ) profiles = WorkshiftProfile.objects.all() for profile, shift in zip(profiles, manager_shifts): shift.current_assignees.add(profile) shift.save() unfinished = utils.auto_assign_shifts( self.semester, pool=WorkshiftPool.objects.get(title="Humor Shift") ) self.assertEqual([], unfinished)