-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1036 from IntersectMBO/chore/fix-backend-tests
Fix/Add tests for missing APIs
- Loading branch information
Showing
17 changed files
with
449 additions
and
105 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 |
---|---|---|
@@ -1,7 +1,8 @@ | ||
BASE_URL = `URL where the api is hosted` | ||
BASE_URL = "https://govtool.cardanoapi.io/api" | ||
RECORD_METRICS_API = `URL where metrics is posted` | ||
METRICS_API_SECRET= `api_secret` | ||
|
||
# required for setup | ||
KUBER_API_URL = "" | ||
KUBER_API_KEY = "" | ||
KUBER_API_URL = "https://kuber-govtool.cardanoapi.io" | ||
KUBER_API_KEY = "" # optional | ||
FAUCET_API_KEY= """ |
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
Empty file.
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,41 @@ | ||
import os | ||
from typing import TypedDict | ||
|
||
import requests | ||
|
||
|
||
class FaucetAmount(TypedDict): | ||
lovelace: int | ||
|
||
|
||
class Transaction(TypedDict): | ||
amount: FaucetAmount | ||
txid: str | ||
txin: str | ||
|
||
|
||
class CardanoFaucet: | ||
def __init__(self, api_key: str, base_url: str = "https://faucet.sanchonet.world.dev.cardano.org"): | ||
self.api_key = api_key | ||
self.base_url = base_url | ||
|
||
@staticmethod | ||
def from_env(): | ||
api_key = os.getenv("FAUCET_API_KEY") | ||
base_url = os.getenv("FAUCET_API_URL", "https://faucet.sanchonet.world.dev.cardano.org") | ||
if not api_key: | ||
raise ValueError("FAUCET_API_KEY environment variable not set.") | ||
return CardanoFaucet(api_key, base_url) | ||
|
||
def send_money(self, address: str, tx_type: str = "default") -> Transaction: | ||
endpoint = f"{self.base_url}/send-money" | ||
params = {"address": address, "api_key": self.api_key, "type": tx_type} | ||
response = requests.get(endpoint, params=params) | ||
|
||
if response.status_code == 200: | ||
return response.json() | ||
else: | ||
response.raise_for_status() | ||
|
||
|
||
"" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from test_cases.fixtures import * |
Oops, something went wrong.