Skip to content

Commit

Permalink
test: cover empty AdvancedDataTypes internet_address and internet_port (
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianliebscher authored May 11, 2023
1 parent 0788b5f commit c8beaab
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions tests/unit_tests/advanced_data_type/types_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,29 @@ def test_cidr_func_invalid_ip():
assert internet_address.translate_type(cidr_request) == cidr_response


def test_cidr_func_empty_ip():
"""Test to see if the cidr_func behaves as expected when no IP is passed in"""
cidr_request: AdvancedDataTypeRequest = {
"advanced_data_type": "cidr",
"values": [""],
}
cidr_response: AdvancedDataTypeResponse = {
"values": [""],
"error_message": "",
"display_value": "",
"valid_filter_operators": [
FilterStringOperators.EQUALS,
FilterStringOperators.GREATER_THAN_OR_EQUAL,
FilterStringOperators.GREATER_THAN,
FilterStringOperators.IN,
FilterStringOperators.LESS_THAN,
FilterStringOperators.LESS_THAN_OR_EQUAL,
],
}

assert internet_address.translate_type(cidr_request) == cidr_response


def test_port_translation_func_valid_port_number():
"""Test to see if the port_translation_func behaves as expected when a valid port number
is passed in"""
Expand Down Expand Up @@ -175,6 +198,30 @@ def test_port_translation_func_invalid_port_number():
assert port.translate_type(port_request) == port_response


def test_port_translation_func_empty_port_number():
"""Test to see if the port_translation_func behaves as expected when no port
number is passed in"""
port_request: AdvancedDataTypeRequest = {
"advanced_data_type": "port",
"values": [""],
}
port_response: AdvancedDataTypeResponse = {
"values": [[""]],
"error_message": "",
"display_value": "",
"valid_filter_operators": [
FilterStringOperators.EQUALS,
FilterStringOperators.GREATER_THAN_OR_EQUAL,
FilterStringOperators.GREATER_THAN,
FilterStringOperators.IN,
FilterStringOperators.LESS_THAN,
FilterStringOperators.LESS_THAN_OR_EQUAL,
],
}

assert port.translate_type(port_request) == port_response


def test_cidr_translate_filter_func_equals():
"""Test to see if the cidr_translate_filter_func behaves as expected when the EQUALS
operator is used"""
Expand Down

0 comments on commit c8beaab

Please sign in to comment.