Exemple #1
0
    def test_limit_ip_results_only_range_entry(self):
        """
        Given
            - IPs data that contains only ranges
            - Limit value
        When
            - limit value will be applied only to ranges entry
        Then
            - data will have a Range list with up to 'limit' entries
        """
        data = {'Range': ['1.4.3.1-1.4.3.5', '1.4.3.6-1.4.3.9']}
        limit = 1

        limit_ip_results(data, limit)
        assert len(data['Range']) == 1
Exemple #2
0
    def test_limit_ip_results_single_ip_and_range(self):
        """
        Given
            - arguments received by the user
            - command name to be run
        When
            - all arguments where provided and there are only API args
        Then
            - create a dictionary with all the arguments
        """
        data = {'Address': '1.1.1.1', 'Range': '1.4.3.1-1.4.3.5'}
        limit = 1

        limit_ip_results(data, limit)
        assert data['Address'] == '1.1.1.1'
        assert len(data['Range']) == 0
Exemple #3
0
    def test_limit_ip_results_low_limit(self):
        """
        Given
            - IPs data that contains both single IP's and ranges
            - Limit value
        When
            - Limit values is low
        Then
            - Data will be changed so only Address's list can be shown
        """
        data = {
            'Address': ['1.1.1.1', '1.2.3.4'],
            'Range': ['1.4.3.1-1.4.3.5', '1.4.3.6-1.4.3.9']
        }
        limit = 1

        limit_ip_results(data, limit)
        assert len(data['Address']) == 1
        assert len(data['Range']) == 0
Exemple #4
0
    def test_limit_ip_results_high_limit(self):
        """
        Given
            - IPs data that contains both single IP's and ranges
            - Limit value
        When
            - the limit value is high enough so data will be taken from both lists
        Then
            - Change the lists so all addresses will show and part of the Ranges
        """
        data = {
            'Address': ['1.1.1.1', '1.2.3.4'],
            'Range': ['1.4.3.1-1.4.3.5', '1.4.3.6-1.4.3.9']
        }
        limit = 3

        data = limit_ip_results(data, limit)
        assert len(data['Address']) == 2
        assert len(data['Range']) == 1