Ejemplo n.º 1
0
 def test_roster(self):
     rmgr = RosterManagerFacade(self.entmgr)
     recs = util.runCoroutine(rmgr.sync())
     dbrecs = util.runCoroutine(rmgr.find())
     self.assertLessEqual(len(dbrecs), len(recs),
                          "db records lengths differ")
     self.assertGreater(len([r for r in dbrecs if "previous_teams" in r]),
                        0, "previous_teams not set")
Ejemplo n.º 2
0
 def test_miss_pl_abbrv(self):
     mgr = RosterManagerFacade(self.entmgr)
     mpabb = readData("game_play_miss_plabb.json")
     qd = makeLastNameDict(mpabb, getLastNameFromAbbr)
     rdata = [
         d for d in util.runCoroutine(mgr.find(last_names=list(qd.keys())))
         if d["position"] in ["QB", "RB", "WR", "TE", "K"]
     ]
     rd = makeLastNameDict(rdata, lambda d: d["last_name"])
     hdata = readData("historic_roster.json", "data")
     hd = makeLastNameDict(hdata, lambda d: d["last_name"])
     updated = False
     for k in qd:
         if k in rd:
             for qr in qd[k]:
                 mrost = [
                     r for r in rd[k]
                     if matchAbbr(r, qr["player_abrv_name"])
                 ]
                 if len(mrost) == 1:
                     mhist = None
                     if k in hd:
                         # mhista = [r for r in hd[k] if matchAbbr(r, qr["player_abrv_name"]) and r["position"] in ["QB", "RB", "WR", "TE", "K"]]
                         mhista = []
                         for r in hd[k]:
                             if isinstance(r, list):
                                 mhista.extend(r)
                             else:
                                 mhista.append(r)
                         if len(mhista) == 1:
                             mhist = mhista[0]
                     if mhist is None:
                         mhist = mrost[0]
                         hdata.append(mhist)
                         if k in hd:
                             hd[k].append(mhist)
                         else:
                             hd[k] = [mhista]
                     pt = set([])
                     if "previous_teams" in mhist:
                         pt = set(mhist["previous_teams"])
                     pt.add(qr["team"])
                     ptl = list(pt)
                     ptl.sort()
                     mhist["previous_teams"] = ptl
                     updated = True
     if updated:
         writeData(convertDateToString(hdata), "historic_roster.json",
                   "data")
     self.assertTrue(updated)
Ejemplo n.º 3
0
 def _rosterManager(self):
     if self._rostmgr is None:
         self._rostmgr = RosterManagerFacade(self._entityManager,
                                             self._apiClient, self._tmgr)
     return self._rostmgr
Ejemplo n.º 4
0
 def _rosterManager(self) -> RosterManagerFacade:
     if self._roster_mgr is None:
         self._roster_mgr = RosterManagerFacade(self._entityManager,
                                                self._apiClient,
                                                self._teamManager)
     return self._roster_mgr
Ejemplo n.º 5
0
 def _getRosterManager(self):
     self.datamgr = RosterManagerFacade(self.entmgr)
     return self.datamgr