mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Added unit tests for faction. (To be completed)
This commit is contained in:
parent
e1572c09ff
commit
3d8c2d689e
1
.gitignore
vendored
1
.gitignore
vendored
@ -8,7 +8,6 @@ logs.txt
|
||||
dist/**
|
||||
a.py
|
||||
resources/tools/a.miz
|
||||
tests/**
|
||||
# User-specific stuff
|
||||
.idea/
|
||||
|
||||
|
||||
0
tests/resources/invalid_faction.json
Normal file
0
tests/resources/invalid_faction.json
Normal file
86
tests/resources/valid_faction.json
Normal file
86
tests/resources/valid_faction.json
Normal file
@ -0,0 +1,86 @@
|
||||
{
|
||||
"country": "USA",
|
||||
"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": {},
|
||||
"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"
|
||||
}
|
||||
35
tests/test_factions.py
Normal file
35
tests/test_factions.py
Normal file
@ -0,0 +1,35 @@
|
||||
import json
|
||||
import unittest
|
||||
|
||||
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 game.factions.faction import Faction
|
||||
|
||||
|
||||
class TestFactionLoader(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def test_load_valid_faction(self):
|
||||
with open("./resources/valid_faction.json", 'r') as data:
|
||||
faction = Faction.from_json(json.load(data))
|
||||
|
||||
self.assertEqual(faction.country, "USA")
|
||||
self.assertEqual(faction.name, "USA 2005")
|
||||
self.assertEqual(faction.authors, "Khopa")
|
||||
self.assertEqual(faction.description, "This is a test description")
|
||||
|
||||
self.assertIn(F_15C, faction.aircrafts)
|
||||
self.assertIn(F_15E, faction.aircrafts)
|
||||
self.assertIn(F_14B, faction.aircrafts)
|
||||
self.assertIn(FA_18C_hornet, faction.aircrafts)
|
||||
self.assertIn(F_16C_50, faction.aircrafts)
|
||||
self.assertIn(A_10A, faction.aircrafts)
|
||||
self.assertIn(AV8BNA, faction.aircrafts)
|
||||
self.assertIn(UH_1H, faction.aircrafts)
|
||||
self.assertIn(AH_64A, faction.aircrafts)
|
||||
self.assertIn(B_52H, faction.aircrafts)
|
||||
self.assertIn(B_1B, faction.aircrafts)
|
||||
self.assertIn(F_117A, faction.aircrafts)
|
||||
Loading…
x
Reference in New Issue
Block a user