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_account(self): account_response = AccountProcessor.add_account("paypal", "testAdmin") assert account_response assert account_response["_id"] == 3 assert account_response["name"] == "paypal" account_response = AccountProcessor.add_account("ebay", "testAdmin") assert account_response assert account_response["_id"] == 4 assert account_response["name"] == "ebay"
def test_add_account(self): account_response = AccountProcessor.add_account("paypal", "testAdmin") account = AccountProcessor.get_account(account_response["_id"]) assert account_response assert account_response["_id"] == account["_id"] assert account_response["name"] == account["name"] account_response = AccountProcessor.add_account("ebay", "testAdmin") account = AccountProcessor.get_account(account_response["_id"]) assert account_response assert account_response["_id"] == account["_id"] assert account_response["name"] == account["name"]
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_none_account(self): with pytest.raises(ValidationError): AccountProcessor.add_account(None, "testAdmin")
def test_add_empty_account(self): with pytest.raises(ValidationError): AccountProcessor.add_account(" ", "testAdmin")
def test_add_duplicate_account(self): with pytest.raises(Exception): AccountProcessor.add_account("paypal", "testAdmin")
def test_add_blank_account(self): with pytest.raises(AssertionError): AccountProcessor.add_account("", "testAdmin")
def test_add_duplicate_account_case_insentive(self): with pytest.raises(Exception): AccountProcessor.add_account("PayPal", "testAdmin")