Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardoughton committed Sep 7, 2020
1 parent b80cee0 commit 43f0de5
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 50 deletions.
Binary file added tests/calculation_validation/demand.xlsx
Binary file not shown.
18 changes: 10 additions & 8 deletions tests/test_assess.py
Expand Up @@ -4,15 +4,16 @@
assess, estimate_subsidies, allocate_available_excess)



def test_get_administration_cost(setup_region, setup_country_parameters):
def test_get_administration_cost(setup_region, setup_country_parameters,
setup_global_parameters, setup_timesteps):

setup_region[0]['network_cost'] = 100
setup_timesteps = list(range(2020, 2030 + 1))

answer = get_administration_cost(setup_region[0], setup_country_parameters)
answer = get_administration_cost(setup_region[0], setup_country_parameters,
setup_global_parameters, setup_timesteps)

answer['administration'] = (setup_region[0]['network_cost']
* (setup_country_parameters['financials']['administration_percentage_of_network_cost']) / 100)
assert round(answer['administration']) == 174


def test_get_spectrum_costs(setup_region, setup_option, setup_global_parameters, setup_country_parameters):
Expand Down Expand Up @@ -149,7 +150,8 @@ def test_estimate_subsidies():
assert available_cross_subsidy == 0


def test_assess(setup_option, setup_global_parameters, setup_country_parameters, setup_costs):
def test_assess(setup_option, setup_global_parameters, setup_country_parameters,
setup_timesteps, setup_costs):

regions = [
{
Expand All @@ -176,7 +178,7 @@ def test_assess(setup_option, setup_global_parameters, setup_country_parameters,
setup_country_parameters['financials']['spectrum_capacity_baseline_usd_mhz_pop'] = 0.025

answer = assess('MWI', regions, setup_option, setup_global_parameters,
setup_country_parameters, setup_costs)
setup_country_parameters, setup_timesteps, setup_costs)

assert answer[0]['total_revenue'] == 20000
assert answer[0]['network_cost'] == 5000
Expand Down Expand Up @@ -220,7 +222,7 @@ def test_assess(setup_option, setup_global_parameters, setup_country_parameters,
]

answer = assess('MWI', regions, setup_option, setup_global_parameters,
setup_country_parameters, setup_costs)
setup_country_parameters, setup_timesteps, setup_costs)

assert answer[0]['available_cross_subsidy'] == 8420.0
assert answer[0]['used_cross_subsidy'] == 0
Expand Down
76 changes: 34 additions & 42 deletions tests/test_demand.py
Expand Up @@ -13,7 +13,7 @@ def test_estimate_demand(
setup_penetration_lut
):

answer = estimate_demand(
answer, annual_answer = estimate_demand(
setup_region,
setup_option,
setup_global_parameters,
Expand Down Expand Up @@ -59,7 +59,7 @@ def test_estimate_demand(
smartphones_on_network * 50 / 100 / 2
)

answer = estimate_demand(
answer, annual_answer = estimate_demand(
setup_region_rural,
setup_option_high,
setup_global_parameters,
Expand All @@ -75,9 +75,16 @@ def test_estimate_demand(
assert round(answer[0]['total_revenue']) == round(5000 * 15 / 3)

setup_region[0]['geotype'] = 'rural'
setup_region[0]['mean_luminosity_km2'] = 2
setup_option['strategy'] = '4G_epc_microwave_baseline_shared_baseline_baseline'
setup_country_parameters['arpu']['medium'] = 7

answer = estimate_demand(
setup_timesteps = list(range(2020, 2030 + 1))
setup_penetration_lut = {}
for i in setup_timesteps:
setup_penetration_lut[i] = 50

answer, annual_answer = estimate_demand(
setup_region,
setup_option,
setup_global_parameters,
Expand All @@ -97,45 +104,30 @@ def test_estimate_demand(
# = 5000 phones
assert round(answer[0]['phones_on_network']) == round(5000)

# # 5000 phones
# # 1 network
# # 50% smartphones
# # = 833 smartphones
# smartphones_on_network = round(5000 * (50 / 100))
# assert round(answer[0]['smartphones_on_network']) == smartphones_on_network

# # 5000 phones
# # arpu = 15
# assert round(answer[0]['total_revenue']) == round(15 * 5000)

# # 5000 phones
# # arpu = 15
# # area = 2
# assert round(answer[0]['revenue_km2']) == round((15 * 5000) / 2)

# # 2500 smartphones
# # scenario = 50
# # overbooking factor = 100
# # area = 2
# # demand_mbps_km2 = 125

# assert round(answer[0]['demand_mbps_km2']) == round(
# (smartphones_on_network * 50 / 100 / 2)
# )

# answer = estimate_demand(
# setup_region_rural,
# setup_option_high,
# setup_global_parameters,
# setup_country_parameters,
# setup_timesteps,
# setup_penetration_lut,
# {'rural': {'smartphone': 0.5}}
# )

# # 5000 phones on network
# # arpu = 15
# assert round(answer[0]['total_revenue']) == round(5000 * 15)
# 5000 phones
# 1 network
# 50% smartphones
# = 833 smartphones
smartphones_on_network = round(5000 * (50 / 100))
assert round(answer[0]['smartphones_on_network']) == smartphones_on_network

# 5000 phones
# arpu = 7
# discounted arpur over 10 years @ 5% = 242
#[35000.0, 33333.33333333333, 31746.031746031746, 30234.31594860166,
# 28794.586617715864, 27423.41582639606, 26117.538882281962, 24873.846554554246,
# 23689.377671004044, 22561.312067622897, 21486.963873926572]
assert round(answer[0]['total_revenue']) == round(305261)

# 2500 smartphones
# scenario = 50
# overbooking factor = 100
# area = 2
# demand_mbps_km2 = 125
#sum [625.0, 625.0, 625.0, 625.0, 625.0, 625.0, 625.0, 625.0, 625.0, 625.0, 625.0] / 11
assert round(answer[0]['demand_mbps_km2']) == round(
((smartphones_on_network * 50 / 100 / 2) * 11) / 11
)


def test_get_per_user_capacity():
Expand Down

0 comments on commit 43f0de5

Please sign in to comment.