Beispiel #1
0
 def test_matricule_is_immutable(self):
     """The student matricule cannot be edited"""
     Student.new_student({
         'firstName': 'Alice',
         'lastName': 'Smith',
         'matricule': 'X2010200001'
     })
     alice = Student.get_by_id('X2010200001')
     alice.data['matricule'] += '1'
     self.assertRaises(AttributeError, alice.put)
Beispiel #2
0
 def test_update_student(self):
     """the student data stay valide"""
     Student.new_student({
         'firstName': 'Alice',
         'lastName': 'Smith',
         'matricule': 'X2010200001'
     })
     alice = Student.get_by_id('X2010200001')
     del alice.data['lastName']
     self.assertRaises(ValidationError, alice.put)
Beispiel #3
0
    def test_names_are_capitalized(self):
        alice = Student.new_student({
            'firstName': 'alice',
            'lastName': 'smith',
            'matricule': 'X2010200001'
        })
        self.assertEqual('Alice', alice.first_name)
        self.assertEqual('Smith', alice.last_name)

        alice = Student.get_by_id('X2010200001')
        alice.data['lastName'] = 'taylor'
        alice.put()
        self.assertEqual('Taylor', alice.last_name)
Beispiel #4
0
    def test_new_student(self):
        alice = Student.new_student({
            'firstName': 'Alice',
            'lastName': 'Smith',
            'matricule': 'X2010200001'
        })
        self.assertEqual('X2010200001', alice.matricule)
        self.assertEqual('X2010200001', alice.key.id())
        self.assertEqual('Alice', alice.first_name)
        self.assertEqual('Smith', alice.last_name)
        self.assertEqual('Smith, Alice', alice.full_name)
        self.assertEqual(None, alice.photo)

        alice = Student.get_by_id('X2010200001')
        self.assertTrue(alice)
Beispiel #5
0
    def test_new_student_create_unique_student(self):
        Student.new_student({
            'firstName': 'Alice',
            'lastName': 'Smith',
            'matricule': 'X2010200001'
        })
        self.assertRaises(
            AttributeError,
            Student.new_student,
            {
                'firstName': 'Bob',
                'lastName': 'Smith',
                'matricule': 'X2010200001' # same matricule
            }
        )

        alice = Student.get_by_id('X2010200001')
        self.assertEqual('Alice', alice.first_name)