Esempio n. 1
0
  def test_create_new_already_exists(self):
    long_ago = datetime.datetime(year=1901, month=2, day=3)
    props = {
      'created': long_ago,
      'last_webmention_sent': long_ago + datetime.timedelta(days=1),
      'last_polled': long_ago + datetime.timedelta(days=2),
      'last_hfeed_fetch': long_ago + datetime.timedelta(days=3),
      'last_syndication_url': long_ago + datetime.timedelta(days=4),
      'superfeedr_secret': 'asdfqwert',
      }
    FakeSource.new(None, features=['listen'], **props).put()
    self.assert_equals(['listen'], FakeSource.query().get().features)

    FakeSource.string_id_counter -= 1
    auth_entity = testutil.FakeAuthEntity(
      id='x', user_json=json.dumps({'url': 'http://foo.com/'}))
    auth_entity.put()
    self._test_create_new(auth_entity=auth_entity, features=['publish'])

    source = FakeSource.query().get()
    self.assert_equals(['listen', 'publish'], source.features)
    for prop, value in props.items():
      self.assert_equals(value, getattr(source, prop), prop)

    self.assert_equals(
      {"Updated fake (FakeSource). Try previewing a post from your web site!"},
      self.handler.messages)

    task_params = testutil.get_task_params(self.taskqueue_stub.GetTasks('poll')[0])
    self.assertEqual('1901-02-05-00-00-00', task_params['last_polled'])
Esempio n. 2
0
    def test_create_new_already_exists(self):
        long_ago = datetime.datetime(year=1901, month=2, day=3)
        props = {
            'created': long_ago,
            'last_webmention_sent': long_ago + datetime.timedelta(days=1),
            'last_polled': long_ago + datetime.timedelta(days=2),
            'last_hfeed_refetch': long_ago + datetime.timedelta(days=3),
            'last_syndication_url': long_ago + datetime.timedelta(days=4),
            'superfeedr_secret': 'asdfqwert',
        }
        FakeSource.new(None, features=['listen'], **props).put()
        self.assert_equals(['listen'], FakeSource.query().get().features)

        FakeSource.string_id_counter -= 1
        auth_entity = testutil.FakeAuthEntity(id='x',
                                              user_json=json.dumps(
                                                  {'url': 'http://foo.com/'}))
        auth_entity.put()
        self._test_create_new(auth_entity=auth_entity, features=['publish'])

        source = FakeSource.query().get()
        self.assert_equals(['listen', 'publish'], source.features)
        for prop, value in props.items():
            self.assert_equals(value, getattr(source, prop), prop)

        self.assert_equals(
            {
                "Updated fake (FakeSource). Try previewing a post from your web site!"
            }, self.handler.messages)

        task_params = testutil.get_task_params(
            self.taskqueue_stub.GetTasks('poll')[0])
        self.assertEqual('1901-02-05-00-00-00', task_params['last_polled'])
Esempio n. 3
0
  def _test_create_new(self, **kwargs):
    FakeSource.create_new(self.handler, domains=['foo'],
                          domain_urls=['http://foo.com'],
                          webmention_endpoint='http://x/y',
                          **kwargs)
    self.assertEqual(1, FakeSource.query().count())

    tasks = self.taskqueue_stub.GetTasks('poll')
    self.assertEqual(1, len(tasks))
    source = FakeSource.query().get()
    self.assertEqual('/_ah/queue/poll', tasks[0]['url'])
    self.assertEqual(source.key.urlsafe(),
                     testutil.get_task_params(tasks[0])['source_key'])
Esempio n. 4
0
  def _test_create_new(self, **kwargs):
    FakeSource.create_new(self.handler, domains=['foo'],
                          domain_urls=['http://foo.com'],
                          webmention_endpoint='http://x/y',
                          **kwargs)
    self.assertEqual(1, FakeSource.query().count())

    tasks = self.taskqueue_stub.GetTasks('poll')
    self.assertEqual(1, len(tasks))
    source = FakeSource.query().get()
    self.assertEqual('/_ah/queue/poll', tasks[0]['url'])
    self.assertEqual(source.key.urlsafe(),
                     testutil.get_task_params(tasks[0])['source_key'])
    self.assertEqual('fake (FakeSource)', source.label())
Esempio n. 5
0
  def test_create_new(self):
    self.assertEqual(0, FakeSource.query().count())
    self._test_create_new(features=['listen'])
    msg = "Added fake (FakeSource). Refresh to see what we've found!"
    self.assert_equals({msg}, self.handler.messages)

    task_params = testutil.get_task_params(self.taskqueue_stub.GetTasks('poll')[0])
    self.assertEqual('1970-01-01-00-00-00', task_params['last_polled'])
Esempio n. 6
0
  def test_create_new(self):
    self.assertEqual(0, FakeSource.query().count())
    self._test_create_new(features=['listen'])
    msg = "Added fake (FakeSource). Refresh in a minute to see what we've found!"
    self.assert_equals({msg}, self.handler.messages)

    for queue in 'poll', 'poll-now':
      task_params = testutil.get_task_params(self.taskqueue_stub.GetTasks(queue)[0])
      self.assertEqual('1970-01-01-00-00-00', task_params['last_polled'])