def test_write_cert_file(self, mock_open): mock_file = mock.Mock() mock_open.return_value.__enter__.return_value = mock_file custom._write_cert_file("cert", "publickey-aadcert.pub") mock_open.assert_called_once_with("publickey-aadcert.pub", 'w') mock_file.write.assert_called_once_with( "[email protected] cert")
def test_write_cert_file(self, mock_open, mock_split, mock_join): mock_file = mock.Mock() mock_open.return_value.__enter__.return_value = mock_file mock_split.return_value = ["path", "to", "publickey"] file_name = custom._write_cert_file("public", "cert") self.assertEqual(mock_join.return_value, file_name) mock_split.assert_called_once_with("public") mock_join.assert_called_once_with("path", "to", "id_rsa-cert.pub") mock_open.assert_called_once_with(mock_join.return_value, 'w') mock_file.write.assert_called_once_with("[email protected] cert")