-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add environment-based configuration using ENV variable for different …
…environments (test, staging, production) To set env before run $env:ENV="test" # On PowerShell (Windows) export ENV=test # On Linux/macOS
- Loading branch information
Showing
5 changed files
with
52 additions
and
4 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
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import yaml | ||
import os | ||
|
||
|
||
class Config: | ||
# Set the default environment (can be overridden) | ||
ENV = os.getenv('ENV', 'test') # Default to 'test' if not specified | ||
|
||
with open("config/config.yaml", "r") as file: | ||
config = yaml.safe_load(file) | ||
|
||
# Dynamically select the environment | ||
BASE_URL = config[ENV]["base_url"] | ||
USERNAME = config[ENV]["username"] | ||
PASSWORD = config[ENV]["password"] |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
test: | ||
base_url: "https://rahulshettyacademy.com/loginpagePractise/" | ||
username: "rahulshettyacademy" | ||
password: "learning" | ||
|
||
staging: | ||
base_url: " https://rahulshettyacademy.com/" | ||
username: "staginguser" | ||
password: "stagingpassword" | ||
|
||
production: | ||
base_url: "https://www.example.com" | ||
username: "produser" | ||
password: "prodpassword" |
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 |
---|---|---|
@@ -1,3 +1,12 @@ | ||
2024-11-17 13:28:41,304 - INFO - url opened successfully | ||
2024-11-17 13:31:45,047 - INFO - url opened successfully | ||
2024-11-17 13:31:45,172 - INFO - username and password set successfully | ||
2024-11-17 14:13:53,035 - INFO - url opened successfully | ||
2024-11-17 14:13:53,166 - INFO - username and password set successfully | ||
2024-11-17 14:14:12,540 - INFO - url opened successfully | ||
2024-11-17 14:14:12,667 - INFO - username and password set successfully | ||
2024-11-17 14:16:00,281 - INFO - https://rahulshettyacademy.com/loginpagePractise/ url opened successfully | ||
2024-11-17 14:16:00,413 - INFO - username and password set successfully | ||
2024-11-17 14:22:02,722 - INFO - https://rahulshettyacademy.com/loginpagePractise/ url opened successfully | ||
2024-11-17 14:22:02,852 - INFO - username and password set successfully | ||
2024-11-17 14:23:55,012 - INFO - https://rahulshettyacademy.com/ url opened successfully |
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