def client(): file_path = find_dotenv('.env.test') load_dotenv(file_path, override=True) test_app = create_app() with test_app.test_client() as client: yield client
def client(): file_path = find_dotenv('.env.test') load_dotenv(file_path, override = True) test_app = create_app() test_app.config['LOGIN_DISABLED'] = True with test_app.test_client() as client: yield client
def app_with_temp_board(): # Create the new board & update the board id environment variable file_path = find_dotenv('.env') load_dotenv(file_path, override=True) board_id = create_trello_board() os.environ['TRELLO_BOARD_ID'] = board_id # list_id = create_trello_list(board_id) # create_trello_card(list_id) todolist_id = getToDoListid(board_id) os.environ['TODO_LISTID'] = todolist_id donelist_id = getDoneListid(board_id) os.environ['DONE_LISTID'] = donelist_id doinglist_id = getDoingListid(board_id) os.environ['DOING_LISTID'] = doinglist_id # create_trello_card(todolist_id) # construct the new application application = app.create_app() # start the app in its own thread. thread = Thread(target=lambda: application.run(use_reloader=False)) thread.daemon = True thread.start() yield application # Tear Down thread.join(1) delete_trello_board(board_id)
def app_with_temp_board(): file_path = find_dotenv('.env') load_dotenv(file_path, override=True) # Create the new board & update the board id environment variable board_id = create_trello_board() os.environ['TRELLO_BOARD_ID'] = board_id lists = trello_client.get_lists_for_board() todo_list = [list for list in lists if list["name"] == "To Do"][0] done_list = [list for list in lists if list["name"] == "Done"][0] os.environ['TRELLO_TODO_LIST_ID'] = todo_list["id"] os.environ['TRELLO_DONE_LIST_ID'] = done_list["id"] # construct the new application application = app.create_app() # start the app in its own thread. thread = Thread(target=lambda: application.run(use_reloader=False)) thread.daemon = True thread.start() time.sleep(5) yield app # Tear Down thread.join(1) delete_trello_board(board_id)
def client(): # Use our test integration config instead of the "real" version file_path = find_dotenv('.env.test') load_dotenv(file_path, override=True) # CosmosDB secrets: cosmos_database_name = os.getenv('DATABASE_NAME') cosmos_url = os.getenv("COSMOS_URL") cosmos_port = os.getenv("COSMOS_PORT") cosmos_connection_string = os.getenv('COSMOS_CONNECTION_STRING') # Mongomock with mongomock.patch(servers=((f'{cosmos_database_name}.{cosmos_url}', int(cosmos_port)), )): # Create the new app. test_app = create_app() test_app.config['LOGIN_DISABLED'] = True # Connect to CosmosDB using mongo api: mclient = pymongo.MongoClient(cosmos_connection_string) # Add fake items to mongomock db = mclient.testboard insert_document('Test item 1', 'to do', db) insert_document('Test item 2', 'doing', db) insert_document('Test item 3', 'done', db) # Use the app to create a test_client that can be used in our tests. with test_app.test_client() as client: yield client
def client(): load_dotenv('.env.test', override=True) os.environ["disable_login"] = '******' with mongomock.patch(servers=(("test.mongo.cosmos.azure.com", 10255), )): test_app = app.create_app() with test_app.test_client() as client: yield client
def client(): # Use our test integration config instead of the 'real' version file_path = dotenv.find_dotenv('.env.test') dotenv.load_dotenv(file_path, override=True) # Create the new app. taskDb = TasksDb() taskDb.get_all_tasks = MagicMock() taskDb.get_all_tasks.return_value = [ Task(id='604fabbef6dcb41ee250c4b6', status='To Do', title='TestTask', last_modified='2021-04-04 18:50:33.252000'), Task(id='604fac79f6dcb41ee250c4b9', status='To Do', title='TestTask2', last_modified='2021-04-04 18:50:33.252000') ] test_app = app.create_app(taskDb) # Use the app to create a test_client that can be used in our tests. with test_app.test_client() as client: yield client
def test_app(): # Create the new board & update the board id environment variable file_path = find_dotenv('.env') load_dotenv(file_path, override=True) os.environ['FLASK_SKIP_LOGIN'] = "******" os.environ['MONGO_DB'] = "test_db" mongo_srv = os.getenv('MONGO_SRV') mongo_user = os.getenv('MONGO_USER') mongo_pwd = os.getenv('MONGO_PWD') mongo_connection = os.getenv('MONGO_CONNECTION') testClient = ToDoMongoClient(mongo_user, mongo_pwd, mongo_srv, "test_db", mongo_connection) admin_user = testClient.add_user("admin_user", "Admin") writer_user = testClient.add_user("writer_user", "Writer") reader_user = testClient.add_user("reader_user", "Reader") application = create_app() # start the app in its own thread. thread = Thread(target=lambda: application.run(use_reloader=False)) thread.daemon = True thread.start() yield application # Tear Down thread.join(1) testClient.delete_user(admin_user.id) testClient.delete_user(writer_user.id) testClient.delete_user(reader_user.id)
def setUp(self): options = webdriver.ChromeOptions() options.add_argument("no-sandbox") options.add_argument("--disable-gpu") options.add_argument("--disable-dev-shm-usage") options.add_argument("--headless") self._driver = webdriver.Chrome( ChromeDriverManager(chrome_type=ChromeType.GOOGLE).install(), options=options) self._driver.implicitly_wait(5) file_path = find_dotenv('.env') load_dotenv(file_path, override=True) board_id = self.create_trello_board() os.environ['BOARD_ID'] = board_id self._board_id = board_id lists = list(get_lists()) os.environ['TODO_LIST_ID'] = lists[0] os.environ['IN_PROGRESS_LIST_ID'] = lists[1] os.environ['DONE_LIST_ID'] = lists[2] application = create_app() self._thread = Thread( target=lambda: application.run(use_reloader=False)) self._thread.daemon = True self._thread.start()
def client(): # Use our test integration config instead of the 'real' version file_path = find_dotenv('.env.test') load_dotenv(file_path, override=True) # Create the new app. test_app = app.create_app() with test_app.test_client() as client: yield client
def client(): file_path = find_dotenv('.env.test') load_dotenv(file_path, override=True) with mongomock.patch(servers=(('fakemongo.com', 27017), )): test_app = app.create_app() with test_app.test_client() as client: setup_testdata() yield client
def client(): if os.environ.get('FLASK_APP') == None: file_path = find_dotenv('.env.test') load_dotenv(file_path, override=True) test_app = create_app() with test_app.test_client() as client: yield client
def client(): # Use our test integration config instead of the 'real' version file_path = dotenv.find_dotenv('.env.test') dotenv.load_dotenv(file_path, override=True) # Create the new app. test_app = create_app() # Use the app to create a test_client that can be used in our tests. yield test_app
def client(): file_path = find_dotenv('.env.test') load_dotenv(file_path, override=True) with patch('requests.get') as mock_get_requests: mock_get_requests.side_effect = mock_get_lists test_app = app.create_app() yield test_app.test_client()
def client(): # Use our test integration config instead of the 'real' version file_path = find_dotenv(".env.test") load_dotenv(file_path, override=True) # Create the new app. test_app = app.create_app() # Use the app to create a test_client that can be used in our tests. with test_app.test_client() as client: yield client
def client(): # Use our test integration config instead of the 'real' version file_path = find_dotenv('.env.test') load_dotenv(file_path, override=True) with mongomock.patch(servers=(('server.example.com', 27017),)): test_app = app.create_app() with test_app.test_client() as client: yield client
def app_with_temp_database(): application = create_app() thread = Thread(target=lambda: application.run(use_reloader=False)) thread.daemon = True thread.start() yield application thread.join(1) mongo_db_client = pymongo.MongoClient( os.getenv('DATABASE_CONNECTION_STRING')) mongo_db_client.drop_database(str([os.getenv('DATABASE_NAME')]))
def client(): with mongomock.patch(servers=('mongodb://example:27017/', )): # Use our test integration config instead of the 'real' version file_path = find_dotenv('../.env.test') load_dotenv(file_path, override=True) # Create the new app. test_app = app.create_app() test_app.config['LOGIN_DISABLED'] = True # Use the app to create a test_client that can be used in our tests. with test_app.test_client() as client: yield client
def client(): file_path = find_dotenv('.env.test') load_dotenv(file_path, override=True) from todo_app import app # Create the new app test_app = app.create_app() #use the app to create test client that can be used in our tests with test_app.test_client() as client: yield client
def client(): # Use our test integration config instead of the 'real' version file_path = find_dotenv('.env.test') load_dotenv(file_path, override=True) with mongomock.patch(servers=(('fakemongo.com', 27017), )): prepare_test_data() test_app = app.create_app() test_app.config['LOGIN_DISABLED'] = True with test_app.test_client() as client: yield client
def client(): try: file_path = find_dotenv('.env.test') load_dotenv(file_path, override=True) except: pass with mongomock.patch(servers=(('fakemongo.com', 27017), )): test_app = create_app() with test_app.test_client() as client: yield client
def client(): file_path = find_dotenv('.env.test') load_dotenv(file_path, override=True) # Create the new app test_app = app.create_app() # Use the app to create a test_client with test_app.test_client() as client: yield client
def app_client(): # Use our test integration config instead of the 'real' version file_path = find_dotenv('.env.test') load_dotenv(file_path, override=True) # Initialise mongomock here. with mongomock.patch(servers=(('fakemongo', 27017), )): # Create the new app. test_app = app.create_app() # Use the app to create a test_client that can be used in our tests. with test_app.test_client() as client: yield client
def app_with_temp_data(): # Create the new board & update the board id environment variable os.environ['DBNAME'] = "E2E_Test_DB" os.environ['LOGIN_DISABLED'] = 'True' # construct the new application application = app.create_app() # start the app in its own thread. thread = Thread(target=lambda: application.run(use_reloader=False)) thread.daemon = True thread.start() yield application
def test_app(driver): file_path = find_dotenv('.env') load_dotenv(file_path, override=True) # Create the new board & update the board id environment variable service = Trello_service() service.initiate() board_id = os.environ['TRELLO_BOARD_ID'] # construct the new application application = app.create_app() # start the app in its own thread. thread = Thread(target=lambda: application.run(use_reloader=False)) thread.daemon = True thread.start() yield app
def app_with_temp_board(): boards = get_board() board_id = boards.create_trello_board(os.environ.get('TRELLO_WORKSPACE_ID')) os.environ['TRELLO_BOARD_ID'] = board_id # construct the new application application = app.create_app() # start the app in its own thread. thread = Thread(target=lambda: application.run(use_reloader=False)) thread.daemon = True thread.start() wait_for_up() yield application # Tear Down thread.join(1) boards.delete_trello_board(board_id)
def test_app(): with mongomock.patch(servers=('mongodb://example:27017/', )): file_path = find_dotenv('../.env.test') load_dotenv(file_path, override=True) # construct the new application application = app.create_app() application.config['LOGIN_DISABLED'] = True # start the app in its own thread. thread = Thread(target=lambda: application.run(use_reloader=False)) thread.daemon = True thread.start() yield app # Tear Down thread.join(1) print('Completed tests')
def client(): # Use our test integration config instead of the 'real' version try: file_path = find_dotenv('.env.test') load_dotenv(file_path, override=True) except OSError: print(".env file not found") # Create the new app. with mongomock.patch(servers=(('fakemongo.com', 27017),)): test_app = app.create_app() # Use the app to create a test_client that can be used in our tests. with test_app.test_client() as client: setup_test_data() yield client
def app_with_temp_db(): file_path = find_dotenv('.env') load_dotenv(file_path, override=True) # CosmosDB secrets: # Construct the new application app = create_app() app.config['LOGIN_DISABLED'] = True # start the app in its own thread thread = Thread(target=lambda:app.run(use_reloader=False)) thread.daemon = True thread.start() yield app #Tear Down thread.join(1)
def app_with_temp_board(): file_path = find_dotenv('.env') load_dotenv(file_path, override=True) # Create the new board & update the board id environment variable board_id = create_trello_board() # construct the new application application = app.create_app() # start the app in its own thread. thread = Thread(target=lambda: application.run(use_reloader=False)) thread.daemon = True thread.start() yield app # Tear Down thread.join(1) delete_trello_board()