def testAddTeam(self): # add a league and a sponsor sponsor = self.add_sponsor("Test Import Sponsor") league = self.add_league("Test Import League") color = "Pink" # set the logger logging.basicConfig(level=logging.INFO, format='%(asctime)s %(message)s') logger = logging.getLogger(__name__) lines = ["Sponsor:,{},".format(sponsor['sponsor_name']), "Color:,{},".format(color), "Captain:,Test Captain,", "League:,{},".format(league['league_name']), "Player Name,Player Email,Gender (M/F)" "Laura Visentin,[email protected],F", "Test Captain,[email protected],M", "Test Girl,[email protected],F", "Test Boy,[email protected],M"] importer = TeamList(lines, logger=logger, session=MockSession(self)) # no point checking for errors that were tested above importer.add_team() self.assertEqual(importer.warnings, ['Team was created'], "Should be no warnings")
def admin_import_team_list(): results = {'errors': [], 'success':False, 'warnings': []} if not logged_in(): results['errors'].append("Permission denied") return dumps(results) file = request.files['file'] result = None if file and allowed_file(file.filename): content = (file.read()).decode("UTF-8") lines = content.replace("\r", "") lines = lines.split("\n") team = TeamList(lines) team.add_team() result = team.warnings else: raise InvalidField(payload={'detail': "File format not accepted (csv)"}) return dumps(result)
def admin_import_team_list(): results = {'errors': [], 'success': False, 'warnings': []} if not logged_in(): results['errors'].append("Permission denied") return dumps(results) file = request.files['file'] result = None if file and allowed_file(file.filename): content = (file.read()).decode("UTF-8") lines = content.replace("\r", "") lines = lines.split("\n") team = TeamList(lines) team.add_team() result = team.warnings else: s = "File format not accepted (csv)" raise InvalidField(payload={'detail': s}) return dumps(result)
def testAddTeam(self): logging.basicConfig(level=logging.INFO, format='%(asctime)s %(message)s') logger = logging.getLogger(__name__) lines = [ "Sponsor:,Domus,", "Color:,Pink,", "Captain:,Dallas Fraser,", "League:,Monday & Wedneday,", "Player Name,Player Email,Gender (M/F)" "Laura Visentin,[email protected],F", "Dallas Fraser,[email protected],M", "Mitchell Ellul,[email protected],M", "Mitchell Ortofsky,[email protected],M", "Adam Shaver,[email protected],M", "Taylor Takamatsu,[email protected],F", "Jordan Cross,[email protected],M", "Erin Niepage,[email protected],F", "Alex Diakun,[email protected],M", "Kevin Holmes,[email protected],M", "Kevin McGaire,[email protected],M", "Kyle Morrison,[email protected],M", "Ryan Lackey,[email protected],M", "Rory Landy,[email protected],M", "Claudia Vanderholst,[email protected],F", "Luke MacKenzie,[email protected],M", "Jaron Wu,[email protected],M", "Tea Galli,[email protected],F", "Cara Hueston ,[email protected],F", "Derek Schoenmakers,[email protected],M", "Marni Shankman,[email protected],F", "Christie MacLeod ,[email protected],F" ] importer = TeamList(lines, logger=logger) self.addLeagues() self.addSponsors() # no point checking for errors that were tested above importer.add_team() self.assertEqual(importer.warnings, ['Team was created'], "Should be no warnings")