| 
									
										
										
										
											2019-02-16 20:53:27 -06:00
										 |  |  | # #!/usr/bin/env python | 
					
						
							|  |  |  | # -*- coding: utf-8 -*- | 
					
						
							|  |  |  | from __future__ import unicode_literals | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-31 08:44:26 -07:00
										 |  |  | from moto.packages.httpretty.core import ( | 
					
						
							|  |  |  |     HTTPrettyRequest, | 
					
						
							|  |  |  |     fake_gethostname, | 
					
						
							|  |  |  |     fake_gethostbyname, | 
					
						
							|  |  |  | ) | 
					
						
							| 
									
										
										
										
											2019-02-16 20:53:27 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | def test_parse_querystring(): | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-31 08:44:26 -07:00
										 |  |  |     core = HTTPrettyRequest(headers="test test HTTP/1.1") | 
					
						
							| 
									
										
										
										
											2019-02-16 20:53:27 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-31 08:44:26 -07:00
										 |  |  |     qs = "test test" | 
					
						
							| 
									
										
										
										
											2019-02-16 20:53:27 -06:00
										 |  |  |     response = core.parse_querystring(qs) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     assert response == {} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-31 08:44:26 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-16 20:53:27 -06:00
										 |  |  | def test_parse_request_body(): | 
					
						
							| 
									
										
										
										
											2019-10-31 08:44:26 -07:00
										 |  |  |     core = HTTPrettyRequest(headers="test test HTTP/1.1") | 
					
						
							| 
									
										
										
										
											2019-02-16 20:53:27 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-31 08:44:26 -07:00
										 |  |  |     qs = "test" | 
					
						
							| 
									
										
										
										
											2019-02-16 20:53:27 -06:00
										 |  |  |     response = core.parse_request_body(qs) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-31 08:44:26 -07:00
										 |  |  |     assert response == "test" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-16 20:53:27 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  | def test_fake_gethostname(): | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-31 08:44:26 -07:00
										 |  |  |     response = fake_gethostname() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     assert response == "localhost" | 
					
						
							| 
									
										
										
										
											2019-02-16 20:53:27 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | def test_fake_gethostbyname(): | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-31 08:44:26 -07:00
										 |  |  |     host = "test" | 
					
						
							| 
									
										
										
										
											2019-02-16 20:53:27 -06:00
										 |  |  |     response = fake_gethostbyname(host=host) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-31 08:44:26 -07:00
										 |  |  |     assert response == "127.0.0.1" |