def setUp(self): cr_db = Classrace.objects.get(pk=1) self.oldcr = mocks.BaseMock( classname=cr_db.classname, racetype=cr_db.racetype, eventrace = mocks.BaseMock( eventracefkey = cr_db.eventrace) ) self.firsteventrace = EventRace.objects.get(pk=1)
def test_oldpersonrun(self): person = self.oldentries[0].person competitor = mocks.BaseMock(classraces = { 1 : { 'H21': self.aclassrace } }, person_fkey = person) edata = mocks.BaseMock( competitors = [competitor], classraces = [self.aclassrace]) iu.update_personruns(edata) assert self.oldentries == [x for x in PersonRun.objects.all()]
def test_newpersonrun(self): # get person not existing in fixtures i = 1 while i in [x.person.id for x in self.oldentries]: i += 1 person = Person.objects.get(pk=i) competitor = mocks.BaseMock(classraces = { 1 : { 'H21': self.aclassrace } }, person_fkey = person) edata = mocks.BaseMock( competitors = [competitor], classraces = [self.aclassrace]) iu.update_personruns(edata) assert len(self.oldentries) == len([x for x in \ PersonRun.objects.all()]) -1
def setUp(self): self.results_before = [x for x in Result.objects.all()] crfkey = Classrace.objects.get(pk=1) self.oldcr = mocks.BaseMock(classrace_fkey=crfkey, results = { '23': { 'firstname': 'Per', 'lastname': 'Permans', 'position': 2, 'status': 'OK', 'time': '130', 'diff': '0'}}) self.newcr = mocks.BaseMock(classrace_fkey=crfkey, results = { '45': { 'firstname': 'Jonny', 'lastname': 'Jonnison', 'position': 5, 'status': 'OK', 'time': '200', 'diff': '50'}})
def setUp(self): self.events_in_db = {} with open('data_input/fixtures/graphs_events_testdata.json') as fp: ev_fix = json.load(fp) for ev in ev_fix: self.events_in_db[ev['fields']['eventor_id']] = \ mocks.BaseMock( name = ev['fields']['name'], startdate = ev['fields']['startdate'], eventorID = ev['fields']['eventor_id'] )
def setUp(self): self.competitors = [ mocks.BaseMock( SInrs = ['123'], firstname = 'Pelle', lastname = 'Plupp', email = '*****@*****.**', eventorID = 45678979, ), mocks.BaseMock( SInrs = ['1234'], lastname = 'Rutger', firstname = 'Jönåker', email = '*****@*****.**', eventorID = 45667867, ), mocks.BaseMock( SInrs = ['12'], firstname = 'Surbritt', lastname = 'Jonsson', email = 'suris@local', eventorID = 45687907, )]
def setUp(self): self.eventordata = data.EventorData() self.eventordata.competitors = [ mocks.BaseMock( SInrs = ['123'], firstname = 'Pelle', lastname = 'Plupp', email = '*****@*****.**', eventorID = 45678979, ), mocks.BaseMock( SInrs = ['1234'], lastname = 'Rutger', firstname = 'Jönåker', email = '*****@*****.**', eventorID = 45667867, ), mocks.BaseMock( SInrs = ['12'], firstname = 'Surbritt', lastname = 'Jonsson', email = 'suris@localhost', eventorID = 45687907, )]
def test_oldsplit(self): spobj = Split.objects.get(pk=1) resobj = spobj.result cr = mocks.BaseMock(results={resobj.person_eventor_id : {'resultobj': resobj, 'splits': [{'split_n': spobj.split_n, 'time': spobj.splittime}] } }) iu.update_splits([cr]) assert self.splits_before == [x for x in Split.objects.all()]
def test_new_events(self): newevents = {} newevents[1] = mocks.BaseMock( name = 'Nya Karolinska Sprint', startdate = '2010-01-03', eventorID = 1) before = Event.objects.all() len(before) # executes lazy query, otherwise it will include new event. result = iu.update_events(newevents) assert len(Event.objects.all()) - len(before) == 1 newquery = Event.objects.filter(eventor_id=1) assert len(newquery) == 1 assert newquery[0].name == newevents[1].name
def setUp(self): super(PersonUpdateMixOldNewMembers, self).setUp() self.eventordata.competitors.extend([ mocks.BaseMock( SInrs = ['123'], firstname = 'Pelle', lastname = 'Plupp', email = 'perplupp@localhost', eventorID = 45678979, ), mocks.BaseMock( SInrs = ['1234'], lastname = 'Rutger', firstname = 'Jönåker', email = 'rj@localhost', eventorID = 45667867, ), mocks.BaseMock( SInrs = ['12'], firstname = 'Surbritt', lastname = 'Jonsson', email = '*****@*****.**', eventorID = 45687907, )])
def test_newsplit(self): spobj = Split.objects.get(pk=1) resobj = spobj.result highest_splitn = max([x.split_n for x in \ Split.objects.filter(result=resobj)]) cr = mocks.BaseMock(results={resobj.person_eventor_id : {'resultobj': resobj, 'splits': [{'split_n': highest_splitn+1 , 'time': spobj.splittime}] } }) iu.update_splits([cr]) assert len(self.splits_before) == len([x for x in Split.objects.all()]) - 1
def setUp(self): self.oldentries = [x for x in PersonRun.objects.all()] crfkey = self.oldentries[0].classrace self.aclassrace = mocks.BaseMock(classrace_fkey=crfkey)