mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Completed basic faction parameters loading test.
This commit is contained in:
parent
93f0627c5e
commit
ec7f8f5710
86
tests/resources/invalid_faction_country.json
Normal file
86
tests/resources/invalid_faction_country.json
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
{
|
||||||
|
"country": "C",
|
||||||
|
"name": "USA 2005",
|
||||||
|
"authors": "Khopa",
|
||||||
|
"description": "This is a test description",
|
||||||
|
"aircrafts": [
|
||||||
|
"F_15C",
|
||||||
|
"F_15E",
|
||||||
|
"F_14B",
|
||||||
|
"FA_18C_hornet",
|
||||||
|
"F_16C_50",
|
||||||
|
"A_10A",
|
||||||
|
"AV8BNA",
|
||||||
|
"UH_1H",
|
||||||
|
"AH_64A",
|
||||||
|
"B_52H",
|
||||||
|
"B_1B",
|
||||||
|
"F_117A"
|
||||||
|
],
|
||||||
|
"awacs": [
|
||||||
|
"E_3A"
|
||||||
|
],
|
||||||
|
"tankers": [
|
||||||
|
"KC_135",
|
||||||
|
"KC130"
|
||||||
|
],
|
||||||
|
"frontline_units": [
|
||||||
|
"MBT_M1A2_Abrams",
|
||||||
|
"ATGM_M1134_Stryker",
|
||||||
|
"APC_M1126_Stryker_ICV",
|
||||||
|
"IFV_M2A2_Bradley",
|
||||||
|
"IFV_LAV_25",
|
||||||
|
"APC_M1043_HMMWV_Armament",
|
||||||
|
"ATGM_M1045_HMMWV_TOW"
|
||||||
|
],
|
||||||
|
"artillery_units": [
|
||||||
|
"MLRS_M270",
|
||||||
|
"SPH_M109_Paladin"
|
||||||
|
],
|
||||||
|
"logistics_units": [
|
||||||
|
"Transport_M818"
|
||||||
|
],
|
||||||
|
"infantry_units": [
|
||||||
|
"Infantry_M4",
|
||||||
|
"Soldier_M249"
|
||||||
|
],
|
||||||
|
"shorads": [
|
||||||
|
"AvengerGenerator"
|
||||||
|
],
|
||||||
|
"sams": [
|
||||||
|
"HawkGenerator"
|
||||||
|
],
|
||||||
|
"aircraft_carrier": [
|
||||||
|
"CVN_74_John_C__Stennis"
|
||||||
|
],
|
||||||
|
"helicopter_carrier": [
|
||||||
|
"LHA_1_Tarawa"
|
||||||
|
],
|
||||||
|
"destroyers": [
|
||||||
|
"Oliver_Hazzard_Perry_class",
|
||||||
|
"USS_Arleigh_Burke_IIa"
|
||||||
|
],
|
||||||
|
"cruisers": [
|
||||||
|
"Ticonderoga_class"
|
||||||
|
],
|
||||||
|
"requirements": {"mod": "Some mod is required"},
|
||||||
|
"carrier_names": [
|
||||||
|
"CVN-71 Theodore Roosevelt",
|
||||||
|
"CVN-72 Abraham Lincoln",
|
||||||
|
"CVN-73 George Washington",
|
||||||
|
"CVN-74 John C. Stennis"
|
||||||
|
],
|
||||||
|
"helicopter_carrier_names": [
|
||||||
|
"LHA-1 Tarawa",
|
||||||
|
"LHA-2 Saipan",
|
||||||
|
"LHA-3 Belleau Wood",
|
||||||
|
"LHA-4 Nassau",
|
||||||
|
"LHA-5 Peleliu"
|
||||||
|
],
|
||||||
|
"navy_generators": [
|
||||||
|
"OliverHazardPerryGroupGenerator",
|
||||||
|
"ArleighBurkeGroupGenerator"
|
||||||
|
],
|
||||||
|
"has_jtac": true,
|
||||||
|
"jtac_unit": "MQ_9_Reaper"
|
||||||
|
}
|
||||||
@ -63,7 +63,7 @@
|
|||||||
"cruisers": [
|
"cruisers": [
|
||||||
"Ticonderoga_class"
|
"Ticonderoga_class"
|
||||||
],
|
],
|
||||||
"requirements": {},
|
"requirements": {"mod": "Some mod is required"},
|
||||||
"carrier_names": [
|
"carrier_names": [
|
||||||
"CVN-71 Theodore Roosevelt",
|
"CVN-71 Theodore Roosevelt",
|
||||||
"CVN-72 Abraham Lincoln",
|
"CVN-72 Abraham Lincoln",
|
||||||
|
|||||||
@ -2,7 +2,11 @@ import json
|
|||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from dcs.helicopters import UH_1H, AH_64A
|
from dcs.helicopters import UH_1H, AH_64A
|
||||||
from dcs.planes import F_15C, F_15E, F_14B, FA_18C_hornet, F_16C_50, A_10A, AV8BNA, B_52H, B_1B, F_117A
|
from dcs.planes import F_15C, F_15E, F_14B, FA_18C_hornet, F_16C_50, A_10A, AV8BNA, B_52H, B_1B, F_117A, MQ_9_Reaper, \
|
||||||
|
E_3A, KC130, KC_135
|
||||||
|
from dcs.ships import CVN_74_John_C__Stennis, LHA_1_Tarawa, Oliver_Hazzard_Perry_class, USS_Arleigh_Burke_IIa, \
|
||||||
|
Ticonderoga_class
|
||||||
|
from dcs.vehicles import Armor, Unarmed, Infantry, Artillery, AirDefence
|
||||||
|
|
||||||
from game.factions.faction import Faction
|
from game.factions.faction import Faction
|
||||||
|
|
||||||
@ -33,3 +37,57 @@ class TestFactionLoader(unittest.TestCase):
|
|||||||
self.assertIn(B_52H, faction.aircrafts)
|
self.assertIn(B_52H, faction.aircrafts)
|
||||||
self.assertIn(B_1B, faction.aircrafts)
|
self.assertIn(B_1B, faction.aircrafts)
|
||||||
self.assertIn(F_117A, faction.aircrafts)
|
self.assertIn(F_117A, faction.aircrafts)
|
||||||
|
|
||||||
|
self.assertEqual(len(faction.awacs), 1)
|
||||||
|
self.assertIn(E_3A, faction.awacs)
|
||||||
|
|
||||||
|
self.assertEqual(len(faction.tankers), 2)
|
||||||
|
self.assertIn(KC_135, faction.tankers)
|
||||||
|
self.assertIn(KC130, faction.tankers)
|
||||||
|
|
||||||
|
self.assertTrue(faction.has_jtac)
|
||||||
|
self.assertEqual(faction.jtac_unit, MQ_9_Reaper)
|
||||||
|
|
||||||
|
self.assertIn(Armor.MBT_M1A2_Abrams, faction.frontline_units)
|
||||||
|
self.assertIn(Armor.ATGM_M1134_Stryker, faction.frontline_units)
|
||||||
|
self.assertIn(Armor.APC_M1126_Stryker_ICV, faction.frontline_units)
|
||||||
|
self.assertIn(Armor.IFV_M2A2_Bradley, faction.frontline_units)
|
||||||
|
self.assertIn(Armor.IFV_LAV_25, faction.frontline_units)
|
||||||
|
self.assertIn(Armor.APC_M1043_HMMWV_Armament, faction.frontline_units)
|
||||||
|
self.assertIn(Armor.ATGM_M1045_HMMWV_TOW, faction.frontline_units)
|
||||||
|
|
||||||
|
self.assertIn(Artillery.MLRS_M270, faction.artillery_units)
|
||||||
|
self.assertIn(Artillery.SPH_M109_Paladin, faction.artillery_units)
|
||||||
|
|
||||||
|
self.assertIn(Unarmed.Transport_M818, faction.logistics_units)
|
||||||
|
|
||||||
|
self.assertIn(Infantry.Infantry_M4, faction.infantry_units)
|
||||||
|
self.assertIn(Infantry.Soldier_M249, faction.infantry_units)
|
||||||
|
|
||||||
|
self.assertIn("AvengerGenerator", faction.shorads)
|
||||||
|
|
||||||
|
self.assertIn("HawkGenerator", faction.sams)
|
||||||
|
|
||||||
|
self.assertIn(CVN_74_John_C__Stennis, faction.aircraft_carrier)
|
||||||
|
self.assertIn(LHA_1_Tarawa, faction.helicopter_carrier)
|
||||||
|
self.assertIn(Oliver_Hazzard_Perry_class, faction.destroyers)
|
||||||
|
self.assertIn(USS_Arleigh_Burke_IIa, faction.destroyers)
|
||||||
|
self.assertIn(Ticonderoga_class, faction.cruisers)
|
||||||
|
|
||||||
|
self.assertIn("mod", faction.requirements.keys())
|
||||||
|
self.assertIn("Some mod is required", faction.requirements.values())
|
||||||
|
|
||||||
|
self.assertEqual(4, len(faction.carrier_names))
|
||||||
|
self.assertEqual(5, len(faction.helicopter_carrier_names))
|
||||||
|
|
||||||
|
self.assertIn("OliverHazardPerryGroupGenerator", faction.navy_generators)
|
||||||
|
self.assertIn("ArleighBurkeGroupGenerator", faction.navy_generators)
|
||||||
|
|
||||||
|
def test_load_valid_faction_with_invalid_country(self):
|
||||||
|
|
||||||
|
with open("./resources/invalid_faction_country.json", 'r') as data:
|
||||||
|
try:
|
||||||
|
Faction.from_json(json.load(data))
|
||||||
|
self.fail("Should have thrown assertion error")
|
||||||
|
except AssertionError as e:
|
||||||
|
pass
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user