コード例 #1
0
class TestCredentialsField(unittest.TestCase):

    def setUp(self):
        self.fake_model = FakeCredentialsModel()
        self.fake_model_field = self.fake_model._meta.get_field('credentials')
        self.field = CredentialsField()
        self.credentials = Credentials()
        self.pickle_str = _from_bytes(
            base64.b64encode(pickle.dumps(self.credentials)))

    def test_field_is_text(self):
        self.assertEquals(self.field.get_internal_type(), 'TextField')

    def test_field_unpickled(self):
        self.assertTrue(isinstance(self.field.to_python(self.pickle_str),
                                   Credentials))

    def test_field_unpickled_none(self):
        self.assertEqual(self.field.to_python(None), None)

    def test_field_pickled(self):
        prep_value = self.field.get_db_prep_value(self.credentials,
                                                  connection=None)
        self.assertEqual(prep_value, self.pickle_str)

    def test_field_value_to_string(self):
        self.fake_model.credentials = self.credentials
        value_str = self.fake_model_field.value_to_string(self.fake_model)
        self.assertEqual(value_str, self.pickle_str)

    def test_field_value_to_string_none(self):
        self.fake_model.credentials = None
        value_str = self.fake_model_field.value_to_string(self.fake_model)
        self.assertEqual(value_str, None)
コード例 #2
0
 def setUp(self):
     self.fake_model = FakeCredentialsModel()
     self.fake_model_field = self.fake_model._meta.get_field('credentials')
     self.field = CredentialsField(null=True)
     self.credentials = Credentials()
     self.pickle_str = _from_bytes(
         base64.b64encode(pickle.dumps(self.credentials)))
コード例 #3
0
class TestCredentialsField(unittest.TestCase):
    def setUp(self):
        self.fake_model = FakeCredentialsModel()
        self.fake_model_field = self.fake_model._meta.get_field('credentials')
        self.field = CredentialsField()
        self.credentials = Credentials()
        self.pickle_str = _from_bytes(
            base64.b64encode(pickle.dumps(self.credentials)))

    def test_field_is_text(self):
        self.assertEquals(self.field.get_internal_type(), 'TextField')

    def test_field_unpickled(self):
        self.assertTrue(
            isinstance(self.field.to_python(self.pickle_str), Credentials))

    def test_field_unpickled_none(self):
        self.assertEqual(self.field.to_python(None), None)

    def test_field_pickled(self):
        prep_value = self.field.get_db_prep_value(self.credentials,
                                                  connection=None)
        self.assertEqual(prep_value, self.pickle_str)

    def test_field_value_to_string(self):
        self.fake_model.credentials = self.credentials
        value_str = self.fake_model_field.value_to_string(self.fake_model)
        self.assertEqual(value_str, self.pickle_str)

    def test_field_value_to_string_none(self):
        self.fake_model.credentials = None
        value_str = self.fake_model_field.value_to_string(self.fake_model)
        self.assertEqual(value_str, None)
コード例 #4
0
class FakeCredentialsModelMockNoSet(object):
    def __init__(self, set_store=False, *args, **kwargs):
        self.model = FakeCredentialsModelMock
        self.saved = False
        self.deleted = False

    credentials = CredentialsField()
コード例 #5
0
 def setUp(self):
     self.fake_model = FakeCredentialsModel()
     self.fake_model_field = self.fake_model._meta.get_field('credentials')
     self.field = CredentialsField(null=True)
     self.credentials = Credentials()
     self.pickle_str = _from_bytes(
         base64.b64encode(pickle.dumps(self.credentials)))
コード例 #6
0
class CredentialsModel(models.Model):
    user = models.OneToOneField(settings.AUTH_USER_MODEL,
                                related_name='analytics_credential',
                                primary_key=True)
    credential = CredentialsField()

    def has_analytics(self):
        return self.user.has_analytics
コード例 #7
0
class GmailCredentialsModel(models.Model):
    """
    OAuth2 credentials for Gmail API.
    """
    id = models.OneToOneField(EmailAccount, primary_key=True)
    credentials = CredentialsField()

    class Meta:
        app_label = 'email'
コード例 #8
0
class Migration(migrations.Migration):

    dependencies = [
        ('accounts', '0031_auto_20150708_1252'),
    ]

    operations = [
        migrations.CreateModel(
            name='CredentialsModel',
            fields=[
                ('id',
                 models.ForeignKey(related_name='addnow_user',
                                   primary_key=True,
                                   serialize=False,
                                   to=settings.AUTH_USER_MODEL)),
                ('credential', CredentialsField(null=True)),
            ],
            options={},
            bases=(models.Model, ),
        ),
    ]
コード例 #9
0
ファイル: models.py プロジェクト: AthmanZiri/TolaTables
class GoogleCredentialsModel(models.Model):
    id = models.OneToOneField(User, primary_key=True, related_name='google_credentials')
    credential = CredentialsField()
コード例 #10
0
ファイル: models.py プロジェクト: google/mirandum
class BeamCredentialsModel(models.Model):
  id = models.ForeignKey(BeamAppCreds, primary_key=True)
  credential = CredentialsField()
コード例 #11
0
class CredentialsModel(models.Model):
    id = models.ForeignKey(User, primary_key=True)
    credential = CredentialsField()
コード例 #12
0
ファイル: models.py プロジェクト: raxelg/murmur
class CredentialsModel(models.Model):
    id = models.ForeignKey(AUTH_USER_MODEL,
                           primary_key=True,
                           on_delete=models.CASCADE)
    credential = CredentialsField()
コード例 #13
0
class TokenStorageModel(models.Model):
    id = models.OneToOneField(User, primary_key=True, related_name='google_id')
    credential = CredentialsField()

    class Meta:
        app_label = 'main'
コード例 #14
0
 def test_credentials_without_null(self):
     credentials = CredentialsField()
     self.assertTrue(credentials.null)
コード例 #15
0
class PatreonCredentialsModel(models.Model):
    id = models.ForeignKey(PatreonAppCreds, primary_key=True)
    credential = CredentialsField()
コード例 #16
0
class FakeCredentialsModel(models.Model):
    credentials = CredentialsField()
コード例 #17
0
class TwitchCredentialsModel(models.Model):
    id = models.ForeignKey(TwitchAppCreds, primary_key=True)
    credential = CredentialsField()
コード例 #18
0
class IntegrationCredentials(models.Model):
    details = models.OneToOneField(IntegrationDetails, primary_key=True)
    credentials = CredentialsField()
コード例 #19
0
class CredentialsModel(models.Model):
	id = models.OneToOneField(User, primary_key=True)
	credential = CredentialsField()