コード例 #1
0
    def test_edit_invalid_value(self):
        # First, make sure we can't do this
        bot = CandidateBot(self.person.pk)
        with self.assertRaises(ValueError):
            bot.edit_field("email", "INVALID")

        # Now, ignore errors and verify nothing changes, but no errors
        # are raised
        bot = CandidateBot(self.person.pk)
        bot.IGNORE_ERRORS = True
        bot.edit_field("email", "INVALID")
        person = bot.save("a source")
        self.assertEqual(person.get_email, None)
コード例 #2
0
    def test_update_field(self):
        self.person.tmp_person_identifiers.create(value_type="email",
                                                  value="*****@*****.**")
        self.assertEqual(self.person.get_email, "*****@*****.**")
        bot = CandidateBot(self.person.pk)
        bot.edit_field("email", "*****@*****.**", update=True)
        person = bot.save("a source")
        self.assertEqual(person.get_email, "*****@*****.**")

        # Now test this doesn't work if update==False
        bot = CandidateBot(self.person.pk)
        with self.assertRaises(IntegrityError):
            bot.edit_field("email", "*****@*****.**", update=False)

        # Now test we can ignore the above error if we want to
        bot = CandidateBot(self.person.pk)
        bot.IGNORE_ERRORS = True
        bot.edit_field("email", "*****@*****.**", update=False)
        person = bot.save("a source")
        # The edit failed, but didn't raise an error
        self.assertEqual(person.get_email, "*****@*****.**")
コード例 #3
0
 def test_cant_edit_linkedin(self):
     bot = CandidateBot(self.person.pk)
     with self.assertRaises(ValueError):
         bot.edit_field("linkedin", "https://linkedin.com/CandidateBot")