Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Giacomo Licari committed Mar 8, 2024
1 parent 5e1f49d commit 41689be
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 24 deletions.
5 changes: 2 additions & 3 deletions api/api/services/database.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import sqlite3
from datetime import datetime

from flask_sqlalchemy import SQLAlchemy

from api.const import (DEFAULT_ERC20_MAX_AMOUNT_PER_DAY,
DEFAULT_NATIVE_MAX_AMOUNT_PER_DAY, FaucetRequestType)
from flask_sqlalchemy import SQLAlchemy

db = SQLAlchemy()

Expand Down Expand Up @@ -165,7 +164,7 @@ def last_by_ip_or_recipient(cls, ip, recipient):
@classmethod
def get_by_hash(cls, hash):
return cls.query.filter_by(hash=hash).first()

@classmethod
def get_amount_sum_by_access_key_and_token(cls,
access_key_id,
Expand Down
5 changes: 2 additions & 3 deletions api/api/services/validator.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import datetime

from api.const import TokenType
from flask import current_app, request
from web3 import Web3

from api.const import TokenType

from .captcha import captcha_verify
from .database import AccessKeyConfig, Token, Transaction
from .rate_limit import Strategy
Expand Down Expand Up @@ -144,7 +143,7 @@ def web_request_limit_validation(self):
else:
raise NotImplementedError

# Check if the recipient can claim funds, they must not have claimed any tokens
# Check if the recipient can claim funds, they must not have claimed any tokens
# in the period of time defined by FAUCET_RATE_LIMIT_TIME_LIMIT_SECONDS
if transaction:
time_diff_seconds = (datetime.datetime.utcnow() - transaction.created).total_seconds()
Expand Down
1 change: 0 additions & 1 deletion api/api/settings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import json
import os

from dotenv import load_dotenv
Expand Down
4 changes: 2 additions & 2 deletions api/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import os
from unittest import TestCase, mock

from api.services import Strategy
from api.services.database import Token, db
from temp_env_var import FAUCET_ENABLED_TOKENS, TEMP_ENV_VARS

from api import create_app
from api.services import Strategy
from api.services.database import Token, db

api_prefix = '/api/v1'

Expand Down
5 changes: 2 additions & 3 deletions api/tests/test_api.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from api.const import ZERO_ADDRESS
from api.services.database import Transaction
from conftest import BaseTest, api_prefix
# from mock import patch
from temp_env_var import (CAPTCHA_TEST_RESPONSE_TOKEN,
Expand All @@ -7,9 +9,6 @@
NATIVE_TOKEN_ADDRESS, NATIVE_TRANSFER_TX_HASH,
TOKEN_TRANSFER_TX_HASH)

from api.const import ZERO_ADDRESS
from api.services.database import Transaction


class TestAPI(BaseTest):

Expand Down
5 changes: 2 additions & 3 deletions api/tests/test_api_claim_rate_limit.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
from api.const import ZERO_ADDRESS
from api.services.database import Transaction
from conftest import (RateLimitIPBaseTest, RateLimitIPorAddressBaseTest,
api_prefix)
# from mock import patch
from temp_env_var import (CAPTCHA_TEST_RESPONSE_TOKEN,
DEFAULT_ERC20_MAX_AMOUNT_PER_DAY,
ERC20_TOKEN_ADDRESS, FAUCET_CHAIN_ID)

from api.const import ZERO_ADDRESS
from api.services.database import Transaction


class TestAPIWithIPLimitStrategy(RateLimitIPBaseTest):

Expand Down
7 changes: 3 additions & 4 deletions api/tests/test_api_cli.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from api.const import ZERO_ADDRESS
from api.services.database import AccessKey, AccessKeyConfig
from api.utils import generate_access_key
from conftest import BaseTest, api_prefix
# from mock import patch
from temp_env_var import (DEFAULT_ERC20_MAX_AMOUNT_PER_DAY,
ERC20_TOKEN_ADDRESS, FAUCET_CHAIN_ID)

from api.const import ZERO_ADDRESS
from api.services.database import AccessKey, AccessKeyConfig
from api.utils import generate_access_key


class TestAPICli(BaseTest):
def test_ask_route_parameters(self):
Expand Down
8 changes: 3 additions & 5 deletions api/tests/test_database.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import pytest
from sqlalchemy.exc import IntegrityError

from conftest import BaseTest
from temp_env_var import NATIVE_TOKEN_ADDRESS, NATIVE_TRANSFER_TX_HASH

from api.const import ZERO_ADDRESS
from api.services.database import (AccessKey, AccessKeyConfig, Token,
Transaction)
from api.utils import generate_access_key
from conftest import BaseTest
from sqlalchemy.exc import IntegrityError
from temp_env_var import NATIVE_TOKEN_ADDRESS, NATIVE_TRANSFER_TX_HASH


class TestDatabase(BaseTest):
Expand Down

0 comments on commit 41689be

Please sign in to comment.