Exemplo n.º 1
0
 def setUp(self):
     super(UsersTests, self).setUp()
     self._mox = mox.Mox()
     self._other = DATA
     self._me = {
         'username': '******',
         'password': '******',
         'email': '*****@*****.**',
     }
     User.create(**self._me)
     User.create(**self._other)
     Blocked.create(self._me['username'], self._other['username'])
     self._mox.StubOutWithMock(APIHandler,
                               'get_current_user', use_mock_anything=True)
     APIHandler.get_current_user().AndReturn(self._me['username'])
     self._mox.ReplayAll()
Exemplo n.º 2
0
 def test_unblock_one(self):
     r = self.delete(self._path.format(self._other['username']))
     self.assertEqual(r.code, 200)
     self.assertDictEqual(json.loads(r.body), {'status': 1})
     exists = Blocked.get_by_user_blocked(
         self._me['username'], self._other['username'])
     self.assertIsNone(exists)
     self._mox.VerifyAll()
Exemplo n.º 3
0
Arquivo: users.py Projeto: damnever/2L
 def get(self):
     username = self.current_user
     users = yield gen.maybe_future(Blocked.list_blocked(username))
     blockeds = list()
     if users:
         ids = [user.blocked_id for user in users]
         users = yield gen.maybe_future(User.get_multi(*ids))
         blockeds = [user.information() for user in users]
     raise gen.Return({
         'blockeds': blockeds,
         'total': len(blockeds),
     })
Exemplo n.º 4
0
Arquivo: users.py Projeto: damnever/2L
    def get(self, username):
        user = yield gen.maybe_future(User.get_by_name(username))
        if user is None:
            raise exceptions.UsernameDoesNotExists()
        else:
            info = user.information()
            followed, blocked = False, False

            if self.current_user != username:
                me = yield gen.maybe_future(User.get_by_name(self.current_user))
                followed = yield gen.maybe_future(
                    Following.followed(me.id, user.id))
                blocked = yield gen.maybe_future(
                    Blocked.blocked(me.id, user.id))

            info.update({'followed': followed, 'blocked': blocked})
            raise gen.Return(info)
Exemplo n.º 5
0
Arquivo: users.py Projeto: damnever/2L
 def delete(self, username):
     me = self.current_user
     r = yield gen.maybe_future(Blocked.get_by_user_blocked(me, username))
     yield gen.maybe_future(r.delete())
Exemplo n.º 6
0
Arquivo: users.py Projeto: damnever/2L
 def post(self, username):
     me = self.current_user
     yield gen.maybe_future(Blocked.create(me, username))