Exemple #1
0
    def test_sort_3(self):
        record_store = RecordStore()

        people = [
            Person(last_name='B',
                   first_name='x',
                   gender='Male',
                   favorite_color='x',
                   date_of_birth='01/01/2000'),
            Person(last_name='A',
                   first_name='x',
                   gender='Male',
                   favorite_color='x',
                   date_of_birth='01/01/2000'),
            Person(last_name='C',
                   first_name='x',
                   gender='Male',
                   favorite_color='x',
                   date_of_birth='01/01/2000'),
            Person(last_name='D',
                   first_name='x',
                   gender='Male',
                   favorite_color='x',
                   date_of_birth='01/01/2000')
        ]
        record_store.add_records(people)

        sorted_records = record_store.get_all_records(3)

        assert sorted_records[0] == people[3]
        assert sorted_records[1] == people[2]
        assert sorted_records[2] == people[0]
        assert sorted_records[3] == people[1]
Exemple #2
0
 def post(self):
     list_name = self.request.POST['list_name'].strip()
     sub_list = self.request.POST['list'].split('\n')
     new_list = []
     for item in sub_list:
         if item.strip() <> '': new_list.append(item.strip())
     person = Person().getCurrentPerson()
     person.updateTimesheetTasks(new_list)
     self.response.out.write(json.dumps({"response": person.toDict()}))
Exemple #3
0
    def save_entry(self, items):
        '''
        Only save or deleting
        no updating
        '''
        errors = []
        self.google_id = users.get_current_user().user_id()
        new_item = items['task'].strip()
        if new_item == '': errors.append('Must enter a value for task')
        self.task = new_item

        try:
            self.minutes = int(items['minutes'])
        except:
            errors.append('Minutes must be an integer')

        try:
            self.date = convertToDate(items['date'])
        except:
            errors.append('Invalid date format - yyyy-mm-dd')

        if items['add'] == 'yes':
            Person().updateTimesheetTask(new_item)

        if len(errors) > 0: raise KnownError(errors)
        self.createNew()
        return str(self.key())
    def test_str_value(self):
        person = Person(first_name=" bob ",
                        last_name="SMITH",
                        gender="Male",
                        favorite_color="RED",
                        date_of_birth="01/25/1999")

        assert str(person) == "Bob, Smith, Male, red, 01/25/1999"
Exemple #5
0
 def post(self):
     response = Person().addShout(self.request.POST['item'].strip(), 
                                 self.request.POST['date_time'].strip(), 
                                 self.request.POST['key'].strip(), 
                                 self.request.POST['who'].strip(),
                                 self.request.POST['shouts_last_updated'].strip(),
                                 self.request.POST['latt'].strip(),
                                 self.request.POST['long'].strip())
     self.response.out.write(json.dumps({"response":response}))
 def test_init_bad_values_raise(self, last, first, gender, color, dob,
                                expected_failure_message):
     with pytest.raises(ValueError) as person_error:
         person = Person(last_name=last,
                         first_name=first,
                         gender=gender,
                         favorite_color=color,
                         date_of_birth=dob)
         assert expected_failure_message in person_error
    def test_init_person(self, last, first, gender, color, dob):
        person = Person(last_name=last,
                        first_name=first,
                        gender=gender,
                        favorite_color=color,
                        date_of_birth=dob)

        assert person.last_name == last.strip().capitalize()
        assert person.first_name == first.strip().capitalize()
        assert person.gender == gender.strip().capitalize()
        assert person.favorite_color == color.strip().lower()
        assert person.date_of_birth == datetime.strptime(
            dob.strip(), "%m/%d/%Y")
Exemple #8
0
 def post(self):
     response = Person().deleteShout(self.request.POST['key'].strip()) 
     self.response.out.write(json.dumps({"response":response}))
Exemple #9
0
 def post(self):
     response = Person().loadCheck(self.request.POST['shouts_last_updated'].strip())
     self.response.out.write(json.dumps({"response":response}))
Exemple #10
0
 def post(self):
     response = Person().updateFriendName(self.request.POST['friend_name'].strip(),
                                self.request.POST['key'].strip())
     self.response.out.write(json.dumps({"response":response}))
Exemple #11
0
 def post(self):
     response = Person().addFriend(self.request.POST['friend_name'].strip(),
                                self.request.POST['friend_id'].strip())
     self.response.out.write(json.dumps({"response":response}))
Exemple #12
0
 def post(self):
     response = Person().updatePerson(self.request)
     self.response.out.write(json.dumps({"response":response}))
Exemple #13
0
 def post(self):
     new_field_value = self.request.POST['new_field_value'].strip()
     field_name = self.request.POST['field_name'].strip()
     person = Person().getCurrentPerson()
     person.updateField(field_name, new_field_value)
     self.response.out.write(json.dumps({"response": person.toDict()}))
Exemple #14
0
from app.Person import Person
from app.Questions import Questions

if __name__ == "__main__":

    persons = [Person("Spyridoyla"), Person("Helias"), Person("Anastasia")]

    questions = Questions()

    for q in questions.ques:
        for p in persons:
            p.ask_question(q, questions.skip)

    print()
    print("Scoring time...")
    for p in persons:
        print(p.name + " : " + str(p.correct) + " / " + str(p.total))
Exemple #15
0
 def post(self):
     person = Person().getCurrentPerson()
     self.response.out.write(json.dumps({"response": person.toDict()}))
Exemple #16
0
 def post(self):
     response = Person().fullSynch()
     self.response.out.write(json.dumps({"response":response}))
Exemple #17
0
 def post(self):
     response = Person().shoutHistory(self.request.POST['key'].strip(), 
                                      self.request.POST['item'].strip())
     self.response.out.write(json.dumps({"response":response}))
Exemple #18
0
 def get(self):
     person = Person().getCurrentPerson()
     self.template_values['task_list'] = ['-'] + person.timesheet_tasks
     self.response.out.write(
         template.render('web/timesheet_mob.html', self.template_values))