Add docstrings
This commit is contained in:
@@ -6,6 +6,7 @@ import argparse
|
|||||||
|
|
||||||
|
|
||||||
def parse_args(): # pragma: no cover
|
def parse_args(): # pragma: no cover
|
||||||
|
"""Get arguments from CLI."""
|
||||||
parser = argparse.ArgumentParser(description="Get 6to4 address from IPv4 address.")
|
parser = argparse.ArgumentParser(description="Get 6to4 address from IPv4 address.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-a",
|
"-a",
|
||||||
@@ -19,6 +20,7 @@ def parse_args(): # pragma: no cover
|
|||||||
|
|
||||||
|
|
||||||
def ipv4_to_ipv6(ipv4):
|
def ipv4_to_ipv6(ipv4):
|
||||||
|
"""COnvert IPv4 address to IPv6."""
|
||||||
ipv4_hex = ""
|
ipv4_hex = ""
|
||||||
ipv6_hextets = ["", ""]
|
ipv6_hextets = ["", ""]
|
||||||
|
|
||||||
@@ -49,6 +51,7 @@ def ipv4_to_ipv6(ipv4):
|
|||||||
|
|
||||||
|
|
||||||
def main(): # pragma: no cover
|
def main(): # pragma: no cover
|
||||||
|
"""Main function."""
|
||||||
ipv4 = parse_args().address
|
ipv4 = parse_args().address
|
||||||
output = ipv4_to_ipv6(ipv4)
|
output = ipv4_to_ipv6(ipv4)
|
||||||
print(output)
|
print(output)
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
from app.main import ipv4_to_ipv6
|
from app.main import ipv4_to_ipv6
|
||||||
|
|
||||||
|
|
||||||
def test_ipv4_to_ipv6():
|
def test_ipv4_to_ipv6():
|
||||||
result = ipv4_to_ipv6('192.168.0.1')
|
"""Test case for ipv4_to_ipv6()."""
|
||||||
|
result = ipv4_to_ipv6("192.168.0.1")
|
||||||
assert result == "2002:c0a8:1::/128"
|
assert result == "2002:c0a8:1::/128"
|
||||||
|
|||||||
Reference in New Issue
Block a user