-
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.
* output to csv and json * added gitignore file * Written test files * Run CI action with secrets
- Loading branch information
1 parent
8a51481
commit 49c73f5
Showing
9 changed files
with
113 additions
and
26 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ requires = ["pdm-backend"] | |
build-backend = "pdm.backend" | ||
|
||
[project] | ||
name = "airdrop-scripts" | ||
name = "dhkdao_airdrop_scripts" | ||
version = "0.1.0" | ||
authors = [ | ||
{ name = "Jimmy Chu", email = "[email protected]" }, | ||
|
@@ -28,6 +28,7 @@ lint = [ | |
] | ||
test = [ | ||
"pytest>=8.3.3", | ||
"python-dotenv>=1.0.1" | ||
] | ||
|
||
[project.urls] | ||
|
@@ -38,8 +39,9 @@ Issues = "https://github.com/dhkdao/airdrop-scripts/issues" | |
distribution = true | ||
|
||
[tool.pdm.scripts] | ||
test = "pytest tests" | ||
test = "pytest --capture=no tests" | ||
"test:ci" = "pytest" | ||
lint = "flake8 src tests" | ||
"lint:write" = "black src tests" | ||
exe = "pdm run src/scripts/main.py" | ||
all = { composite = ["lint", "test"]} | ||
all = { composite = ["lint", "test:ci"]} |
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,4 @@ | ||
from .airdrop import airdrop_monthly_alloc | ||
from .airdrop import Airdrop | ||
from .utils import is_number, round_output | ||
|
||
__all__ = ["airdrop_monthly_alloc"] | ||
__all__ = ["Airdrop", "is_number", "round_output"] |
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 |
---|---|---|
@@ -1,3 +1,70 @@ | ||
class TestClass: | ||
def test(self): | ||
assert True | ||
import json | ||
import os | ||
import pytest | ||
import typer | ||
from dotenv import load_dotenv | ||
from scripts import Airdrop | ||
|
||
|
||
load_dotenv() | ||
|
||
UNKNOWN_TOKEN = "HASH" | ||
KNOWN_TOKEN = "ATOM" | ||
INVALID_CONFIG_FILEPATH = os.path.join( | ||
os.path.dirname(__file__), "../fixtures/config-invalid-1.json" | ||
) | ||
|
||
print("INVALID_CONFIG_FILEPATH", INVALID_CONFIG_FILEPATH) | ||
|
||
|
||
def get_config(): | ||
return json.loads( | ||
"""{ | ||
"dhk_distribution": 100000, | ||
"reference_date": "2024-08-27", | ||
"tokens": [ | ||
{ "token": "AKT", "network": "akash", "qty": 188787 }, | ||
{ "token": "ATOM", "network": "cosmos", "qty": 592015 } | ||
], | ||
"apis": { | ||
"cryptocompare": { | ||
"endpoint": "https://min-api.cryptocompare.com/data/pricehistorical" | ||
}, | ||
"mintscan": { | ||
"endpoint": "https://apis.mintscan.io/v1/:network/apr" | ||
} | ||
} | ||
}""" | ||
) | ||
|
||
|
||
def get_config_with_cryptocompare_apikey_env(): | ||
config = get_config() | ||
config["apis"]["cryptocompare"]["apikey"] = os.getenv("CRYPTOCOMPARE_APIKEY") | ||
return config | ||
|
||
|
||
class TestAirdropClass: | ||
def test_fetch_price_on_unknown_token_should_return_none(self): | ||
config = get_config_with_cryptocompare_apikey_env() | ||
airdrop = Airdrop(config) | ||
price = airdrop.fetch_price(UNKNOWN_TOKEN) | ||
assert price is None | ||
|
||
def test_fetch_price_on_known_token_should_return_value(self): | ||
config = get_config_with_cryptocompare_apikey_env() | ||
airdrop = Airdrop(config) | ||
price = airdrop.fetch_price(KNOWN_TOKEN) | ||
assert isinstance(price, float) | ||
|
||
def test_on_config_missing_key_should_raise_exception(self): | ||
with open(INVALID_CONFIG_FILEPATH, "r") as f: | ||
config = json.loads(f.read()) | ||
|
||
with pytest.raises(typer.Exit) as excinfo: | ||
Airdrop(config) | ||
|
||
assert excinfo.type is typer.Exit | ||
|
||
def test_fetch_staking_apr(self): | ||
pass |