def add_user(): Utility.load_evironment() connect(Utility.environment["mongo_db"], host=Utility.environment["mongo_url"]) account = AccountProcessor.add_account("integration", "testAdmin") bot = AccountProcessor.add_bot("integration", account["_id"], "testAdmin") AccountProcessor.add_user( email="*****@*****.**", first_name="Demo", last_name="User", password="******", account=account["_id"], bot=bot["name"], user="******", ) account = AccountProcessor.add_account("integration2", "testAdmin") bot = AccountProcessor.add_bot("integration2", account["_id"], "testAdmin") AccountProcessor.add_user( email="*****@*****.**", first_name="Demo", last_name="User", password="******", account=account["_id"], bot=bot["name"], user="******", )
def test_add_user_duplicate(self): with pytest.raises(Exception): AccountProcessor.add_user( email="*****@*****.**", first_name="Fahad Ali", last_name="Shaikh", password="******", account=1, bot="test", user="******", )
def test_add_user_None_password(self): with pytest.raises(ValidationError): AccountProcessor.add_user( email="*****@*****.**", first_name="Fahad Ali", last_name="Shaikh", password=None, account=1, bot="test", user="******", )
def test_add_user_blank_lastname(self): with pytest.raises(ValidationError): AccountProcessor.add_user( email="*****@*****.**", first_name="Fahad Ali", last_name=" ", password="******", account=1, bot="test", user="******", )
def test_add_user_empty_firstname(self): with pytest.raises(Exception): AccountProcessor.add_user( email="*****@*****.**", first_name="", last_name="Shaikh", password="******", account=1, bot="test", user="******", )
def test_add_user_none_email(self): with pytest.raises(Exception): AccountProcessor.add_user( email=None, first_name="Fahad Ali", last_name="Shaikh", password="******", account=1, bot="test", user="******", )
def test_add_user_empty_email(self): with pytest.raises(ValidationError): AccountProcessor.add_user( email="", first_name="Fahad Ali", last_name="Shaikh", password="******", account=1, bot="test", user="******", )
def test_add_user_none_firstname(self): with pytest.raises(ValidationError): AccountProcessor.add_user( email="*****@*****.**", first_name="", last_name="Shaikh", password="******", account=1, bot=pytest.bot, user="******", )
def test_add_user_invalid_email(self): with pytest.raises(Exception): AccountProcessor.add_user( email="demo", first_name="Fahad Ali", last_name="Shaikh", password="******", account=1, bot=pytest.bot, user="******", )
def test_add_user_blank_password(self): with pytest.raises(AssertionError): AccountProcessor.add_user( email="*****@*****.**", first_name="Fahad Ali", last_name="Shaikh", password="******", account=1, bot=pytest.bot, user="******", )
def test_add_user_none_lastname(self): with pytest.raises(AssertionError): AccountProcessor.add_user( email="*****@*****.**", first_name="Fahad Ali", last_name=None, password="******", account=1, bot=pytest.bot, user="******", )
def test_add_user_empty_firstname(self): with pytest.raises(AssertionError): AccountProcessor.add_user( email="*****@*****.**", first_name="", last_name="Shaikh", password="******", account=1, bot=pytest.bot, user="******", )
def test_add_user_invalid_email(self): with pytest.raises(AssertionError): AccountProcessor.add_user( email="demo", first_name="Fahad Ali", last_name="Shaikh", password="******", account=1, bot=pytest.bot, user="******", )
def test_add_user_duplicate_case_insensitive(self): with pytest.raises(Exception): AccountProcessor.add_user( email="*****@*****.**", first_name="Fahad Ali", last_name="Shaikh", password="******", account=1, bot=pytest.bot, user="******", )
def test_get_user_details_user_inactive(self): account = AccountProcessor.add_account("paytm", "testAdmin") bot = AccountProcessor.add_bot("support", account["_id"], "testAdmin") user = AccountProcessor.add_user( email="*****@*****.**", first_name="Demo", last_name="User", password="******", account=account["_id"], bot=bot["name"], user="******", ) user_details = AccountProcessor.get_user_details(user["email"]) assert all(user_details[key] == False if key == "is_integration_user" else user_details[key] for key in user_details.keys()) user_details = User.objects().get(id=user["_id"]) user_details.status = False user_details.save() with pytest.raises(Exception): user_details = AccountProcessor.get_user_details( user_details["email"]) assert all(user_details[key] == False if key == "is_integration_user" else user_details[key] for key in user_details.keys()) user_details.status = True user_details.save()
def test_add_user(self): user = AccountProcessor.add_user( email="*****@*****.**", first_name="Fahad Ali", last_name="Shaikh", password="******", account=1, bot="test", user="******", ) assert user assert user["password"] != "12345" assert user["status"]