Beispiel #1
0
    def test_just_diff(self):
        os.environ['OPENSHIFT_MONGODB_DB_URL'] = u"mongodb://*****:*****@127.0.0.1:27017/euroxxxvi"

        match = Match()
        match.key = "KEYMATCH"
        match.resultA = 2
        match.resultB = 1
        # case just 1 or N or 2
        bet = Bet()
        bet.key = "KEYMATCH"
        bet.resultA = 5
        bet.resultB = 6
        match.computeResult(bet)
        self.assertEqual(2, bet.nbpoints)

        match = Match()
        match.key = "KEYMATCH"
        match.resultA = 1
        match.resultB = 2
        bet = Bet()
        bet.key = "KEYMATCH"
        bet.resultA = 51
        bet.resultB = 50
        match.computeResult(bet)
        self.assertEqual(2, bet.nbpoints)
Beispiel #2
0
    def test_createOrUpdate(self):
        os.environ['OPENSHIFT_MONGODB_DB_URL']=u"mongodb://*****:*****@127.0.0.1:27017/euroxxxvi"
        mgr = BetsManager()
        self.assertIsNotNone(mgr.getDb())
        bet = Bet()
        bet.resultA=1
        bet.resultB=10
        bet.user_id="moi_en_uuid"
        bet.com_id="ma_com_id_en_uuid"
        bet.category="categcode"
        bet.categoryName="categname"
        bet.key="keymatch"
        bet.libteamA="theliba"
        bet.libteamB="thelibb"
        bet.teamA="theteamA"
        bet.teamB="theteamb"
        bet.dateDeadLineBet=datetime(2016, 6, 2, 18, 15, 0, 0, tzinfo=timezone.utc)
        bet.dateMatch=datetime(2016, 6, 2, 18, 15, 0, 0, tzinfo=timezone.utc)

        mgr.createOrUpdate(bet)

        bets = mgr.getBetsOfUserAndCom(user_id="moi_en_uuid", com_id="ma_com_id_en_uuid")
        self.assertGreater(len(bets), 0)
        for u in bets:
            print(u)
        self.assertIsNotNone(bets)

        nb = mgr.delete(bet)
        self.assertEqual(1, nb)
Beispiel #3
0
    def test_countPlayer(self):
        os.environ['OPENSHIFT_MONGODB_DB_URL']=u"mongodb://*****:*****@127.0.0.1:27017/euroxxxvi"
        mgr = BetsManager()
        self.assertIsNotNone(mgr.getDb())
        bet = Bet()
        bet.resultA=1
        bet.resultB=10
        bet.user_id="moi_en_uuid"
        bet.com_id="ma_com_id_en_uuid"
        bet.category="categcode"
        bet.categoryName="categname"
        bet.key="keymatch"
        bet.libteamA="theliba"
        bet.libteamB="thelibb"
        bet.teamA="theteamA"
        bet.teamB="theteamb"
        bet.dateDeadLineBet=datetime(2016, 6, 2, 18, 15, 0, 0, tzinfo=timezone.utc)
        bet.dateMatch=datetime(2016, 6, 2, 18, 15, 0, 0, tzinfo=timezone.utc)

        mgr.createOrUpdate(bet)

        result = mgr.countPlayers("ma_com_id_en_uuid")
        self.assertEqual(1, result)
        players = mgr.players("ma_com_id_en_uuid")
        self.assertEqual(1, len(players))

        bet2 = Bet()
        bet2.resultA=1
        bet2.resultB=10
        bet2.user_id="moi_en_uuid"
        bet2.com_id="ma_com_id_en_uuid"
        bet2.category="categcode"
        bet2.categoryName="categname"
        bet2.key="keymatch"
        bet2.libteamA="theliba"
        bet2.libteamB="thelibb"
        bet2.teamA="theteamA"
        bet2.teamB="theteamb"
        bet2.dateDeadLineBet=datetime(2016, 6, 2, 18, 15, 0, 0, tzinfo=timezone.utc)
        bet2.dateMatch=datetime(2016, 6, 2, 18, 15, 0, 0, tzinfo=timezone.utc)
        mgr.createOrUpdate(bet)

        mgr.delete(bet)
        mgr.delete(bet2)
Beispiel #4
0
    def test_just_1n2(self):
        os.environ['OPENSHIFT_MONGODB_DB_URL'] = u"mongodb://*****:*****@127.0.0.1:27017/euroxxxvi"

        match = Match()
        match.key = "KEYMATCH"
        match.resultA = 2
        match.resultB = 1

        # case just 1 or N or 2
        bet = Bet()
        bet.key = "KEYMATCH"
        bet.resultA = 50
        bet.resultB = 5
        match.computeResult(bet)
        self.assertEqual(5, bet.nbpoints)

        match = Match()
        match.key = "KEYMATCH"
        match.resultA = 1
        match.resultB = 2
        bet = Bet()
        bet.key = "KEYMATCH"
        bet.resultA = 5
        bet.resultB = 50
        match.computeResult(bet)
        self.assertEqual(5, bet.nbpoints)

        #for null match : 5pts + 2 because right diff of goal
        match = Match()
        match.key = "KEYMATCH"
        match.resultA = 2
        match.resultB = 2
        bet = Bet()
        bet.key = "KEYMATCH"
        bet.resultA = 50
        bet.resultB = 50
        match.computeResult(bet)
        self.assertEqual(7, bet.nbpoints)
Beispiel #5
0
    def test_exact_score(self):
        os.environ['OPENSHIFT_MONGODB_DB_URL'] = u"mongodb://*****:*****@127.0.0.1:27017/euroxxxvi"

        match = Match()
        match.key="KEYMATCH"
        match.resultA=2
        match.resultB=1

        #case exact result
        bet = Bet()
        bet.key="KEYMATCH"
        bet.resultA=2
        bet.resultB=1
        match.computeResult(bet)
        self.assertEqual(13, bet.nbpoints)
Beispiel #6
0
    def test_createOrUpdate(self):
        os.environ[
            'OPENSHIFT_MONGODB_DB_URL'] = u"mongodb://*****:*****@127.0.0.1:27017/euroxxxvi"
        mgr = BetsManager()
        self.assertIsNotNone(mgr.getDb())
        bet = Bet()
        bet.resultA = 1
        bet.resultB = 10
        bet.user_id = "moi_en_uuid"
        bet.com_id = "ma_com_id_en_uuid"
        bet.category = "categcode"
        bet.categoryName = "categname"
        bet.key = "keymatch"
        bet.libteamA = "theliba"
        bet.libteamB = "thelibb"
        bet.teamA = "theteamA"
        bet.teamB = "theteamb"
        bet.dateDeadLineBet = datetime(2016,
                                       6,
                                       2,
                                       18,
                                       15,
                                       0,
                                       0,
                                       tzinfo=timezone.utc)
        bet.dateMatch = datetime(2016, 6, 2, 18, 15, 0, 0, tzinfo=timezone.utc)

        mgr.createOrUpdate(bet)

        bets = mgr.getBetsOfUserAndCom(user_id="moi_en_uuid",
                                       com_id="ma_com_id_en_uuid")
        self.assertGreater(len(bets), 0)
        for u in bets:
            print(u)
        self.assertIsNotNone(bets)

        nb = mgr.delete(bet)
        self.assertEqual(1, nb)
Beispiel #7
0
    def test_countPlayer(self):
        os.environ[
            'OPENSHIFT_MONGODB_DB_URL'] = u"mongodb://*****:*****@127.0.0.1:27017/euroxxxvi"
        mgr = BetsManager()
        self.assertIsNotNone(mgr.getDb())
        bet = Bet()
        bet.resultA = 1
        bet.resultB = 10
        bet.user_id = "moi_en_uuid"
        bet.com_id = "ma_com_id_en_uuid"
        bet.category = "categcode"
        bet.categoryName = "categname"
        bet.key = "keymatch"
        bet.libteamA = "theliba"
        bet.libteamB = "thelibb"
        bet.teamA = "theteamA"
        bet.teamB = "theteamb"
        bet.dateDeadLineBet = datetime(2016,
                                       6,
                                       2,
                                       18,
                                       15,
                                       0,
                                       0,
                                       tzinfo=timezone.utc)
        bet.dateMatch = datetime(2016, 6, 2, 18, 15, 0, 0, tzinfo=timezone.utc)

        mgr.createOrUpdate(bet)

        result = mgr.countPlayers("ma_com_id_en_uuid")
        self.assertEqual(1, result)
        players = mgr.players("ma_com_id_en_uuid")
        self.assertEqual(1, len(players))

        bet2 = Bet()
        bet2.resultA = 1
        bet2.resultB = 10
        bet2.user_id = "moi_en_uuid"
        bet2.com_id = "ma_com_id_en_uuid"
        bet2.category = "categcode"
        bet2.categoryName = "categname"
        bet2.key = "keymatch"
        bet2.libteamA = "theliba"
        bet2.libteamB = "thelibb"
        bet2.teamA = "theteamA"
        bet2.teamB = "theteamb"
        bet2.dateDeadLineBet = datetime(2016,
                                        6,
                                        2,
                                        18,
                                        15,
                                        0,
                                        0,
                                        tzinfo=timezone.utc)
        bet2.dateMatch = datetime(2016,
                                  6,
                                  2,
                                  18,
                                  15,
                                  0,
                                  0,
                                  tzinfo=timezone.utc)
        mgr.createOrUpdate(bet)

        mgr.delete(bet)
        mgr.delete(bet2)