-
Notifications
You must be signed in to change notification settings - Fork 11
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
9b81159
commit 5db96d0
Showing
4 changed files
with
49 additions
and
149 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
This file was deleted.
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 |
---|---|---|
@@ -1,8 +1,47 @@ | ||
import pytest | ||
from core.components.parameters import Parameters | ||
from core.model.budget import Budget | ||
from core.model.economic_model_legacy import EconomicModelLegacy | ||
from core.model.economic_model_legacy import ( | ||
Coefficients, | ||
EconomicModelLegacy, | ||
Equation, | ||
Equations, | ||
) | ||
|
||
|
||
def test_init_class(): | ||
pass | ||
@pytest.fixture | ||
def model(): | ||
model = EconomicModelLegacy( | ||
Equations( | ||
Equation("a * x", "l <= x <= c"), | ||
Equation("a * c + (x - c) ** (1 / b)", "x > c"), | ||
), | ||
Coefficients(1, 2, 3, 1), | ||
1, | ||
20.0, | ||
) | ||
model.budget = Budget(1200, 1, 1) | ||
model.budget.ticket_price = 0.1 | ||
|
||
return model | ||
|
||
|
||
def test_transformed_stake(model: EconomicModelLegacy): | ||
assert model.transformed_stake(0) == 0 | ||
assert model.transformed_stake(model.coefficients.l) == model.coefficients.l | ||
assert model.transformed_stake(model.coefficients.c) == model.coefficients.c | ||
assert model.transformed_stake(model.coefficients.c * 2) < ( | ||
model.coefficients.c * 2 | ||
) | ||
|
||
|
||
def test_message_count_for_reward(model: EconomicModelLegacy): | ||
assert model.message_count_for_reward(0) == 0, "No reward for 0 stake" | ||
assert model.message_count_for_reward(model.coefficients.l) == round( | ||
model.coefficients.l * model.apr / model.budget.ticket_price / 12 | ||
), "Linear result if stake is minimum" | ||
assert model.message_count_for_reward(model.coefficients.c) == round( | ||
model.coefficients.c * model.apr / model.budget.ticket_price / 12 | ||
), "Linear result if stake is at threshold" | ||
assert model.message_count_for_reward(model.coefficients.c * 2) < round( | ||
(model.coefficients.c + 2) * model.apr / model.budget.ticket_price / 12 | ||
), "Non-linear result if stake is above threshold" |