def test_find_fuzzy_market(self):
        self.assertEqual(
            self.lookup.find_id(find_id_search=[
                lambda x, y: ["en", dList2Dict(x.description)["en"]] in y[
                    "description"]
            ]),
            "1.24.218",
        )

        self.assertEqual(
            self.lookup.find_id(
                find_id_search=[comparators.cmp_dynamic_bmg_fuzzy(0)]),
            "1.24.218")

        # No match because   floor(4.9) + 0.5 = 4.5
        self.lookup.set_overunder(4.9)
        self.assertFalse(
            self.lookup.find_id(
                find_id_search=[comparators.cmp_dynamic_bmg_fuzzy(0)]))

        # Match!
        self.lookup.set_overunder(5.0)
        self.assertTrue(
            self.lookup.find_id(
                find_id_search=[comparators.cmp_dynamic_bmg_fuzzy(0)]))

        self.assertTrue(
            self.lookup.find_id(
                find_id_search=[comparators.cmp_dynamic_bmg_fuzzy(0.51)]))
Beispiel #2
0
    def __init__(self,
                 bmg,
                 result,
                 handicaps=None,
                 overunder=None,
                 extra_data={}):
        Lookup.__init__(self)
        self.identifier = "{}::resolution".format(
            dList2Dict(bmg.description)["en"])
        self.parent = bmg
        dict.__init__(self, extra_data)
        dict.update(self, bmg)

        assert (isinstance(result, list)
                and len(result) == 2), "Result must be a list of length 2."
        handicaps = handicaps or [0, 0]
        overunder = overunder or 0
        dict.update(
            self, dict(result=result, handicaps=handicaps,
                       overunder=overunder))

        # We here direct the handicaps and overunders through BettingMarket
        # Group of the parent and load it from there again to allow
        # modifications according to set_*()
        if overunder:
            self.parent.set_overunder(overunder)
            self["overunder"] = self.parent["overunder"]

        if any(handicaps):
            self.parent.set_handicaps(home=handicaps[0], away=handicaps[1])
            self["handicaps"] = self.parent["handicaps"]
Beispiel #3
0
    def test_find_fuzzy_market(self):
        self.lookup.set_handicaps(home=5)

        self.assertEqual(
            self.lookup.find_id(find_id_search=[
                lambda x, y: ["en", dList2Dict(x.description)["en"]] in y[
                    "description"],
            ]), "1.20.220")

        self.assertEqual(
            self.lookup.find_id(find_id_search=[
                comparators.cmp_fuzzy(0),
            ]), "1.20.220")

        self.lookup.set_handicaps(home=6.5)
        self.assertFalse(
            self.lookup.find_id(find_id_search=[
                comparators.cmp_fuzzy(0),
            ]))

        self.assertFalse(
            self.lookup.find_id(find_id_search=[
                comparators.cmp_fuzzy(.49),
            ]))

        self.assertTrue(
            self.lookup.find_id(find_id_search=[
                comparators.cmp_fuzzy(.5),
            ]))

        self.assertTrue(
            self.lookup.find_id(find_id_search=[
                comparators.cmp_fuzzy(.51),
            ]))
Beispiel #4
0
    def test_find_fuzzy_market(self):
        self.lookup.set_handicaps(home=5)

        self.assertEqual(
            self.lookup.find_id(
                find_id_search=[
                    lambda x, y: ["en", dList2Dict(x.description)["en"]]
                    in y["description"]
                ]
            ),
            "1.24.301",
        )

        self.assertEqual(
            self.lookup.find_id(find_id_search=[comparators.cmp_dynamic_bmg_fuzzy(0.5)]), "1.24.220"
        )

        self.lookup.set_handicaps(home=6)
        self.assertFalse(self.lookup.find_id(find_id_search=[comparators.cmp_dynamic_bmg_fuzzy(0)]))

        self.assertFalse(
            self.lookup.find_id(find_id_search=[comparators.cmp_dynamic_bmg_fuzzy(0.99)])
        )

        self.assertTrue(
            self.lookup.find_id(find_id_search=[comparators.cmp_dynamic_bmg_fuzzy(1.1)])
        )

        self.assertTrue(
            self.lookup.find_id(find_id_search=[comparators.cmp_dynamic_bmg_fuzzy(1.01)])
        )
Beispiel #5
0
 def test_dlist2dict(self):
     self.assertEqual(utils.dList2Dict([["a", "b"]]), dict(a="b"))