Exemplo n.º 1
0
    def test_main_no_env_set(self):
        """
        Assert that correct user data are dumped when nothing is provided.
        """
        user = models.User(
            email='*****@*****.**',
            username='******',
            active=True,
        )
        user_social_auth = social_models.UserSocialAuth(user_id=user.id,
                                                        user=user)

        self.session.add(user_social_auth)
        self.session.add(user)

        user2 = models.User(
            email='*****@*****.**',
            username='******',
            active=True,
        )
        user_social_auth = social_models.UserSocialAuth(user_id=user2.id,
                                                        user=user2)

        self.session.add(user_social_auth)
        self.session.add(user2)
        self.session.commit()

        sar.main()

        out, err = self.capsys.readouterr()

        self.assertEqual('[]', out)
Exemplo n.º 2
0
    def test_main_username(self):
        """
        Assert that correct user data are dumped when providing
        username.
        """
        user = models.User(email="*****@*****.**",
                           username="******",
                           active=True)

        self.session.add(user)

        user2 = models.User(email="*****@*****.**",
                            username="******",
                            active=True)

        self.session.add(user2)
        self.session.commit()

        exp = [{
            "id": str(user.id),
            "username": user.username,
            "email": user.email,
            "active": user.active,
            "user_social_auths": [],
        }]

        sar.main()

        out, err = self.capsys.readouterr()

        obs = json.loads(out)

        self.assertEqual(exp, obs)
Exemplo n.º 3
0
    def test_main_username(self):
        """
        Assert that correct user data are dumped when providing
        username.
        """
        user = models.User(email="*****@*****.**", username="******", active=True)
        user_social_auth = social_models.UserSocialAuth(user_id=user.id, user=user)

        self.session.add(user_social_auth)
        self.session.add(user)

        user2 = models.User(email="*****@*****.**", username="******", active=True)
        user_social_auth = social_models.UserSocialAuth(user_id=user2.id, user=user2)

        self.session.add(user_social_auth)
        self.session.add(user2)
        self.session.commit()

        exp = [
            {
                "id": str(user.id),
                "username": user.username,
                "email": user.email,
                "active": user.active,
                "social_auth": [{"uid": None, "provider": None, "extra_data": None}],
            }
        ]

        sar.main()

        out, err = self.capsys.readouterr()

        obs = json.loads(out)

        self.assertEqual(exp, obs)
Exemplo n.º 4
0
    def test_main_email(self):
        """
        Assert that correct user data are dumped when providing
        e-mail.
        """
        user = models.User(email="*****@*****.**", username="******", active=True)
        user_social_auth = social_models.UserSocialAuth(user_id=user.id, user=user)

        self.session.add(user_social_auth)
        self.session.add(user)

        user2 = models.User(email="*****@*****.**", username="******", active=True)
        user_social_auth = social_models.UserSocialAuth(user_id=user2.id, user=user2)

        self.session.add(user_social_auth)
        self.session.add(user2)
        self.session.commit()

        exp = [
            {
                "id": str(user.id),
                "username": user.username,
                "email": user.email,
                "active": user.active,
                "social_auth": [{"uid": None, "provider": None, "extra_data": None}],
            }
        ]

        sar.main()

        out, err = self.capsys.readouterr()

        obs = json.loads(out)

        self.assertEqual(exp, obs)
Exemplo n.º 5
0
    def test_main_username(self):
        """
        Assert that correct user data are dumped when providing
        username.
        """
        user = models.User(
            email='*****@*****.**',
            username='******',
            active=True,
        )
        user_social_auth = social_models.UserSocialAuth(user_id=user.id,
                                                        user=user)

        self.session.add(user_social_auth)
        self.session.add(user)

        user2 = models.User(
            email='*****@*****.**',
            username='******',
            active=True,
        )
        user_social_auth = social_models.UserSocialAuth(user_id=user2.id,
                                                        user=user2)

        self.session.add(user_social_auth)
        self.session.add(user2)
        self.session.commit()

        exp = [{
            'id':
            str(user.id),
            'username':
            user.username,
            'email':
            user.email,
            'active':
            user.active,
            'social_auth': [{
                'uid': None,
                'provider': None,
                'extra_data': None
            }]
        }]

        sar.main()

        out, err = self.capsys.readouterr()

        obs = json.loads(out)

        self.assertEqual(exp, obs)
Exemplo n.º 6
0
    def test_main_no_env_set(self):
        """
        Assert that correct user data are dumped when nothing is provided.
        """
        user = models.User(email="*****@*****.**",
                           username="******",
                           active=True)

        self.session.add(user)

        user2 = models.User(email="*****@*****.**",
                            username="******",
                            active=True)

        self.session.add(user2)
        self.session.commit()

        sar.main()

        out, err = self.capsys.readouterr()

        self.assertEqual("[]", out)
Exemplo n.º 7
0
    def test_main_no_env_set(self):
        """
        Assert that correct user data are dumped when nothing is provided.
        """
        user = models.User(email="*****@*****.**", username="******", active=True)
        user_social_auth = social_models.UserSocialAuth(user_id=user.id, user=user)

        self.session.add(user_social_auth)
        self.session.add(user)

        user2 = models.User(email="*****@*****.**", username="******", active=True)
        user_social_auth = social_models.UserSocialAuth(user_id=user2.id, user=user2)

        self.session.add(user_social_auth)
        self.session.add(user2)
        self.session.commit()

        sar.main()

        out, err = self.capsys.readouterr()

        self.assertEqual("[]", out)