示例#1
0
    def test_get_and_put_ndb(self):
        # Start empty
        storage = StorageByKeyName(CredentialsNDBModel, "foo", "credentials")
        self.assertEqual(None, storage.get())

        # Refresh storage and retrieve without using storage
        self.credentials.set_store(storage)
        self.credentials._refresh(_http_request)
        credmodel = CredentialsNDBModel.get_by_id("foo")
        self.assertEqual("bar", credmodel.credentials.access_token)
        self.assertEqual(credmodel.credentials.to_json(), self.credentials.to_json())
示例#2
0
    def test_get_and_put_ndb(self):
        # Start empty
        storage = StorageByKeyName(CredentialsNDBModel, 'foo', 'credentials')
        self.assertEqual(None, storage.get())

        # Refresh storage and retrieve without using storage
        self.credentials.set_store(storage)
        self.credentials._refresh(_http_request)
        credmodel = CredentialsNDBModel.get_by_id('foo')
        self.assertEqual('bar', credmodel.credentials.access_token)
        self.assertEqual(credmodel.credentials.to_json(),
                         self.credentials.to_json())
示例#3
0
    def test_get_and_put_mixed_db_storage_ndb_get(self):
        # Start empty
        storage = StorageByKeyName(CredentialsModel, "foo", "credentials")
        self.assertEqual(None, storage.get())

        # Set DB store and refresh to add to storage
        self.credentials.set_store(storage)
        self.credentials._refresh(_http_request)

        # Retrieve same key from NDB model to confirm mixing works
        credmodel = CredentialsNDBModel.get_by_id("foo")
        self.assertEqual("bar", credmodel.credentials.access_token)
        self.assertEqual(self.credentials.to_json(), credmodel.credentials.to_json())
示例#4
0
    def test_delete_ndb(self):
        # Start empty
        storage = StorageByKeyName(CredentialsNDBModel, "foo", "credentials")
        self.assertEqual(None, storage.get())

        # Add credentials to model with storage, and check equivalent w/o storage
        storage.put(self.credentials)
        credmodel = CredentialsNDBModel.get_by_id("foo")
        self.assertEqual(credmodel.credentials.to_json(), self.credentials.to_json())

        # Delete and make sure empty
        storage.delete()
        self.assertEqual(None, storage.get())
示例#5
0
    def test_get_and_put_mixed_db_storage_ndb_get(self):
        # Start empty
        storage = StorageByKeyName(CredentialsModel, 'foo', 'credentials')
        self.assertEqual(None, storage.get())

        # Set DB store and refresh to add to storage
        self.credentials.set_store(storage)
        self.credentials._refresh(_http_request)

        # Retrieve same key from NDB model to confirm mixing works
        credmodel = CredentialsNDBModel.get_by_id('foo')
        self.assertEqual('bar', credmodel.credentials.access_token)
        self.assertEqual(self.credentials.to_json(),
                         credmodel.credentials.to_json())
示例#6
0
    def test_delete_ndb(self):
        # Start empty
        storage = StorageByKeyName(CredentialsNDBModel, 'foo', 'credentials')
        self.assertEqual(None, storage.get())

        # Add credentials to model with storage, and check equivalent w/o storage
        storage.put(self.credentials)
        credmodel = CredentialsNDBModel.get_by_id('foo')
        self.assertEqual(credmodel.credentials.to_json(),
                         self.credentials.to_json())

        # Delete and make sure empty
        storage.delete()
        self.assertEqual(None, storage.get())