本文整理汇总了Python中stream.connect函数的典型用法代码示例。如果您正苦于以下问题:Python connect函数的具体用法?Python connect怎么用?Python connect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了connect函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_location_support
def test_location_support(self):
client = stream.connect('a', 'b', 'c', location='us-east')
full_location = 'https://us-east-api.getstream.io/api/'
self.assertEqual(client.location, 'us-east')
self.assertEqual(client.base_url, full_location)
# test a wrong location
client = stream.connect('a', 'b', 'c', location='nonexistant')
def get_feed():
client.feed('user', '1').get()
self.assertRaises(ConnectionError, get_feed)
示例2: test_heroku_real
def test_heroku_real(self):
url = 'https://bvt88g4kvc63:t[email protected]getstream.io/?site=669'
os.environ['STREAM_URL'] = url
client = stream.connect()
self.assertEqual(client.api_key, 'bvt88g4kvc63')
self.assertEqual(client.api_secret, 'twc5ywfste5bm2ngqkzs7ukxk3pn96yweghjrxcmcrarnt3j4dqj3tucbhym5wfd')
self.assertEqual(client.site_id, '669')
示例3: connect_debug
def connect_debug():
return stream.connect(
'gav9ygr75by3',
'5ws2hnua79n9qga6e2dy572qdfapwgdc83853mjm3mjp66czyb2xkahbdhs98an8',
location='us-east',
timeout=10
)
示例4: value_storage
def value_storage(request):
resp = {"success":False, "msgs":['Cannot store the current operation.']}
if request.method == 'POST':
user_name = request.POST['name']
memory_value = request.POST['memory_value']
results_value = request.POST['results_value']
a = Calculations(name=user_name,operations=memory_value,result=results_value)
a.save()
client = stream.connect('tzn84uddddhm', 'hd722ggruc6s6qjzrdskywtctug63r2h396yjhamrbe72cztqgnmkzzvzmh3dzv9', location='eu-central')
# Create a bit more complex activity
user_feed_1 = client.feed('user', '1')
activity_data = {'actor': '1', 'verb': 'run', 'object': 'test',
'participants': ['Sibi'],
'started_at': datetime.datetime.now(),
'foreign_id': 'run:1'
}
user_feed_1.add_activity(activity_data)
notification_feed = client.feed('user', '1')
print memory_value
print results_value
print user_name
resp = {"success":True, "msgs":['Operation has been updated']}
return HttpResponse(json.dumps(resp))
示例5: test_heroku
def test_heroku(self):
url = 'https://thierry:[email protected]/?app_id=1'
os.environ['STREAM_URL'] = url
client = stream.connect()
self.assertEqual(client.api_key, 'thierry')
self.assertEqual(client.api_secret, 'pass')
self.assertEqual(client.app_id, '1')
示例6: test_heroku_overwrite
def test_heroku_overwrite(self):
url = 'https://thierry:[email protected]/?app_id=1'
os.environ['STREAM_URL'] = url
client = stream.connect('a', 'b', 'c')
self.assertEqual(client.api_key, 'a')
self.assertEqual(client.api_secret, 'b')
self.assertEqual(client.app_id, 'c')
示例7: test_original_server
def test_original_server():
client = stream.connect('5e62adrfbcxw', 'qxshw6rvbgcv4ghb342fevzp75h53qhga8vajmd6s4pr6f7kcyfx72w5j693xe3t')
f = client.feed('feed', "user_9_0_5600c2359e08b6b9653ce87e_official")
res = f.get(offset=0,limit=1)
print res
assert 'duration' in res
assert 'results' in res
assert 'next' in res
assert len(res['results']) <= 1
示例8: test_heroku_location
def test_heroku_location(self):
url = 'https://ahj2ndz7gsan:g[email protected]us-east.getstream.io/?app_id=1'
os.environ['STREAM_URL'] = url
client = stream.connect()
self.assertEqual(client.api_key, 'ahj2ndz7gsan')
self.assertEqual(
client.api_secret, 'gthc2t9gh7pzq52f6cky8w4r4up9dr6rju9w3fjgmkv6cdvvav2ufe5fv7e2r9qy')
self.assertEqual(
client.base_url, 'https://us-east-api.getstream.io/api/')
self.assertEqual(client.app_id, '1')
示例9: test_api_key_exception
def test_api_key_exception(self):
self.c = stream.connect(
'5crf3bhfzesnMISSING',
'tfq2sdqpj9g446sbv653x3aqmgn33hsn8uzdc9jpskaw8mj6vsnhzswuwptuj9su'
)
self.user1 = self.c.feed('user', '1')
activity_data = {'actor': 1, 'verb': 'tweet',
'object': 1, 'debug_example_undefined': 'test'}
self.assertRaises(ApiKeyException, lambda:
self.user1.add_activity(activity_data))
示例10: test_new_server
def test_new_server():
client = stream.connect('5e62adrfbcxw', 'qxshw6rvbgcv4ghb342fevzp75h53qhga8vajmd6s4pr6f7kcyfx72w5j693xe3t')
# change from original endpoint to the new one to test
client.base_url = "http://192.168.99.100:5000/api/"
f = client.feed('feed', "user_9_0_5600c2359e08b6b9653ce87e_official")
res = f.get(offset=0,limit=1)
print res
assert 'duration' in res
assert 'results' in res
assert 'next' in res
assert len(res['results']) <= 1
示例11: home
def home(request):
a = 'sibi test getStream'
client = stream.connect('tzn84uddddhm', 'hd722ggruc6s6qjzrdskywtctug63r2h396yjhamrbe72cztqgnmkzzvzmh3dzv9', location='eu-central')
# Create a bit more complex activity
user_feed_1 = client.feed('user', '1')
activity_data = {'actor': '1', 'verb': 'run', 'object': 'test',
'participants': ['Sibi'],
'started_at': datetime.datetime.now(),
'foreign_id': 'run:1'
}
user_feed_1.add_activity(activity_data)
notification_feed = client.feed('user', '1')
return render(request, 'home.html',
{
'a':a,
'token':notification_feed.token,
})
示例12: test_wrong_feed_spec
def test_wrong_feed_spec(self):
self.c = stream.connect(
'5crf3bhfzesnMISSING',
'tfq2sdqpj9g446sbv653x3aqmgn33hsn8uzdc9jpskaw8mj6vsnhzswuwptuj9su'
)
self.assertRaises(TypeError, lambda: getfeed('user1'))
示例13: ImproperlyConfigured
from stream_django import conf
import os
import stream
from django.core.exceptions import ImproperlyConfigured
if conf.API_KEY and conf.API_SECRET:
stream_client = stream.connect(
conf.API_KEY, conf.API_SECRET, location=conf.LOCATION, timeout=conf.TIMEOUT)
else:
stream_client = stream.connect()
if os.environ.get('STREAM_URL') is None and not(conf.API_KEY and conf.API_SECRET):
raise ImproperlyConfigured('Stream credentials are not set in your settings')
示例14:
import stream
import os
from app import app
client = stream.connect(app.config['API_KEY'], app.config['API_SECRET'])
示例15: ImproperlyConfigured
from stream_django import conf
import os
import stream
from django.core.exceptions import ImproperlyConfigured
if conf.API_KEY and conf.API_SECRET:
stream_client = stream.connect(
conf.API_KEY, conf.API_SECRET, location=conf.LOCATION)
else:
stream_client = stream.connect()
if os.environ.get('STREAM_URL') is None and not(conf.API_KEY and conf.API_SECRET):
raise ImproperlyConfigured('Stream credentials are not set in your settings')