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)
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)
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)
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)
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)
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)
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)