def test_initialize(self): inventory = EDRInventory() event = { "timestamp":"2019-01-02T11:03:33Z", "event":"Materials", "Raw":[ { "Name":"zinc", "Count":52 }, { "Name":"mercury", "Count":54 }, { "Name":"polonium", "Count":33 }, { "Name":"tellurium", "Count":47 }, { "Name":"yttrium", "Count":43 }, { "Name":"antimony", "Count":51 }, { "Name":"selenium", "Count":21 }, { "Name":"ruthenium", "Count":49 }, { "Name":"zirconium", "Count":50 }, { "Name":"vanadium", "Count":66 }, { "Name":"manganese", "Count":83 }, { "Name":"chromium", "Count":26 }, { "Name":"molybdenum", "Count":44 }, { "Name":"technetium", "Count":22 }, { "Name":"tin", "Count":15 }, { "Name":"arsenic", "Count":44 }, { "Name":"cadmium", "Count":42 }, { "Name":"iron", "Count":54 }, { "Name":"niobium", "Count":29 }, { "Name":"phosphorus", "Count":48 }, { "Name":"germanium", "Count":37 }, { "Name":"tungsten", "Count":24 }, { "Name":"sulphur", "Count":32 }, { "Name":"carbon", "Count":67 }, { "Name":"nickel", "Count":78 }, { "Name":"rhenium", "Count":52 }, { "Name":"boron", "Count":36 }, { "Name":"lead", "Count":52 } ], "Manufactured":[ { "Name":"focuscrystals", "Name_Localised":"Focus Crystals", "Count":87 }, { "Name":"compoundshielding", "Name_Localised":"Compound Shielding", "Count":55 }, { "Name":"galvanisingalloys", "Name_Localised":"Galvanising Alloys", "Count":85 }, { "Name":"heatvanes", "Name_Localised":"Heat Vanes", "Count":34 }, { "Name":"configurablecomponents", "Name_Localised":"Configurable Components", "Count":26 }, { "Name":"biotechconductors", "Name_Localised":"Biotech Conductors", "Count":53 }, { "Name":"chemicalmanipulators", "Name_Localised":"Chemical Manipulators", "Count":77 }, { "Name":"mechanicalcomponents", "Name_Localised":"Mechanical Components", "Count":24 }, { "Name":"fedproprietarycomposites", "Name_Localised":"Proprietary Composites", "Count":46 }, { "Name":"highdensitycomposites", "Name_Localised":"High Density Composites", "Count":60 }, { "Name":"protoradiolicalloys", "Name_Localised":"Proto Radiolic Alloys", "Count":25 }, { "Name":"chemicaldistillery", "Name_Localised":"Chemical Distillery", "Count":76 }, { "Name":"chemicalprocessors", "Name_Localised":"Chemical Processors", "Count":131 }, { "Name":"imperialshielding", "Name_Localised":"Imperial Shielding", "Count":76 }, { "Name":"gridresistors", "Name_Localised":"Grid Resistors", "Count":59 }, { "Name":"heatconductionwiring", "Name_Localised":"Heat Conduction Wiring", "Count":94 }, { "Name":"militarygradealloys", "Name_Localised":"Military Grade Alloys", "Count":87 }, { "Name":"hybridcapacitors", "Name_Localised":"Hybrid Capacitors", "Count":99 }, { "Name":"heatexchangers", "Name_Localised":"Heat Exchangers", "Count":50 }, { "Name":"conductivepolymers", "Name_Localised":"Conductive Polymers", "Count":43 }, { "Name":"shieldingsensors", "Name_Localised":"Shielding Sensors", "Count":88 }, { "Name":"heatdispersionplate", "Name_Localised":"Heat Dispersion Plate", "Count":100 }, { "Name":"electrochemicalarrays", "Name_Localised":"Electrochemical Arrays", "Count":52 }, { "Name":"conductiveceramics", "Name_Localised":"Conductive Ceramics", "Count":46 }, { "Name":"conductivecomponents", "Name_Localised":"Conductive Components", "Count":87 }, { "Name":"militarysupercapacitors", "Name_Localised":"Military Supercapacitors", "Count":75 }, { "Name":"mechanicalequipment", "Name_Localised":"Mechanical Equipment", "Count":93 }, { "Name":"phasealloys", "Name_Localised":"Phase Alloys", "Count":47 }, { "Name":"pharmaceuticalisolators", "Name_Localised":"Pharmaceutical Isolators", "Count":34 }, { "Name":"fedcorecomposites", "Name_Localised":"Core Dynamics Composites", "Count":25 }, { "Name":"basicconductors", "Name_Localised":"Basic Conductors", "Count":70 }, { "Name":"mechanicalscrap", "Name_Localised":"Mechanical Scrap", "Count":93 }, { "Name":"salvagedalloys", "Name_Localised":"Salvaged Alloys", "Count":90 }, { "Name":"protolightalloys", "Name_Localised":"Proto Light Alloys", "Count":60 }, { "Name":"refinedfocuscrystals", "Name_Localised":"Refined Focus Crystals", "Count":79 }, { "Name":"shieldemitters", "Name_Localised":"Shield Emitters", "Count":105 }, { "Name":"precipitatedalloys", "Name_Localised":"Precipitated Alloys", "Count":5 }, { "Name":"wornshieldemitters", "Name_Localised":"Worn Shield Emitters", "Count":89 }, { "Name":"exquisitefocuscrystals", "Name_Localised":"Exquisite Focus Crystals", "Count":21 }, { "Name":"polymercapacitors", "Name_Localised":"Polymer Capacitors", "Count":60 }, { "Name":"thermicalloys", "Name_Localised":"Thermic Alloys", "Count":42 }, { "Name":"improvisedcomponents", "Name_Localised":"Improvised Components", "Count":27 }, { "Name":"protoheatradiators", "Name_Localised":"Proto Heat Radiators", "Count":12 }, { "Name":"crystalshards", "Name_Localised":"Crystal Shards", "Count":87 }, { "Name":"heatresistantceramics", "Name_Localised":"Heat Resistant Ceramics", "Count":33 }, { "Name":"temperedalloys", "Name_Localised":"Tempered Alloys", "Count":34 }, { "Name":"uncutfocuscrystals", "Name_Localised":"Flawed Focus Crystals", "Count":93 }, { "Name":"filamentcomposites", "Name_Localised":"Filament Composites", "Count":23 }, { "Name":"compactcomposites", "Name_Localised":"Compact Composites", "Count":10 }, { "Name":"chemicalstorageunits", "Name_Localised":"Chemical Storage Units", "Count":43 }, { "Name":"guardian_powerconduit", "Name_Localised":"Guardian Power Conduit", "Count":148 }, { "Name":"guardian_powercell", "Name_Localised":"Guardian Power Cell", "Count":163 }, { "Name":"guardian_techcomponent", "Name_Localised":"Guardian Technology Component", "Count":25 }, { "Name":"guardian_sentinel_wreckagecomponents", "Name_Localised":"Guardian Wreckage Components", "Count":3 }, { "Name":"guardian_sentinel_weaponparts", "Name_Localised":"Guardian Sentinel Weapon Parts", "Count":57 } ], "Encoded":[ { "Name":"classifiedscandata", "Name_Localised":"Classified Scan Fragment", "Count":63 }, { "Name":"securityfirmware", "Name_Localised":"Security Firmware Patch", "Count":78 }, { "Name":"dataminedwake", "Name_Localised":"Datamined Wake Exceptions", "Count":31 }, { "Name":"compactemissionsdata", "Name_Localised":"Abnormal Compact Emissions Data", "Count":53 }, { "Name":"shieldpatternanalysis", "Name_Localised":"Aberrant Shield Pattern Analysis", "Count":81 }, { "Name":"adaptiveencryptors", "Name_Localised":"Adaptive Encryptors Capture", "Count":32 }, { "Name":"emissiondata", "Name_Localised":"Unexpected Emission Data", "Count":88 }, { "Name":"industrialfirmware", "Name_Localised":"Cracked Industrial Firmware", "Count":92 }, { "Name":"scandatabanks", "Name_Localised":"Classified Scan Databanks", "Count":106 }, { "Name":"legacyfirmware", "Name_Localised":"Specialised Legacy Firmware", "Count":100 }, { "Name":"embeddedfirmware", "Name_Localised":"Modified Embedded Firmware", "Count":33 }, { "Name":"shieldcyclerecordings", "Name_Localised":"Distorted Shield Cycle Recordings", "Count":102 }, { "Name":"decodedemissiondata", "Name_Localised":"Decoded Emission Data", "Count":110 }, { "Name":"bulkscandata", "Name_Localised":"Anomalous Bulk Scan Data", "Count":120 }, { "Name":"scanarchives", "Name_Localised":"Unidentified Scan Archives", "Count":98 }, { "Name":"shieldsoakanalysis", "Name_Localised":"Inconsistent Shield Soak Analysis", "Count":92 }, { "Name":"encodedscandata", "Name_Localised":"Divergent Scan Data", "Count":55 }, { "Name":"shielddensityreports", "Name_Localised":"Untypical Shield Scans ", "Count":87 }, { "Name":"shieldfrequencydata", "Name_Localised":"Peculiar Shield Frequency Data", "Count":45 }, { "Name":"encryptioncodes", "Name_Localised":"Tagged Encryption Codes", "Count":85 }, { "Name":"consumerfirmware", "Name_Localised":"Modified Consumer Firmware", "Count":67 }, { "Name":"archivedemissiondata", "Name_Localised":"Irregular Emission Data", "Count":24 }, { "Name":"symmetrickeys", "Name_Localised":"Open Symmetric Keys", "Count":93 }, { "Name":"encryptedfiles", "Name_Localised":"Unusual Encrypted Files", "Count":93 }, { "Name":"scrambledemissiondata", "Name_Localised":"Exceptional Scrambled Emission Data", "Count":18 }, { "Name":"fsdtelemetry", "Name_Localised":"Anomalous FSD Telemetry", "Count":69 }, { "Name":"hyperspacetrajectories", "Name_Localised":"Eccentric Hyperspace Trajectories", "Count":28 }, { "Name":"disruptedwakeechoes", "Name_Localised":"Atypical Disrupted Wake Echoes", "Count":17 }, { "Name":"wakesolutions", "Name_Localised":"Strange Wake Solutions", "Count":16 }, { "Name":"encryptionarchives", "Name_Localised":"Atypical Encryption Archives", "Count":47 }, { "Name":"ancientbiologicaldata", "Name_Localised":"Pattern Alpha Obelisk Data", "Count":144 }, { "Name":"ancienthistoricaldata", "Name_Localised":"Pattern Gamma Obelisk Data", "Count":147 }, { "Name":"guardian_moduleblueprint", "Name_Localised":"Guardian Module Blueprint Fragment", "Count":1 }, { "Name":"ancientculturaldata", "Name_Localised":"Pattern Beta Obelisk Data", "Count":132 }, { "Name":"ancientlanguagedata", "Name_Localised":"Pattern Delta Obelisk Data", "Count":42 } ] } inventory.initialize(event) self.assertEqual(inventory.count("zinc"), 52) self.assertEqual(inventory.count("Zinc"), 52) self.assertEqual(inventory.count("compoundshielding"), 55) self.assertEqual(inventory.count("Compound Shielding"), 55) self.assertEqual(inventory.count("guardian_moduleblueprint"), 1) self.assertEqual(inventory.count("Guardian Module Blueprint Fragment"), 1) self.assertEqual(inventory.count("doesnotexist"), 0)
def __init__(self, name=None): super(EDPlayerOne, self).__init__(name) self.powerplay = None self.game_mode = None self.private_group = None self.previous_mode = None self.previous_wing = set() self.from_genesis = False self.wing = EDWing() self.friends = set() self.crew = None self._target = None self.instance = EDInstance() self.planetary_destination = None self.recon_box = EDReconBox() self.inventory = EDRInventory() self.fleet = edrfleet.EDRFleet() try: with open(self.EDR_FLEET_CARRIER_CACHE, 'rb') as handle: self.fleet_carrier = pickle.load(handle) except: self.fleet_carrier = edrfleetcarrier.EDRFleetCarrier() self.mining_stats = edrminingstats.EDRMiningStats()
class EDPlayerOne(EDPlayer): EDR_FLEET_CARRIER_CACHE = utils2to3.abspathmaker(__file__, 'cache', 'fleet_carrier.v1.p') def __init__(self, name=None): super(EDPlayerOne, self).__init__(name) self.powerplay = None self.game_mode = None self.private_group = None self.previous_mode = None self.previous_wing = set() self.from_genesis = False self.wing = EDWing() self.friends = set() self.crew = None self._target = None self.instance = EDInstance() self.planetary_destination = None self.recon_box = EDReconBox() self.inventory = EDRInventory() self.fleet = edrfleet.EDRFleet() try: with open(self.EDR_FLEET_CARRIER_CACHE, 'rb') as handle: self.fleet_carrier = pickle.load(handle) except: self.fleet_carrier = edrfleetcarrier.EDRFleetCarrier() self.mining_stats = edrminingstats.EDRMiningStats() def __repr__(self): return str(self.__dict__) def persist(self): self.inventory.persist() with open(self.EDR_FLEET_CARRIER_CACHE, 'wb') as handle: pickle.dump(self.fleet_carrier, handle, protocol=pickle.HIGHEST_PROTOCOL) @property def target(self): return self._target @target.setter def target(self, new_target): if self._target: self._target.targeted = False self._target._touch() self._target = new_target if new_target: new_target.targeted = True new_target._touch() self._touch() def lowish_fuel(self): if self.mothership.fuel_level is None or self.mothership.fuel_capacity is None: return True # Better safe than sorry return (self.mothership.fuel_level / self.mothership.fuel_capacity) <= 0.3 def heavily_damaged(self): if self.mothership.hull_health is None: return True # Better safe than sorry return self.mothership.hull_health <= 50 def json(self, fuel_info=False, with_target=False): result = { u"cmdr": self.name, u"timestamp": self.timestamp * 1000, u"wanted": self.wanted, u"bounty": self.bounty, u"starSystem": self.star_system, u"place": self.place, u"wingof": len(self.wing.wingmates), u"wing": self.wing.noteworthy_changes_json(self.instance), u"byPledge": self.powerplay.canonicalize() if self.powerplay else u'', u"ship": self.piloted_vehicle.json(fuel_info=fuel_info), u"mode": self.game_mode, u"group": self.private_group } if with_target: result[u"target"] = self.target.json() if self.target else {} result[u"crew"] = [] if self.crew: result[u"crew"] = [{ u"cmdr": crew_member } for crew_member in self.crew.all_members()] return result def force_new_name(self, new_name): self._name = new_name def in_solo_or_private(self): return self.game_mode in [u"Solo", u"Group"] def in_solo(self): return self.game_mode == u"Solo" def in_open(self): return self.game_mode == u"Open" def inception(self, genesis=False): if genesis: self.from_genesis = True self.previous_mode = None self.previous_wing = set() self.wing = EDWing() self.crew = None self.destroyed = False self.target = None self.wanted = False self.mothership = EDVehicleFactory.unknown_vehicle() self.piloted_vehicle = self.mothership self.srv = None self.slf = None self.location = EDLocation() self._bounty = None self.instance.reset() self.to_normal_space() self._touch() self.reset_mining_stats() def killed(self): super(EDPlayerOne, self).killed() self.previous_mode = self.game_mode self.previous_private_group = self.private_group self.previous_wing = self.wing.wingmates.copy() self.game_mode = None self.private_group = None self.wing = EDWing() self.crew = None self.target = None self.instance.reset() self.recon_box.reset() self._touch() def resurrect(self, rebought=True): self.game_mode = self.previous_mode self.private_group = self.previous_private_group self.wing = EDWing(self.previous_wing) self.previous_mode = None self.previous_wing = set() self.destroyed = False self.target = None self.to_normal_space() self.instance.reset() self._touch() if rebought: self.mothership.reset() if self.slf: self.slf.reset() if self.srv: self.srv.reset() else: self.mothership = EDVehicleFactory.unknown_vehicle() self.piloted_vehicle = self.mothership self.slf = None self.srv = None def is_crew_member(self): if not self.crew: return False return self.crew.captain != self.name def in_a_crew(self): return self.crew is not None def leave_wing(self): self.wing.leave() self._touch() def join_wing(self, others): self.wing.join(others) self.crew = None self._touch() def add_to_wing(self, other): self.wing.add(other) self._touch() def in_a_wing(self): return self.wing.formed() def leave_crew(self): self._touch() if not self.crew: return self.crew = None self.instance.reset() def disband_crew(self): self._touch() if not self.crew: return for member in self.crew.members: self.instance.player_out(member) self.crew.disband() def join_crew(self, captain): self.wing = EDWing() self.instance.reset() self.crew = EDRCrew(captain) self.crew.add(self.name) self.instanced(captain) self.mothership = EDVehicleFactory.unknown_vehicle() self.piloted_vehicle = self.mothership self.slf = None self.srv = None self._touch() def add_to_crew(self, member): self._touch() if not self.crew: self.crew = EDRCrew(self.name) self.wing = EDWing() self.instance.reset() self.instanced(member) return self.crew.add(member) def remove_from_crew(self, member): self._touch() if not self.crew: self.crew = EDRCrew(self.name) self.wing = EDWing() self.instance.reset() self.instance.player_out(member) return self.crew.remove(member) def crew_time_elapsed(self, member): if not self.crew: return 0 return self.crew.duration(member) def is_captain(self, member=None): if not self.crew: return False if not member: member = self.name return self.crew.is_captain(member) def is_friend(self, cmdr_name): return cmdr_name in self.friends def is_wingmate(self, cmdr_name): return cmdr_name in self.wing.wingmates def is_crewmate(self, cmdr_name): if not self.crew: return False return cmdr_name in self.crew.all_members() def is_enemy_with(self, power): if self.is_independent() or not power: return False return self.powerplay.is_enemy(power) def to_normal_space(self): if self.in_normal_space(): return super(EDPlayerOne, self).to_normal_space() self.instance.reset() def to_super_space(self): if self.in_supercruise(): return super(EDPlayerOne, self).to_super_space() self.instance.reset() self.recon_box.reset() def to_hyper_space(self): if self.in_hyper_space(): return super(EDPlayerOne, self).to_hyper_space() self.instance.reset() self.recon_box.reset() def wing_and_crew(self): wing_and_crew = self.wing.wingmates.copy() if self.crew: wing_and_crew.update(self.crew.all_members()) return wing_and_crew def maybe_in_a_pvp_fight(self): if not self.in_a_fight(): return False if self.instance.is_empty(): # Can't PvP if there is no one. return False if not self.instance.anyone_beside(self.wing_and_crew()): return False return True def leave_vehicle(self): self.mothership = EDVehicleFactory.unknown_vehicle() self.piloted_vehicle = self.mothership self.slf = None self.srv = None self.instance.reset() self.recon_box.reset() self._touch() def targeting(self, cmdr): self.instance.player_in(cmdr) self.target = cmdr self._touch() def destroy(self, cmdr): self._touch() cmdr.killed() self.instance.player_out(cmdr.name) if self.target and self.target.name == cmdr.name: self.target = None def interdiction(self, interdicted, success): self._touch() self.to_normal_space() if success: interdicted.location = self.location self.instance.player_in(interdicted) else: self.recon_box.reset() def interdicted(self, interdictor, success): self._touch() if success: self.to_normal_space() interdictor.location = self.location self.instance.player_in(interdictor) else: self.instance.player_out(interdictor.cmdr_name) self.recon_box.reset() def is_instanced_with(self, cmdr_name): return self.instance.player(cmdr_name) != None def instanced(self, cmdr_name, ship_internal_name=None, piloted=True): self._touch() cmdr = self.instance.player(cmdr_name) if not cmdr: cmdr = EDPlayer(cmdr_name) cmdr.location = self.location if ship_internal_name: vehicle = EDVehicleFactory.from_internal_name(ship_internal_name) cmdr.update_vehicle_if_obsolete(vehicle, piloted) self.instance.player_in(cmdr) return cmdr def deinstanced(self, cmdr_name): self._touch() self.instance.player_out(cmdr_name) def attacked(self, target): self._touch() if target == u"Mothership": self.mothership.attacked() elif target == u"Fighter": if self.slf: self.slf.attacked() else: EDRLOG.log(u"SLF attacked but player had none", u"WARNING") elif target == u"You": self.piloted_vehicle.attacked() def update_fleet(self, stored_ships_entry): self.fleet.update(stored_ships_entry) def prospected(self, entry): self.mining_stats.prospected(entry) def refined(self, entry): self.mining_stats.refined(entry) def reset_mining_stats(self): self.mining_stats.reset()
def test_consumed(self): inventory = EDRInventory() inventory.add("manufactured", "heatconductionwiring", 2) inventory.add("manufactured", "conductivecomponents", 3) event = { "timestamp":"2018-11-08T05:15:17Z", "event":"EngineerCraft", "Slot":"PowerPlant", "Module":"int_powerplant_size6_class3", "Ingredients":[ { "Name":"heatconductionwiring", "Name_Localised":"Heat Conduction Wiring", "Count":1 }, { "Name":"conductivecomponents", "Name_Localised":"Conductive Components", "Count":1 } ], "Engineer":"Hera Tani", "EngineerID":300090, "BlueprintID":128673766, "BlueprintName":"PowerPlant_Boosted", "Level":2, "Quality":0.852900, "Modifiers":[ { "Label":"Integrity", "Value":101.699997, "OriginalValue":113.000000, "LessIsGood":0 }, { "Label":"PowerCapacity", "Value":24.773701, "OriginalValue":21.000000, "LessIsGood":0 }, { "Label":"HeatEfficiency", "Value":0.550000, "OriginalValue":0.500000, "LessIsGood":1 } ] } inventory.consumed(event["Ingredients"]) self.assertEqual(inventory.count("heatconductionwiring"), 1) self.assertEqual(inventory.count("conductivecomponents"), 2) event = { "timestamp":"2018-10-31T04:02:03Z", "event":"Synthesis", "Name":"Limpet Basic", "Materials":[ { "Name":"iron", "Count":10 }, { "Name":"nickel", "Count":10 } ] } inventory = EDRInventory() inventory.add("raw", "nickel", 11) inventory.add("raw", "iron", 13) inventory.consumed(event["Materials"]) self.assertEqual(inventory.count("nickel"), 1) self.assertEqual(inventory.count("iron"), 3)
def test_slots(self): inventory = EDRInventory() self.assertEqual(inventory.slots("electrochemicalarrays"), 300) self.assertEqual(inventory.slots("niobium"), 200) self.assertEqual(inventory.slots("decodedemissiondata"), 150) self.assertEqual(inventory.slots("ancienttechnologicaldata"), 100)
def test_discarded(self): inventory = EDRInventory() info = { "timestamp":"2019-01-02T11:03:33Z", "event":"Materials", "Raw":[ { "Name":"zinc", "Count":52 }, { "Name":"mercury", "Count":54 } ], "Manufactured":[ { "Name":"focuscrystals", "Name_Localised":"Focus Crystals", "Count":87 }, { "Name":"compoundshielding", "Name_Localised":"Compound Shielding", "Count":55 } ], "Encoded":[ { "Name":"classifiedscandata", "Name_Localised":"Classified Scan Fragment", "Count":63 }, { "Name":"securityfirmware", "Name_Localised":"Security Firmware Patch", "Count":78 } ] } inventory.initialize(info) info = {"Category": "raw", "Name": "zinc", "Count": 3} inventory.discarded(info) self.assertEqual(inventory.count("zinc"), 49) info = {"Category": "raw", "Name": "zinc", "Count": 52} inventory.discarded(info) self.assertEqual(inventory.count("zinc"), 0) info = {"Category": "raw", "Name": "zinc", "Count": 1} inventory.discarded(info) self.assertEqual(inventory.count("zinc"), 0) self.assertEqual(inventory.count("mercury"), 54) info = {"Category": "manufactured", "Name": "focuscrystals", "Count": 3} inventory.discarded(info) self.assertEqual(inventory.count("focuscrystals"), 84) info = {"Category": "manufactured", "Name": "focuscrystals", "Count": 84} inventory.discarded(info) self.assertEqual(inventory.count("focuscrystals"), 0) info = {"Category": "manufactured", "Name": "focuscrystals", "Count": 1} inventory.discarded(info) self.assertEqual(inventory.count("focuscrystals"), 0) self.assertEqual(inventory.count("compoundshielding"), 55) info = {"Category": "encoded", "Name": "classifiedscandata", "Count": 3} inventory.discarded(info) self.assertEqual(inventory.count("classifiedscandata"), 60) info = {"Category": "encoded", "Name": "classifiedscandata", "Count": 60} inventory.discarded(info) self.assertEqual(inventory.count("focuscrystals"), 0) info = {"Category": "encoded", "Name": "classifiedscandata", "Count": 1} inventory.discarded(info) self.assertEqual(inventory.count("classifiedscandata"), 0) self.assertEqual(inventory.count("securityfirmware"), 78)
def test_collected(self): inventory = EDRInventory() self.assertEqual(inventory.count("zinc"), 0) info = {"Category": "raw", "Name": "zinc", "Count": 3} inventory.collected(info) self.assertEqual(inventory.count("zinc"), 3) info = {"Category": "raw", "Name": "zinc", "Count": 5} inventory.collected(info) self.assertEqual(inventory.count("zinc"), 8) info = {"Category": "raw", "Name": "polonium", "Count": 3} inventory.collected(info) self.assertEqual(inventory.count("zinc"), 8) self.assertEqual(inventory.count("polonium"), 3) info = {"Category": "manufactured", "Name": "highdensitycomposites", "Count": 3} inventory.collected(info) info = {"Category": "encoded", "Name": "shieldcyclerecordings", "Count": 3} inventory.collected(info) self.assertEqual(inventory.count("highdensitycomposites"), 3) self.assertEqual(inventory.count("shieldcyclerecordings"), 3) info = { "timestamp":"2018-10-31T04:03:19Z", "event":"MaterialCollected", "Category":"Manufactured", "Name":"tg_propulsionelement", "Name_Localised":"Propulsion Elements", "Count":3 } inventory.collected(info) self.assertEqual(inventory.count("tg_propulsionelement"), 3) self.assertEqual(inventory.count("Propulsion Elements"), 3)