| 
									
										
										
										
											2013-02-21 23:13:01 -05:00
										 |  |  | import boto | 
					
						
							| 
									
										
										
										
											2013-03-05 22:11:58 -05:00
										 |  |  | from boto.exception import EC2ResponseError | 
					
						
							| 
									
										
										
										
											2013-08-03 17:21:25 -04:00
										 |  |  | import sure  # noqa | 
					
						
							| 
									
										
										
										
											2014-08-25 10:54:47 -07:00
										 |  |  | from nose.tools import assert_raises | 
					
						
							| 
									
										
										
										
											2013-02-21 23:13:01 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | from moto import mock_ec2 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @mock_ec2 | 
					
						
							| 
									
										
										
										
											2013-03-05 22:11:58 -05:00
										 |  |  | def test_console_output(): | 
					
						
							|  |  |  |     conn = boto.connect_ec2('the_key', 'the_secret') | 
					
						
							|  |  |  |     reservation = conn.run_instances('ami-1234abcd') | 
					
						
							|  |  |  |     instance_id = reservation.instances[0].id | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     output = conn.get_console_output(instance_id) | 
					
						
							|  |  |  |     output.output.should_not.equal(None) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @mock_ec2 | 
					
						
							|  |  |  | def test_console_output_without_instance(): | 
					
						
							|  |  |  |     conn = boto.connect_ec2('the_key', 'the_secret') | 
					
						
							| 
									
										
										
										
											2014-08-25 10:54:47 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |     with assert_raises(EC2ResponseError) as cm: | 
					
						
							|  |  |  |         conn.get_console_output('i-1234abcd') | 
					
						
							|  |  |  |     cm.exception.code.should.equal('InvalidInstanceID.NotFound') | 
					
						
							|  |  |  |     cm.exception.status.should.equal(400) | 
					
						
							|  |  |  |     cm.exception.request_id.should_not.be.none |