moto/tests/test_packages/test_httpretty.py

44 lines
801 B
Python
Raw Normal View History

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