def setUp(self): super(TestRequestCount, self).setUp() with self.app.test_request_context(): d1 = Division('Division 1') d2 = Division('Division 2') d3 = Division('Division 3') user = self.normal_user pilot = Pilot(user, 'A Pilot', 1) Permission(d1, PermissionType.submit, user) Permission(d2, PermissionType.review, user) Permission(d3, PermissionType.pay, user) db.session.commit() # Populate requests request_data = { 'ship_type': 'Revenant', 'corporation': 'Center of Applied Studies', 'kill_timestamp': dt.datetime.utcnow(), 'system': 'Jita', 'constellation': 'Kimotoro', 'region': 'The Forge', 'pilot_id': 1, } for division in (d1, d2, d3): requests = ( # Division 1 Request(user, 'Foo', division, request_data.items(), killmail_url='http://google.com', status=ActionType.evaluating), Request(user, 'Foo', division, request_data.items(), killmail_url='http://google.com', status=ActionType.incomplete), Request(user, 'Foo', division, request_data.items(), killmail_url='http://google.com', status=ActionType.approved), Request(user, 'Foo', division, request_data.items(), killmail_url='http://google.com', status=ActionType.paid), Request(user, 'Foo', division, request_data.items(), killmail_url='http://google.com', status=ActionType.rejected), ) db.session.add_all(requests) db.session.commit()
def get_requests(self): """Act as an iterable of requests to add create. It is safe to assume this method will be called from within an request context. """ d1 = Division('Division 1') d2 = Division('Division 2') user1 = self.normal_user user2 = self.admin_user # user1 can submit to division 1, user2 to division 2 # user2 can review and pay out both divisions Permission(d1, PermissionType.submit, user1) Permission(d2, PermissionType.submit, user2) for permission in PermissionType.elevated: for division in (d1, d2): Permission(division, permission, user2) Pilot(user1, 'Generic Pilot', self.sample_request_data['pilot_id']) for division, user in ((d1, user1), (d2, user2)): # 2 evaluating, 1 incomplete, 2 approved, 1 rejected, # and 1 paid. for status in (ActionType.evaluating, ActionType.evaluating, ActionType.incomplete, ActionType.approved, ActionType.approved, ActionType.rejected, ActionType.paid): request_details = "User: {}\nDivision: {}\nStatus: {}"\ .format(user, division, status) yield Request(user, request_details, division, self.sample_request_data.items(), killmail_url='http://paxswill.com', status=status)
def setUp(self): super(TestRequest, self).setUp() with self.app.test_request_context(): d1 = Division('Division One') d2 = Division('Division Two') db.session.add(d1) db.session.add(d2) # Yup, the Gyrobus killmail mock_killmail = dict( id=12842852, ship_type='Erebus', corporation='Ever Flow', alliance='Northern Coalition.', killmail_url=('http://eve-kill.net/?a=kill_detail' '&kll_id=12842852'), base_payout=73957900000, kill_timestamp=dt.datetime(2012, 3, 25, 0, 44, 0, tzinfo=utc), system='92D-OI', constellation='XHYS-O', region='Venal', pilot_id=133741, ) Pilot(self.normal_user, 'eLusi0n', 133741) Request(self.normal_user, 'Original details', d1, mock_killmail.items()) db.session.commit() self.request_path = '/request/12842852/'
def setUp(self): super(TestModels, self).setUp() with self.app.test_request_context(): div = Division('Testing Division') mock_killmail = dict( id=12842852, ship_type='Erebus', corporation='Ever Flow', alliance='Northern Coalition.', killmail_url=('http://eve-kill.net/?a=kill_detail' '&kll_id=12842852'), base_payout=Decimal(73957900000), kill_timestamp=dt.datetime(2012, 3, 25, 0, 44, 0, tzinfo=utc), system='92D-OI', constellation='XHYS-O', region='Venal', pilot_id=133741, ) Pilot(self.normal_user, 'eLusi0n', 133741) Request(self.normal_user, 'Original details', div, mock_killmail.items()) Permission(div, PermissionType.review, self.admin_user) Permission(div, PermissionType.pay, self.admin_user) db.session.commit()
def setUp(self): super(TestFilterBase, self).setUp() with self.app.test_request_context(): # Divisions divisions = { self.DIV_1: Division(self.DIV_1), self.DIV_2: Division(self.DIV_2), self.DIV_3: Division(self.DIV_3), } # Give all permissions in all divisions to admin_user for division in divisions.values(): for permission in PermissionType.all: Permission(division, permission, self.admin_user) # Pilots pilots = { 'Paxswill': 570140137, 'Sapporo Jones': 772506501, 'DurrHurrDurr': 1456384556, 'Gevlon Goblin': 91662677, 'Zora Aran': 534674271, } for name, id in pilots.items(): if id % 2 == 0: user = self.normal_user else: user = self.admin_user db.session.add(Pilot(user, name, id)) # Lossmails/requests for request_data in self.killmails: # Copy dict before we pop stuff out of it data_copy = dict(request_data) # Distribute requests between users if request_data['id'] % 2 == 0: user = self.admin_user else: user = self.normal_user details = data_copy.pop('details') division = divisions[data_copy.pop('division')] status = data_copy.pop('status') data_copy['pilot_id'] = pilots[data_copy.pop('pilot')] request = Request(user, details, division, data_copy.items()) # Set status after the base payout has been set request.status = status db.session.commit()
def setUp(self): super(TestRequestList, self).setUp() with self.app.test_request_context(): d1 = Division('Division 1') d2 = Division('Division 2') user1 = self.normal_user user2 = self.admin_user # user1 can submit to division 1, user2 to division 2 # user2 can review and pay out both divisions Permission(d1, PermissionType.submit, user1) Permission(d2, PermissionType.submit, user2) for permission in PermissionType.elevated: for division in (d1, d2): Permission(division, permission, user2) Pilot(user1, 'Generic Pilot', 1) request_data = { 'ship_type': 'Revenant', 'corporation': 'Center of Applied Studies', 'kill_timestamp': dt.datetime.utcnow(), 'system': 'Jita', 'constellation': 'Kimotoro', 'region': 'The Forge', 'pilot_id': 1, } for division, user in ((d1, user1), (d2, user2)): # 2 evaluating, 1 incomplete, 2 approved, 1 rejected, # and 1 paid. Request(user, 'First', division, request_data.items(), killmail_url='http://paxswill.com', status=ActionType.evaluating) Request(user, 'Second', division, request_data.items(), killmail_url='http://paxswill.com', status=ActionType.evaluating) Request(user, 'Third', division, request_data.items(), killmail_url='http://paxswill.com', status=ActionType.incomplete) Request(user, 'Fourth', division, request_data.items(), killmail_url='http://paxswill.com', status=ActionType.approved) Request(user, 'Fifth', division, request_data.items(), killmail_url='http://paxswill.com', status=ActionType.approved) Request(user, 'Sixth', division, request_data.items(), killmail_url='http://paxswill.com', status=ActionType.rejected) Request(user, 'Sixth', division, request_data.items(), killmail_url='http://paxswill.com', status=ActionType.paid) db.session.commit()