Пример #1
0
    def test_get_group_members(self):
        user = self._sample_user()
        group = self._sample_group(user)

        with self.app_context:
            Group.remove(group.id)
            User.remove(user.id)

            user.save()
            group.save()

            ret = []

            for friend_id in group.users:
                friend = User.get_by_id(friend_id)
                ret.extend([{
                    'friend_id': friend_id,
                    'name': friend.email,
                    'location': friend.location
                }])

            self.assertGreater(len(ret), 0)

            Group.remove(group.id)
            User.remove(user.id)
Пример #2
0
    def test_update_user_location(self):
        user = self._sample_user()

        with self.app_context:
            user.save()

            User.update_location(user.id, 57.062, 13.673)

            user_test = User.get_by_id(user.id)
            self.assertEqual(user_test.location[0], 57.062)
            self.assertEqual(user_test.location[1], 13.673)
            User.remove(user.id)
Пример #3
0
    def test_register_user(self):
        with self.app_context:
            user = User.register(email="*****@*****.**", password="******")

            user.save()

            user_test = User.get_by_id(user.id)
            self.assertIsNotNone(user_test.access_token)
            self.assertEqual(user.email, "*****@*****.**")
            self.assertTrue(check_password_hash(user.password, "paco"))

            User.remove(user.id)
Пример #4
0
    def test_activate_email_invite(self):
        inviter = self._sample_user()
        invite = Invite.create("*****@*****.**", inviter.id)

        with self.app_context:
            invite.save()
            Invite.activate(invite.token, "pass")
            user = User.get_by_email(invite.email)
            self.assertIsNotNone(user)
            self.assertEqual(user.email, invite.email)
            User.remove(user.id)
            Group.remove_member(invite.inviter_id, user.id)
Пример #5
0
    def test_add_member_to_group(self):
        user = self._sample_user()
        group = self._sample_group(user)

        with self.app_context:
            Group.remove(group.id)
            User.remove(user.id)

            user.save()
            group.save()

            Group.add_member(group.id, "1234")

            group_test = Group.get_by_id(group.id)

            Group.remove(group.id)
            User.remove(user.id)

            self.assertTrue("1234" in group_test.users)
Пример #6
0
 def test_save_user(self):
     user = self._sample_user()
     with self.app_context:
         user.save()
         User.remove(user.id)