Ejemplo n.º 1
0
 def test_add_client(self):
   self.mox.StubOutWithMock(clients, 'channel')
   clients.channel.create_channel(mox.IsA(str))
   self.mox.ReplayAll()
   
   (id, token) = clients.add_client('http://example.com/feed')
   self.mox.UnsetStubs()
   self.mox.VerifyAll()
   self.assertEqual(1, len(client_model.Client.all().fetch(2)))
Ejemplo n.º 2
0
def add_clients():

    application.destroy()
    #    login.close()

    import clients
    a = clients.add_client()

    open_win()
Ejemplo n.º 3
0
 def test_send_filtered_messages(self):
   self.mox.StubOutWithMock(clients, 'channel')
   self.mox.StubOutWithMock(clients, 'datetime')
   clients.channel.create_channel(mox.IsA(str))
   clients.channel.send_message(mox.IsA(str), '[{"id": "foo"}, {"id": "bar"}]')
   self.mox.ReplayAll()
   
   (id, token) = clients.add_client('http://example.com/feed')
   clients.send_filtered_messages(id, 'http://example.com/feed',
                                  [{'id': 'foo'}, {'id': 'bar'}])
   self.mox.UnsetStubs()
   self.mox.VerifyAll()
Ejemplo n.º 4
0
  def get(self):
    hostname = app_identity.get_default_version_hostname()
    pshb_client.subscribe(TOPIC_URL, 'http://' + hostname + '/subcb',
                          'http://www.pubsubhubbub.com',
                          'tokentokentoken')
    if (not self.request.get('nt')) and ('token' in self.request.cookies):
      token = self.request.cookies['token']
    else:
      (cid, token) = clients.add_client(TOPIC_URL)
      logging.warning('Created client: %s' % cid)
      expiration = (datetime.utcnow() + clients.TOKEN_EXPIRATION).strftime("%a, %d %b %Y %H:%M:%S GMT")
      self.response.headers.add_header('Set-Cookie', 'token=%s; expires=%s' % (token, expiration))
      self.response.headers.add_header('Set-Cookie', 'cid=%s; expires=%s' % (cid, expiration))
      logging.warning('Created token: %s, expires %s' % (token, expiration))

    if self.request.get('mock'):
      initial_messages = Messages().get_mock_messages()
    else:
      initial_messages = Messages().get_initial_messages()

    if not initial_messages:
      initial_messages = '[]'
    path = os.path.join(os.path.dirname(__file__), 'index.html')
    self.response.out.write(template.render(path, {'token': token, 'initial_messages': initial_messages}));
Ejemplo n.º 5
0
 def test_add_client_no_feed(self):
   try:
     clients.add_client()
     self.fail('add_client with no feed should fail.')
   except:
     """Expected behavior."""