Exemple #1
0
class MigratableTest(testutil.HandlerTest):

  def setUp(self):
    super(MigratableTest, self).setUp()
    self.post = Migratable(key_name='tag:xyz', vars=json.dumps(POST_VARS))
    appengine_config.USER_KEY_HANDLER_SECRET = 'my_secret'

  def test_get_or_save(self):
    self.assertEqual(0, Migratable.all().count())
    self.assertEqual(0, len(self.taskqueue_stub.GetTasks('propagate')))

    # new. should add a propagate task.
    saved = self.post.get_or_save()
    self.assertTrue(saved.is_saved())
    self.assertEqual(self.post.key(), saved.key())

    tasks = self.taskqueue_stub.GetTasks('propagate')
    self.assertEqual(1, len(tasks))
    self.assertEqual(str(self.post.key()),
                     testutil.get_task_params(tasks[0])['post_key'])
    self.assertEqual('/_ah/queue/propagate', tasks[0]['url'])

    # existing. no new task.
    same = saved.get_or_save()
    self.assertEqual(1, len(tasks))

  def test_envelope(self):
    self.expect_urlfetch('https://facebook-webfinger.appspot.com/user_key'
                         '?uri=acct:[email protected]&secret=my_secret',
                         json.dumps(USER_KEY_JSON))
    self.mox.ReplayAll()

    envelope = self.post.envelope('acct:[email protected]')\
        .replace('>', '>\n').replace('</', '\n</')
    self.assert_multiline_equals(ENVELOPE_XML, envelope)

  def test_send_slap(self):
    pass
Exemple #2
0
  def test_get_or_save(self):
    self.assertEqual(0, Migratable.all().count())
    self.assertEqual(0, len(self.taskqueue_stub.GetTasks('propagate')))

    # new. should add a propagate task.
    saved = self.post.get_or_save()
    self.assertTrue(saved.is_saved())
    self.assertEqual(self.post.key(), saved.key())

    tasks = self.taskqueue_stub.GetTasks('propagate')
    self.assertEqual(1, len(tasks))
    self.assertEqual(str(self.post.key()),
                     testutil.get_task_params(tasks[0])['post_key'])
    self.assertEqual('/_ah/queue/propagate', tasks[0]['url'])

    # existing. no new task.
    same = saved.get_or_save()
    self.assertEqual(1, len(tasks))
Exemple #3
0
 def setUp(self):
   super(MigratableTest, self).setUp()
   self.post = Migratable(key_name='tag:xyz', vars=json.dumps(POST_VARS))
   appengine_config.USER_KEY_HANDLER_SECRET = 'my_secret'