def handle(self, **options):
        with open(options['filename'], 'r') as fh:
            reader = csv.DictReader(fh)
            for row in reader:
                source = row.get('source', options.get('source'))
                if not row['democlub_id']:
                    continue
                if not source:
                    raise ValueError("A source is required")

                try:
                    bot = CandidateBot(row['democlub_id'])
                    try:
                        bot.add_email(row['email'])
                        bot.save(source)
                    except ValueError:
                        #Email exists, move on
                        pass
                except Person.DoesNotExist:
                    print("Person ID {} not found".format(row['democlub_id']))
 def test_add_email(self):
     bot = CandidateBot(self.person_extra.base.pk)
     bot.add_email("*****@*****.**")
     person = bot.save('a source')
     self.assertEqual(person.email, "*****@*****.**")
 def test_add_email(self):
     bot = CandidateBot(self.person.pk)
     bot.add_email("*****@*****.**")
     person = bot.save("a source")
     del person.get_all_idenfitiers
     self.assertEqual(person.get_email, "*****@*****.**")