コード例 #1
0
  def test_add_quote(self):
    """
    Add and remove quotes from the system.
    """
    user = users.User('*****@*****.**')
    quoteid = models.add_quote('This is a test.', user)
    time.sleep(1.1)
    quoteid2 = models.add_quote('This is a test2.', user)
    self.assertNotEqual(quoteid, None)
    self.assertNotEqual(quoteid, 0)
    
    # Get the added quotes by creation order
    quotes, next = models.get_quotes_newest()
    self.assertEqual(quotes[0].key().id(), quoteid2)
    self.assertEqual(models.get_quote(quoteid2).key().id(), quoteid2)

    self.assertEqual(len(quotes), 2)
    
    # Remove one quote
    models.del_quote(quoteid2, user)

    quotes, next = models.get_quotes_newest()
    self.assertEqual(quotes[0].key().id(), quoteid)
    self.assertEqual(len(quotes), 1)
    

    # Remove last remaining quote    
    models.del_quote(quoteid, user)
    quotes, next = models.get_quotes_newest()
    self.assertEqual(len(quotes), 0)
コード例 #2
0
    def test_add_quote(self):
        """
    Add and remove quotes from the system.
    """
        user = users.User('*****@*****.**')
        quoteid = models.add_quote('This is a test.', user)
        time.sleep(1.1)
        quoteid2 = models.add_quote('This is a test2.', user)
        self.assertNotEqual(quoteid, None)
        self.assertNotEqual(quoteid, 0)

        # Get the added quotes by creation order
        quotes, next = models.get_quotes_newest()
        self.assertEqual(quotes[0].key().id(), quoteid2)
        self.assertEqual(models.get_quote(quoteid2).key().id(), quoteid2)

        self.assertEqual(len(quotes), 2)

        # Remove one quote
        models.del_quote(quoteid2, user)

        quotes, next = models.get_quotes_newest()
        self.assertEqual(quotes[0].key().id(), quoteid)
        self.assertEqual(len(quotes), 1)

        # Remove last remaining quote
        models.del_quote(quoteid, user)
        quotes, next = models.get_quotes_newest()
        self.assertEqual(len(quotes), 0)
コード例 #3
0
ファイル: main.py プロジェクト: rakeshviyak/rajinination
  def get(self, quoteid):
    """Get a page for just the quote identified."""
    quote = models.get_quote(long(quoteid))
    if quote == None:
      self.response.set_status(404, 'Not Found')
      return      
    user = users.get_current_user()
    quotes = [quote]

    template_values = create_template_dict(user, quotes, 'Quote', nexturi=None, prevuri=None, page=0)
    template_file = os.path.join(os.path.dirname(__file__), 'templates/singlequote.html')
    self.response.out.write(template.render(template_file, template_values))
コード例 #4
0
  def get(self, quoteid):
    """Get a page for just the quote identified."""
    quote = models.get_quote(long(quoteid))
    if quote == None:
      self.response.set_status(404, 'Not Found')
      return      
    user = users.get_current_user()
    quotes = [quote]

    template_values = create_template_dict(user, quotes, 'Quote', nexturi=None, prevuri=None, page=0)
    template_file = os.path.join(os.path.dirname(__file__), 'templates/singlequote.html')
    self.response.out.write(template.render(template_file, template_values))