Beispiel #1
0
    def test_name(self):
        # Since sim names are generated by Valve we'll test against those for consistency
        sim_inv = sim.inventory(
            sim.inventory_context(self.TEST_ID64)[440], self.TEST_ID64)
        # steamodd adds craft numbers to all names, valve doesn't, so they should be stripped
        # steamodd doesn't add crate series to names, valve does, so they should be stripped as well
        cn_exp = re.compile(r" (?:Series )?#\d+$")

        sim_names = set()
        for item in sim_inv:
            # Removes quotes in case of custom name (steamodd leaves that aesthetic choice to the user)
            name = item.full_name.strip("'")

            # Don't even bother with strange items right now. I'm tired of unit tests failing whenever
            # the inventory does and no one from valve responds when I tell them of the issue. If it does
            # get fixed feel free to remove this as it is definitely a WORKAROUND.
            # Removes quotes in case of custom name (steamodd leaves that aesthetic choice to the user)
            if not name.startswith("Strange "):
                sim_names.add(cn_exp.sub('', name))

        # See the above WORKAROUND about strange items and remove if/when it's fixed.
        our_names = set([
            cn_exp.sub('', item.custom_name or item.full_name)
            for item in self._inv
            if item.quality[1] != "strange" or item.custom_name
        ])

        self.assertEqual(our_names, sim_names)
Beispiel #2
0
    def test_name(self):
        # Since sim names are generated by Valve we'll test against those for consistency
        sim_inv = sim.inventory(sim.inventory_context(self.TEST_ID64)[440], self.TEST_ID64)
        # steamodd adds craft numbers to all names, valve doesn't, so they should be stripped
        cn_exp = re.compile(r" #\d+$")

        sim_names = set()
        for item in sim_inv:
            # Removes quotes in case of custom name (steamodd leaves that aesthetic choice to the user)
            name = item.full_name.strip("'")
            sim_names.add(cn_exp.sub('', name))

        our_names = set([cn_exp.sub('', item.full_name) for item in self._inv])

        self.assertEqual(our_names, sim_names)
Beispiel #3
0
    def test_attributes(self):
        # Similarly to the name, we'll test against Valve's strings to check for consistency in the math.
        sim_inv = sim.inventory(
            sim.inventory_context(self.TEST_ID64)[440], self.TEST_ID64)

        schema_attr_exps = []
        for attr in self._schema.attributes:
            if not attr.description:
                continue

            desc = attr.description.strip()
            exp = re.escape(desc).replace("\\%s1", r"[\d-]+")

            schema_attr_exps.append(re.compile(exp))

        sim_attrs = {}
        for item in sim_inv:
            sim_attrs.setdefault(item.id, set())

            for attr in item:
                # Due to lack of contextual data, we'll have to do fuzzy matching to separate actual attrs from fluff/descriptions
                desc = attr.description.strip()
                if desc:
                    # Stop processing if we hit item set attrs, for now
                    if desc.startswith("Item Set Bonus:"):
                        break

                    # Valve for some reason insists on this being attached by the client, since they're not actually attached we skip it.
                    if desc == "Given to valuable Community Contributors":
                        continue

                    for exp in schema_attr_exps:
                        if exp.match(desc):
                            sim_attrs[item.id].add(desc)
                            break

        for item in self._inv:
            # Ignore hidden, special (for now) and date values (timestamp formatting is an eternal battle, let it not be fought on these hallowed testgrounds)
            attrs = set([
                attr.formatted_description for attr in item if not attr.hidden
                and not attr.formatted_description.startswith("Attrib_")
                and attr.value_type not in ("date", "particle_index")
            ])
            self.assertTrue(item.id in sim_attrs)
            self.assertEqual(attrs, sim_attrs[item.id])
Beispiel #4
0
    def test_attributes(self):
        # Similarly to the name, we'll test against Valve's strings to check for consistency in the math.
        sim_inv = sim.inventory(sim.inventory_context(self.TEST_ID64)[440], self.TEST_ID64)

        schema_attr_exps = []
        for attr in self._schema.attributes:
            if not attr.description:
                continue

            desc = attr.description.strip()
            exp = re.escape(desc).replace("\\%s1", r"[\d-]+")

            schema_attr_exps.append(re.compile(exp))

        sim_attrs = {}
        for item in sim_inv:
            sim_attrs.setdefault(item.id, set())

            for attr in item:
                # Due to lack of contextual data, we'll have to do fuzzy matching to separate actual attrs from fluff/descriptions
                desc = attr.description.strip()
                if desc:
                    # Stop processing if we hit item set attrs, for now
                    if desc.startswith("Item Set Bonus:"):
                        break

                    # Valve for some reason insists on this being attached by the client, since they're not actually attached we skip it.
                    if desc == "Given to valuable Community Contributors":
                        continue

                    for exp in schema_attr_exps:
                        if exp.match(desc):
                            sim_attrs[item.id].add(desc)
                            break

        for item in self._inv:
            # Ignore hidden, special (for now) and date values (timestamp formatting is an eternal battle, let it not be fought on these hallowed testgrounds)
            attrs = set([attr.formatted_description for attr in item if not attr.hidden and
                                                                        not attr.formatted_description.startswith("Attrib_") and
                                                                        attr.value_type not in ("date", "particle_index")])
            self.assertTrue(item.id in sim_attrs)
            self.assertEqual(attrs, sim_attrs[item.id])
Beispiel #5
0
    def test_name(self):
        # Since sim names are generated by Valve we'll test against those for consistency
        sim_inv = sim.inventory(sim.inventory_context(self.TEST_ID64)[440], self.TEST_ID64)
        # steamodd adds craft numbers to all names, valve doesn't, so they should be stripped
        # steamodd doesn't add crate series to names, valve does, so they should be stripped as well
        cn_exp = re.compile(r" (?:Series )?#\d+$")

        sim_names = set()
        for item in sim_inv:
            # Removes quotes in case of custom name (steamodd leaves that aesthetic choice to the user)
            name = item.full_name.strip("'")

            # Don't even bother with strange items right now. I'm tired of unit tests failing whenever
            # the inventory does and no one from valve responds when I tell them of the issue. If it does
            # get fixed feel free to remove this as it is definitely a WORKAROUND.
            # Removes quotes in case of custom name (steamodd leaves that aesthetic choice to the user)
            if not name.startswith("Strange "):
                sim_names.add(cn_exp.sub('', name))

        # See the above WORKAROUND about strange items and remove if/when it's fixed.
        our_names = set([cn_exp.sub('', item.custom_name or item.full_name) for item in self._inv if item.quality[1] != "strange" or item.custom_name])

        self.assertEqual(our_names, sim_names)