-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
077cb30
commit 2537a26
Showing
11 changed files
with
82 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -210,7 +210,17 @@ def create_session(host: str, username: str, password: str, csrf: str = "") -> o | |
|
||
|
||
@pytest.fixture(scope="session") | ||
def driver() -> Chrome: | ||
def download_path(worker_id: str) -> str: | ||
try: | ||
worker_id = worker_id | ||
assert worker_id is not None | ||
yield f"{settings.DOWNLOAD_DIRECTORY}/{worker_id}" | ||
except BaseException: | ||
yield settings.DOWNLOAD_DIRECTORY | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def driver(download_path: str) -> Chrome: | ||
chrome_options = Options() | ||
chrome_options.add_argument("--headless") | ||
chrome_options.add_argument("--no-sandbox") | ||
|
@@ -222,15 +232,19 @@ def driver() -> Chrome: | |
chrome_options.add_argument("--window-size=1920,1080") | ||
chrome_options.add_argument("--disable-dev-shm-usage") | ||
try: | ||
os.makedirs(settings.DOWNLOAD_DIRECTORY) | ||
os.makedirs(download_path) | ||
except FileExistsError: | ||
pass | ||
prefs = { | ||
"download.default_directory": settings.DOWNLOAD_DIRECTORY, | ||
"download.default_directory": download_path, | ||
} | ||
chrome_options.add_experimental_option("prefs", prefs) | ||
driver = webdriver.Chrome(options=chrome_options) | ||
yield driver | ||
# try: | ||
# shutil.rmtree(download_path) | ||
# except FileNotFoundError: | ||
# pass | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
|
@@ -514,6 +528,15 @@ def business_area() -> BusinessArea: | |
yield business_area | ||
|
||
|
||
@pytest.fixture | ||
def clear_downloaded_files(download_path: str) -> None: | ||
for file in os.listdir(download_path): | ||
os.remove(os.path.join(download_path, file)) | ||
yield | ||
for file in os.listdir(download_path): | ||
os.remove(os.path.join(download_path, file)) | ||
|
||
|
||
@pytest.fixture | ||
def change_super_user(business_area: BusinessArea) -> None: | ||
user = User.objects.filter(email="[email protected]").first() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.