Esempio n. 1
0
class MineViewTest(GaeTestCase):
    EMAIL = '*****@*****.**'

    def setUp(self):
        GaeTestCase.setUp(self)
        self.mine_view = MineView()
        self.login(MineViewTest.EMAIL)
        text1 = Text(text='text1', approvals=[])
        text1.updated_at = datetime.datetime(2013, 1, 1, 0, 0, 0, 0)
        text1.put()
        Text(text='text2', approvals=[]).put()

        self.login('other' + MineViewTest.EMAIL)
        Text(text='text3', approvals=[]).put()

    def test_get(self):
        self.login(MineViewTest.EMAIL)

        result = self.mine_view.get(None)
        self.assertEqual(result.status_code, 200)
        content = json.loads(result.content)
        self.assertEqual(len(content), 2)
        self.assertEqual(content[0]['text'], 'text2')
        self.assertEqual(content[1]['text'], 'text1')

        self.logout()
        result = self.mine_view.get(None)
        self.assertEqual(result.status_code, 200)
        content = json.loads(result.content)
        self.assertEqual(len(content), 0)
Esempio n. 2
0
    def setUp(self):
        GaeTestCase.setUp(self)
        self.mine_view = MineView()
        self.login(MineViewTest.EMAIL)
        text1 = Text(text='text1', approvals=[])
        text1.updated_at = datetime.datetime(2013, 1, 1, 0, 0, 0, 0)
        text1.put()
        Text(text='text2', approvals=[]).put()

        self.login('other' + MineViewTest.EMAIL)
        Text(text='text3', approvals=[]).put()