Esempio n. 1
0
File: tests.py Progetto: hnb2/ideas
    def test_get_latest_ideas(self):
        '''
        Testing the method get_latest_ideas
        '''

        # Retrieving all the ideas
        ideas = IdeaService.get_latest_ideas(10)
        self.assertEqual(len(ideas), 2)

        # Make sure it contains only the desired fields
        idea = ideas[0]
        self.assertIn('id', idea)
        self.assertIn('title', idea)
        self.assertIn('user__first_name', idea)
        self.assertIn('created_date', idea)
        self.assertIn('excerpt', idea)
        self.assertIn('votes', idea)

        # Make sure it is sorted by created date DESC
        self.assertGreater(
            ideas[0]['created_date'],
            ideas[1]['created_date']
        )

        # Using None
        ideas = IdeaService.get_latest_ideas(None)
        self.assertEqual(len(ideas), 2)
Esempio n. 2
0
    def test_get_latest_ideas(self):
        '''
        Testing the method get_latest_ideas
        '''

        # Retrieving all the ideas
        ideas = IdeaService.get_latest_ideas(10)
        self.assertEqual(len(ideas), 2)

        # Make sure it contains only the desired fields
        idea = ideas[0]
        self.assertIn('id', idea)
        self.assertIn('title', idea)
        self.assertIn('user__first_name', idea)
        self.assertIn('created_date', idea)
        self.assertIn('excerpt', idea)
        self.assertIn('votes', idea)

        # Make sure it is sorted by created date DESC
        self.assertGreater(ideas[0]['created_date'], ideas[1]['created_date'])

        # Using None
        ideas = IdeaService.get_latest_ideas(None)
        self.assertEqual(len(ideas), 2)
Esempio n. 3
0
File: index.py Progetto: hnb2/ideas
 def get_queryset(self):
     '''
     Return a dictionnary of fields, it will not be objects.
     '''
     return IdeaService.get_latest_ideas(8)
Esempio n. 4
0
 def get_queryset(self):
     '''
     Return a dictionnary of fields, it will not be objects.
     '''
     return IdeaService.get_latest_ideas(8)