def isolated_scores(self): """ The input format of the score sheet contains information about which team has how many tokens in a zone. We don't really care about this level, and really want to know _who owns_ each zone. Similarly, it's more useful have a list of which slots a team owns, rather than a map of slot to whether or not they own it. This method performs these tidyups and returns a new dictionary. In the process, we also ensure that there are no clashes. """ zone_tokens = {} slot_bottoms = {} for tla, team_data in self._scoresheet.items(): validate_team(tla, team_data) zone_tokens[tla] = team_data['zone_tokens'] slot_bottoms[tla] = team_data['slot_bottoms'] zones_owned = tidy_zones(zone_tokens) slots_owned = tidy_slots(slot_bottoms) isolated = {} for tla, team_data in self._scoresheet.items(): isolated[tla] = { 'robot_moved': team_data['robot_moved'], 'slots_owned': slots_owned[tla], 'upright_tokens': team_data['upright_tokens'], 'zones_owned': zones_owned[tla], } return isolated
def assert_invalid(remove): input_ = plain_input() del input_[remove] assert remove not in input_, "Wut" e = assert_threw(lambda: validate_team('TLA9', input_), \ "Should error when missing key '{}'.".format(remove)) assert remove in e.message
def assert_invalid(input_, expected_msg_part, error_message): tla = 'TLA9' e = assert_threw(lambda: validate_team(tla, input_), error_message) assert expected_msg_part in e.message assert tla in e.message
def test_validate_team(): input_ = plain_input() validate_team('TLA2', input_)