Ejemplo n.º 1
0
    def test_updates_thread_created_by_when_new_comment_comes_before_previous(self):
        now = datetime.datetime.now()
        later = now + datetime.timedelta(days=5)
        comment1 = self._comment(id=1, user_id=1, created_at=later)
        comment2 = self._comment(id=2, user_id=2, created_at=now)
        dao.save_to_thread(comment1)
        dao.save_to_thread(comment2)

        self.assertEqual(len(dao.get_user_threads(1)), 0)
        self.assertEqual(len(dao.get_user_threads(2)), 1)
Ejemplo n.º 2
0
    def test_get_user_threads_returns_only_threads_initiated_by_given_user(self):
        now = datetime.datetime.now()
        later = now + datetime.timedelta(days=5)
        comment1 = self._comment(id=1, user_id=1, created_at=now)
        comment2 = self._comment(id=2, user_id=2, created_at=later)
        dao.save_to_thread(comment1)
        dao.save_to_thread(comment2)

        self.assertEqual(len(dao.get_user_threads(1)), 1)
        self.assertEqual(len(dao.get_user_threads(2)), 0)
Ejemplo n.º 3
0
    def test_updates_thread_created_by_when_new_comment_comes_before_previous(
            self):
        now = datetime.datetime.now()
        later = now + datetime.timedelta(days=5)
        comment1 = self._comment(id=1, user_id=1, created_at=later)
        comment2 = self._comment(id=2, user_id=2, created_at=now)
        dao.save_to_thread(comment1)
        dao.save_to_thread(comment2)

        self.assertEqual(len(dao.get_user_threads(1)), 0)
        self.assertEqual(len(dao.get_user_threads(2)), 1)
Ejemplo n.º 4
0
    def test_get_user_threads_returns_only_threads_initiated_by_given_user(
            self):
        now = datetime.datetime.now()
        later = now + datetime.timedelta(days=5)
        comment1 = self._comment(id=1, user_id=1, created_at=now)
        comment2 = self._comment(id=2, user_id=2, created_at=later)
        dao.save_to_thread(comment1)
        dao.save_to_thread(comment2)

        self.assertEqual(len(dao.get_user_threads(1)), 1)
        self.assertEqual(len(dao.get_user_threads(2)), 0)
Ejemplo n.º 5
0
    def test_get_user_threads_returns_not_read_when_thread_was_read_by_other_user(self):
        comment1 = self._comment(user_id=1)
        object_id = dao.save_to_thread(comment1)['upserted']
        dao.mark_thread_as_read(2, str(object_id))

        thread = dao.get_user_threads(1)[0]
        self.assertFalse(thread['read'])
Ejemplo n.º 6
0
    def test_get_user_threads_returns_read_when_thread_was_read_by_user(self):
        comment1 = self._comment(user_id=1)
        object_id = dao.save_to_thread(comment1)['upserted']
        dao.mark_thread_as_read(1, str(object_id))

        thread = dao.get_user_threads(1)[0]
        self.assertTrue(thread['read'])
Ejemplo n.º 7
0
    def test_get_user_threads_returns_not_read_when_thread_was_not_read_by_user(self):
        dao.save_to_thread(self._comment(user_id=1))

        thread = dao.get_user_threads(1)[0]
        self.assertFalse(thread['read'])
Ejemplo n.º 8
0
    def test_get_user_threads_returns_not_read_when_thread_was_not_read_by_user(
            self):
        dao.save_to_thread(self._comment(user_id=1))

        thread = dao.get_user_threads(1)[0]
        self.assertFalse(thread['read'])
Ejemplo n.º 9
0
def my_threads():
    return jsonify(dao.get_user_threads(session['github_user_id']))
Ejemplo n.º 10
0
def my_threads():
    return jsonify(dao.get_user_threads(session['github_user_id']))