示例#1
0
    def test_dry_run_honored(self):
        self.state.return_value.exists.return_value = False
        integ.run(True)

        self.get_encrypted_credentials.assert_called_once()
        self.do_exit.assert_not_called()
        self.smtpclient.return_value.send_mail.assert_not_called()
        self.state.return_value.add.assert_not_called()
示例#2
0
 def test_invalid_credentials(self):
     self.get_encrypted_credentials.side_effect = CalledProcessError(
         stderr="iadaiada", returncode=1, cmd="a command")
     self.state.return_value.exists.return_value = False
     integ.run(False)
     self.do_exit.assert_called_once()
     self.get_encrypted_credentials.assert_called_once()
     self.smtpclient.return_value.send_mail.assert_not_called()
示例#3
0
 def test_valid_credentials(self):
     # Yeah, yeah, whatever
     self.state.return_value.exists.return_value = False
     integ.run(False)
     # This has succeeded
     self.do_exit.assert_not_called()
     self.get_encrypted_credentials.assert_called_once_with(
         "credentials_name", self.user, self.settings)
     calls = self.smtpclient.return_value.send_mail.call_args_list
     self.assertEqual(len(calls), 1)
     # I don't care too much about the body of the email, TBH
     self.assertEqual(calls[0][0][:-1], (["myorg"], "aname"))
     # Just check that we're still sending the encrypted credential
     # in the body. This assertion is backwards with regards to all
     # other assertions :(
     self.assertIn("anencryptedcred", calls[0][0][-1])
示例#4
0
 def test_existing_credentials(self):
     self.state.return_value.exists.return_value = True
     integ.run(False)
     self.do_exit.assert_not_called()
     self.get_encrypted_credentials.assert_not_called()
     self.smtpclient.return_value.send_mail.assert_not_called()