def test_resolve_us_plots(self): app = Labyrinth(1, 1, self.set_up_blank_test_scenario) app.get_country("United States").plots = 1 app.get_country("United States").make_hard() app.resolve_plot("United States", 1, 4, [1, 6, 1], [], [], []) self.assertEqual(app.funding, 9) self.assertEqual(app.get_country("United States").get_posture(), SOFT) self.assertEqual(app.prestige, 6) self.assertEqual(app.get_country("United States").plots, 0) app = Labyrinth(1, 1, self.set_up_blank_test_scenario) app.get_country("United States").plots = 1 app.get_country("United States").make_soft() app.resolve_plot("United States", 2, 4, [5, 6, 1], [], [], []) self.assertEqual(app.funding, 9) self.assertEqual(app.get_country("United States").get_posture(), SOFT) self.assertEqual(app.prestige, 8) self.assertEqual(app.get_country("United States").plots, 0) app = Labyrinth(1, 1, self.set_up_blank_test_scenario) app.get_country("United States").plots = 1 app.get_country("United States").make_soft() app.resolve_plot("United States", 3, 5, [5, 6, 4], [], [], []) self.assertEqual(app.funding, 9) self.assertEqual(app.get_country("United States").get_posture(), HARD) self.assertEqual(app.prestige, 11) self.assertEqual(app.get_country("United States").plots, 0) app = Labyrinth(1, 1, self.set_up_blank_test_scenario) self.assertFalse(app.gameOver) app.get_country("United States").plots = 1 app.get_country("United States").make_soft() app.resolve_plot("United States", "WMD", 0, [], [], [], []) self.assertEqual(app.get_country("United States").plots, 0) self.assertTrue(app.gameOver)
def test_prestige(self): """Prestige""" app = Labyrinth(1, 1, self.set_up_test_scenario) app.prestige = 1 self.assertEqual(app.modified_woi_roll(3, "Gulf States"), 1) app.prestige = 2 self.assertEqual(app.modified_woi_roll(3, "Gulf States"), 1) app.prestige = 3 self.assertEqual(app.modified_woi_roll(3, "Gulf States"), 1) app.prestige = 4 self.assertEqual(app.modified_woi_roll(3, "Gulf States"), 2) app.prestige = 5 self.assertEqual(app.modified_woi_roll(3, "Gulf States"), 2) app.prestige = 6 self.assertEqual(app.modified_woi_roll(3, "Gulf States"), 2) app.prestige = 7 self.assertEqual(app.modified_woi_roll(3, "Gulf States"), 3) app.prestige = 8 self.assertEqual(app.modified_woi_roll(3, "Gulf States"), 3) app.prestige = 9 self.assertEqual(app.modified_woi_roll(3, "Gulf States"), 3) app.prestige = 10 self.assertEqual(app.modified_woi_roll(3, "Gulf States"), 4) app.prestige = 11 self.assertEqual(app.modified_woi_roll(3, "Gulf States"), 4) app.prestige = 12 self.assertEqual(app.modified_woi_roll(3, "Gulf States"), 4)
def test_reassessment(self): app = Labyrinth(1, 1, self.set_up_test_scenario) self.assertEqual(app.us_posture(), HARD) app.toggle_us_posture() self.assertEqual(app.us_posture(), SOFT) app.toggle_us_posture() self.assertEqual(app.us_posture(), HARD)
def test_summary(self): # Set up app = Labyrinth(1, 1, self.set_up_test_scenario) app.play_us_card(116) # 3 ops app.deploy_reserves() # Invoke summary = app.get_summary() # Assert self.assertEqual(summary, [ 'Jihadist Ideology: Normal', '', 'VICTORY', 'Good Resources: 0 Islamist Resources: 1', 'Fair/Good Countries: 3 Poor/Islamist Countries: 4', '', 'GWOT', 'US Posture: Hard World Posture: Hard 1', 'US Prestige: 7', '', 'TROOPS', 'War: 9 troops available', '', 'JIHADIST FUNDING', 'Funding: 5 Cells Available: 11', '', 'EVENTS', 'Markers: None', 'Lapsing: None', '', 'US Reserves: 2' ])
def test_is_adjacent(self): app = Labyrinth(1, 1, self.set_up_blank_test_scenario) self.assertTrue(app.is_adjacent("Iran", "Iraq")) self.assertTrue(app.is_adjacent("Germany", "Spain")) self.assertTrue(app.is_adjacent("Libya", "Italy")) self.assertTrue(app.is_adjacent("Benelux", "Russia")) self.assertTrue(app.is_adjacent("Lebanon", "France")) self.assertFalse(app.is_adjacent("United States", "Lebanon"))
def test_to_good(self): """Going to Good""" app = Labyrinth(1, 1, self.set_up_test_scenario) self.assertEqual(app.modified_woi_roll(3, "Gulf States"), 3) app.get_country("Gulf States").make_poor() self.assertEqual(app.modified_woi_roll(3, "Gulf States"), 4) app.get_country("Gulf States").make_fair() app.get_country("Gulf States").make_neutral() self.assertEqual(app.modified_woi_roll(3, "Gulf States"), 4)
def test_no_countries_have_plots_at_first(self): # Set up app = Labyrinth(1, 1) # Invoke plot_countries = app.get_plot_countries() # Check self.assertEqual([], plot_countries)
def test_iran_with_nothing_in_it(self): # Set up app = Labyrinth(1, 1, self.set_up_blank_test_scenario) iran = app.get_country("Iran") # Invoke summary = iran.summary() # Check self.assertEqual(summary, "Iran, Fair")
def test_is_not_good(self): # Set up app = Labyrinth(1, 1, self.set_up_blank_test_scenario) iran = Iran(app) # Invoke result = iran.is_good() # Check self.assertFalse(result)
def test_is_not_schengen(self): # Set up app = Labyrinth(1, 1, self.set_up_blank_test_scenario) iran = Iran(app) # Invoke schengen = iran.schengen # Check self.assertFalse(schengen)
def _create_game(): """Factory function for a new game""" print "" scenario_number = Utils.choose_option("Choose Scenario", scenario_names()) print "" ideology_number = choose_ideology() print "" ai_rolls = Utils.getUserYesNoResponse( "Do you want the program to roll dice for you?") return Labyrinth(scenario_number, ideology_number, ai_rolls=ai_rolls)
def test_is_fair(self): # Set up app = Labyrinth(1, 1, self.set_up_blank_test_scenario) iran = Iran(app) # Invoke result = iran.is_fair() # Check self.assertTrue(result)
def test_alert_reduces_plot_count_by_one(self): app = Labyrinth(1, 1, self.set_up_test_scenario) iraq = app.map.get("Iraq") self.assertEqual(iraq.plots, 2) app.alert_plot("Iraq") self.assertEqual(iraq.plots, 1) app.alert_plot("Iraq") self.assertEqual(iraq.plots, 0) with self.assertRaises(AssertionError): app.alert_plot("Iraq")
def test_adding_three_ops_only_sets_to_two(self): # Set up app = Labyrinth(1, 1, LabyrinthTestCase.set_up_blank_test_scenario) assert app.us_reserves == 0 app.play_us_card(116) # 3 ops # Invoke app.deploy_reserves() # Check self.assertEqual(2, app.us_reserves)
def test_country_without_nato_has_no_extra_troops(self): # Set up app = Labyrinth(1, 1, self.set_up_blank_test_scenario) iran = app.get_country("Iran") iran.change_troops(2) # Invoke troops = iran.troops() # Check self.assertEqual(2, troops)
def test_non_muslim_country_with_no_markers(self): # Set up app = Labyrinth(1, 1, self.set_up_blank_test_scenario) israel = app.get_country("Israel") israel.plots = 2 # Invoke summary = israel.summary() # Check self.assertEqual(summary, "Israel - Posture: Hard\n Plots: 2")
def test_should_be_able_to_do_anything_with_three_ops(self): # Set up app = Labyrinth(1, 1) # Invoke prompt = app.get_us_prompt_to_spend_ops(82) # Jihadist Videos # Check self.assertEqual( prompt, "3 Ops available. Use one of: alert, deploy, disrupt, reassessment, regime_change," " reserves, war_of_ideas, withdraw")
def test_scenario_1_makes_afghanistan_islamist_rule_adversary(self): # Set up app = Labyrinth(1, 1) afghanistan = app.get_country("Afghanistan") # Invoke alignment = afghanistan.alignment() governance = afghanistan.get_governance() # Check self.assertEqual(ADVERSARY, alignment) self.assertEqual(ISLAMIST_RULE, governance)
def test_iran_with_things_in_it(self): # Set up app = Labyrinth(1, 1, self.set_up_blank_test_scenario) iran = app.get_country("Iran") iran.plots = 3 iran.activeCells = 4 # Invoke summary = iran.summary() # Check self.assertEqual(summary, "Iran, Fair\n Active: 4, Plots: 3")
def test_gwot_penalty(self): """GWOT Penalty""" app = Labyrinth(1, 1, self.set_up_test_scenario) self.assertEqual(app.modified_woi_roll(3, "Gulf States"), 3) app.get_country("United States").make_soft() self.assertEqual(app.modified_woi_roll(3, "Gulf States"), 2) app.get_country("Canada").make_hard() self.assertEqual(app.modified_woi_roll(3, "Gulf States"), 1) app.get_country("France").make_hard() self.assertEqual(app.modified_woi_roll(3, "Gulf States"), 0) app.get_country("Germany").make_hard() self.assertEqual(app.modified_woi_roll(3, "Gulf States"), 0)
def test_should_have_minimal_choice_with_one_ops(self): # Set up app = Labyrinth(1, 1) # Invoke prompt = app.get_us_prompt_to_spend_ops(4) # Moro talks # Check self.assertEqual( prompt, "1 Ops available. Use one of: deploy, disrupt, reserves, war_of_ideas" )
def test_adjacent_countries(self): """Adjacent countries Ally Good""" app = Labyrinth(1, 1, self.set_up_test_scenario) self.assertEqual(app.modified_woi_roll(3, "Gulf States"), 3) app.get_country('Pakistan').make_good() app.get_country('Pakistan').make_neutral() self.assertEqual(app.modified_woi_roll(3, "Gulf States"), 3) app.get_country('Pakistan').make_ally() self.assertEqual(app.modified_woi_roll(3, "Gulf States"), 4) app.get_country('Iraq').make_good() app.get_country('Iraq').make_ally() self.assertEqual(app.modified_woi_roll(3, "Gulf States"), 4)
def test_troops_disrupting_cadre_increases_prestige(self): # Set up app = Labyrinth(1, 1, test_user_input=["Egypt"]) prestige_before = app.prestige app.get_country("Egypt").cadre = 1 app.get_country("Egypt").troopCubes = 2 # Invoke app.disrupt_cells_or_cadre() # Check self.assertEqual(app.prestige, prestige_before + 1)
def test_cannot_be_made_hard(self): # Set up app = Labyrinth(1, 1, self.set_up_blank_test_scenario) iran = Iran(app) # Invoke try: iran.make_hard() self.fail("Should have raised an Exception") except Exception as e: # Check self.assertEqual("Not in Iran", e.message)
def test_country_with_nato_has_two_extra_troops(self): # Set up app = Labyrinth(1, 1, self.set_up_blank_test_scenario) iran = app.get_country("Iran") iran.change_troops(2) iran.markers.append("NATO") # Invoke troops = iran.troops() # Check self.assertEqual(4, troops)
def test_major_jihad_is_not_possible(self): # Set up app = Labyrinth(1, 1, self.set_up_blank_test_scenario) iran = Iran(app) iran.sleeperCells = 5 iran.change_troops(-999) # Invoke major_jihad_possible = iran.is_major_jihad_possible(3, 5, False) # Check self.assertFalse(major_jihad_possible)
def test_num_disruptable(self): # Set up app = Labyrinth(1, 1) app.get_country("Canada").sleeperCells = 1 app.get_country("Iraq").sleeperCells = 1 app.get_country("Iraq").make_ally() app.get_country("Jordan").sleeperCells = 1 app.get_country("Jordan").troopCubes = 2 app.get_country("Libya").sleeperCells = 1 app.get_country("Libya").troopCubes = 1 # Should not be enough # Invoke & assert self.assertEqual(app.num_disruptable(), 3)
def test_two_countries_have_plots(self): # Set up app = Labyrinth(1, 1) actual_plot_countries = ["China", "Italy"] for country_name in actual_plot_countries: app.get_country(country_name).plots = 2 # Invoke plot_countries = [c.name for c in app.get_plot_countries()] # Check plot_countries.sort() self.assertEqual(actual_plot_countries, plot_countries)
def test_travel_second_box(self): app = Labyrinth(1, 1, self.set_up_blank_test_scenario) app.get_country("Afghanistan").make_poor() app.get_country("Afghanistan").troopCubes = 1 app.get_country("Afghanistan").sleeperCells = 4 dest = app.travel_destinations(1) self.assertEqual(dest, ["Afghanistan"]) app.get_country("Gulf States").make_poor() app.get_country("Gulf States").make_besieged() dest = app.travel_destinations(1) self.assertEqual(dest, ["Gulf States"]) dest = app.travel_destinations(2) self.assertEqual(dest, ["Gulf States", "Afghanistan"])
def test_schengen_countries(self): # Set up app = Labyrinth(1, 1, self.set_up_test_scenario) # Invoke schengen_countries = app.names_of_countries(lambda c: c.schengen) # Check expected_names = [ 'France', 'Scandinavia', 'Benelux', 'Italy', 'Germany', 'Spain', 'Eastern Europe' ] self.assertEqual(len(expected_names), len(schengen_countries)) for expected_name in expected_names: self.assertTrue(expected_name in schengen_countries, "Could not find '%s'" % expected_name)