def test_opportunity(self): account = Account(name="John SARL") opty = Opportunity(name="1000 widgets") opty.account = account self.check_editable(opty) d = opty.to_dict() j = opty.to_json()
def load_opportunities(self): reader = self.get_reader("Opportunities.csv") for line in reader: d = {} for col in ['Name', 'Description', 'Type']: d[col.lower().replace(" ", "_")] = line[col] d['stage'] = line['Sales Stage'] d['amount'] = line['Opportunity Amount'][3:] d['close_date'] = self.parse_date(line['Expected Close Date']) d['probability'] = line['Probability (%)'] opportunity = Opportunity(**d) opportunity.creator_id = choice(self.users).uid opportunity.owner_id = choice(self.users).uid account = self.accounts_map.get(line['Account Name']) if not account: print "Skipping account", line['Account Name'] continue opportunity.account = account self.db.session.add(opportunity)