def test_defaults(self):
     """
     Do not provide fields that can be defaulted and test their values
     """
     user = User(email='*****@*****.**', password='******')
     user.save()
     self.assertNotEqual(None, user)
     self.assertIsInstance(user, User)
 def test_invalid_age(self):
     """
     The size field was not provided
     """
     user = User(first_name='test',
                 last_name='user',
                 phone='+919999999999',
                 facebook_id='fb001',
                 email='*****@*****.**',
                 age='20')
     user.save()
     print(user)
 def test_fb_id_too_long(self):
     """
     The fb_id field was too long
     """
     msg = 'value too long for type character varying(100)'
     with self.assertRaisesMessage(DataError, msg):
         user = User(first_name='test',
                     last_name='user',
                     phone='+919999999999',
                     facebook_id='f' * 101,
                     email='*****@*****.**',
                     age=20)
         user.save()
         self.fail("'test_fb_id_too_long' did not get the expected error")
 def test_email_too_long(self):
     """
     The archive_location field was too long
     """
     msg = 'value too long for type character varying(254)'
     with self.assertRaisesMessage(DataError, msg):
         user = User(first_name='test',
                     last_name='user',
                     phone='+919999999999',
                     facebook_id='fb001',
                     email='*****@*****.**' * 256,
                     age=20)
         user.save()
         self.fail(
             "'test_archive_location_too_long' did not get the expected error"
         )
 def test_updated_at(self):
     """
     Check is updated_at changes after updating a object
     """
     user = User(first_name='test',
                 last_name='user',
                 phone='+919999999999',
                 facebook_id='fb001',
                 email='*****@*****.**',
                 age='20')
     user.save()
     updated1 = user.updated_at
     user.first_name = 'Sumeet'
     user.save(update_fields=['first_name'])
     updated2 = user.updated_at
     result = updated2 > updated1
     self.assertTrue(result, True)
 def test_valid_data(self):
     """
     User with valid data
     """
     user = User(first_name='test',
                 last_name='user',
                 phone='+919999999999',
                 facebook_id='fb001',
                 email='*****@*****.**',
                 age=20)
     user.save()
     self.assertNotEqual(None, user)
     self.assertIsInstance(user, User)
     self.assertEqual('test', user.first_name)
     self.assertEqual('user', user.last_name)
     self.assertEqual('+919999999999', user.phone)
     self.assertEqual('fb001', user.facebook_id)
     self.assertEqual('*****@*****.**', user.email)
     self.assertEqual(20, user.age)