def test_test_operation_equal(self): self.assertTrue(self.lookup.test_operation_equal(test_operation_dict)) # The second event is identical but has a different start_time t = test_operation_dict.copy() t["start_time"] = parse_time("2018-05-31T02:05:00") self.assertFalse(self.lookup.test_operation_equal(t)) """ # The second event is identical but has a different season t = test_operation_dict.copy() t["season"] = [["en", "2018"]] self.assertFalse(self.lookup.test_operation_equal(t)) """ # The second event is identical but has a different event group t = test_operation_dict.copy() t["event_group_id"] = "1.21.17" self.assertFalse(self.lookup.test_operation_equal(t)) # The second event is identical but has a different event group t = test_operation_dict.copy() t["event_group_id"] = "1.21.17" self.assertFalse(self.lookup.test_operation_equal(t)) # The second event is identical but has different teams t = test_operation_dict.copy() t["name"] = [["en", "Demo2 : Foobar"], ["en_us", "Foobar @ Demo2"]] self.assertFalse(self.lookup.test_operation_equal(t))
def test_leadtimemax_close(self): event = LookupEvent( sport_identifier=self.lookup["sport_identifier"], eventgroup_identifier=self.lookup["eventgroup_identifier"], teams=self.lookup["teams"], start_time=parse_time("2020-05-28T15:14:26"), ) # We set the leadtime_max to 2 days leadtime_Max = event.eventgroup["leadtime_Max"] # If the event starts now, it should be allowed to open event["start_time"] = datetime.datetime.utcnow() self.assertTrue(event.can_open) # If we move the start time forward to leadtime_max-1minute, it should # stil open event["start_time"] = datetime.datetime.utcnow() + datetime.timedelta( days=leadtime_Max, minutes=-1) self.assertTrue(event.can_open) # If we move it further, it should fail to open event["start_time"] = datetime.datetime.utcnow() + datetime.timedelta( days=leadtime_Max, minutes=1) self.assertFalse(event.can_open)
def test_event_create(self): ev = [["de", "1. Bundesliga"], ["en", "First Country League"]] desc = [["de", "Bundesliga"], ["en", "Germany Scoccer Championship"]] season = [["de", "Januar 2016"], ["en", "January 2016"]] start = datetime.datetime(2016, 1, 1, 0, 0, 0, tzinfo=datetime.timezone.utc) proposal = peerplays.proposal() peerplays.sport_create(["en", "testsport"], append_to=proposal) peerplays.event_group_create(ev, sport_id="0.0.0", append_to=proposal) peerplays.event_create(desc, season, start, event_group_id="0.0.1", append_to=proposal) tx = peerplays.tx() ops = tx["operations"] prop = ops[0][1] self.assertEqual(len(ops), 1) self.assertEqual(getOperationNameForId(ops[0][0]), "proposal_create") self.assertEqual(len(prop["proposed_ops"]), 3) self.assertEqual( getOperationNameForId(prop["proposed_ops"][2]["op"][0]), "event_create") self.assertEqual(desc, prop["proposed_ops"][2]["op"][1]["name"]) self.assertEqual(season, prop["proposed_ops"][2]["op"][1]["season"]) self.assertEqual(prop["proposed_ops"][2]["op"][1]["event_group_id"], "0.0.1") self.assertEqual( parse_time(prop["proposed_ops"][2]["op"][1]["start_time"]), start)
from peerplays.bettingmarketgroup import BettingMarketGroups from peerplays.blockchainobject import BlockchainObject, ObjectCache from peerplays.instance import set_shared_blockchain_instance from bookied_sync.lookup import Lookup from bookied_sync.eventgroup import LookupEventGroup from bookied_sync.event import LookupEvent from bookied_sync.bettingmarketgroup import LookupBettingMarketGroup from peerplays.utils import parse_time from peerplays.utils import formatTime from .fixtures import fixture_data, config, lookup_test_event event_group_id = "1.21.12" event_id = "1.22.2242" start_time = parse_time("2018-05-30T02:05:00") test_operation_dict = { "id": event_id, "name": [["en", "Boston Celtics @ Atlanta Hawks"]], "event_group_id": event_group_id, "season": [["en", "2017"]], "status": "upcoming", "start_time": "2022-10-16T00:00:00", } class Testcases(unittest.TestCase): def setUp(self): fixture_data()
from peerplays.eventgroup import EventGroups from peerplays.bettingmarketgroup import BettingMarketGroups from peerplays.blockchainobject import BlockchainObject, ObjectCache from peerplays.instance import set_shared_blockchain_instance from bookied_sync.lookup import Lookup from bookied_sync.eventgroup import LookupEventGroup from bookied_sync.event import LookupEvent from bookied_sync.bettingmarketgroup import LookupBettingMarketGroup from peerplays.utils import parse_time, formatTime from .fixtures import fixture_data, config, lookup_test_event event_group_id = "1.17.12" event_id = "1.18.2242" start_time = parse_time(formatTime(datetime.datetime.utcnow())) start_time_tomorrow = parse_time( formatTime(datetime.datetime.utcnow() + datetime.timedelta(days=1))) test_operation_dict = { "id": event_id, "name": [['en', 'Boston Celtics @ Atlanta Hawks']], "event_group_id": event_group_id, "season": [["en", "2017"]], "status": "upcoming", "start_time": "2022-10-16T00:00:00" } class Testcases(unittest.TestCase): def setUp(self):