

def test_encrypted_save(self):
    'Encrypt access token on save.'
    access_token = self.get_random_string()
    self.access.access_token = access_token
    self.access.save()
    access = AccountAccess.objects.extra(select={
        'raw_token': 'access_token',
    }).get(pk=self.access.pk)
    self.assertNotEqual(access.raw_token, access_token)
    self.assertTrue(access.raw_token.startswith('$AES$'))
    self.assertEqual(access.access_token, access_token, 'Token should be unencrypted on fetch.')

dataset/ETHPy150Open mlavin/django-all-access/allaccess/tests/test_models.py AccountAccessTestCase.test_encrypted_save/original