Пример #1
0
    def test_config_traffic_ip_groups_get_bad(self, responses):
        base_response(responses)

        tigs = TrafficIPGroups(**stingray_args)
        with pytest.raises(
                StingrayAPIClientError,
                match="Traffic IP Group BadGroup not found"):
            tigs.get('BadGroup')
Пример #2
0
    def test_config_traffic_ip_groups_add_bad_args(self, responses):
        base_response(responses)

        tigs = TrafficIPGroups(**stingray_args)
        with pytest.raises(
                StingrayAPIClientError,
                match="No IP addresses specified, unable to create Traffic IP group"):
            tigs.add('TestGroup')
Пример #3
0
    def test_config_traffic_ip_groups_get(self, responses):
        base_response(responses)

        responses.add(
            responses.GET,
            '{0}www.example.com'.format(base),
            json=ctigr.traffic_ip_group
        )

        tigs = TrafficIPGroups(**stingray_args)
        tig = tigs.get('www.example.com')
        assert isinstance(tig, TrafficIPGroup)
Пример #4
0
    def test_config_traffic_ip_groups_add_with_props(self, responses):
        base_response(responses)

        responses_callback(responses, 'TestGroup')

        tigs = TrafficIPGroups(**stingray_args)
        tig = tigs.add('TestGroup', ipaddresses=['192.168.100.2'],
                       machines=[tigs.api_host], mode='ec2vpcelastic',
                       basic=dict(ip_assignment_mode='alphabetic'))
        assert isinstance(tig, TrafficIPGroup)
        assert tig.properties['basic']['ip_assignment_mode'] == "alphabetic"
        assert tig.properties['basic']['mode'] == "ec2vpcelastic"
Пример #5
0
    def test_config_traffic_ip_groups_delete(self, responses):
        base_response(responses)

        responses.add(
            responses.DELETE,
            '{0}www.example.com'.format(base),
            status=204
        )

        tigs = TrafficIPGroups(**stingray_args)
        del_response = tigs.delete('www.example.com')
        assert del_response['success'] == "Resource has been removed"
        assert len(tigs.traffic_ip_groups) == 2
        assert 'www.example.com' not in tigs.traffic_ip_groups
Пример #6
0
    def test_config_traffic_ip_groups_add(self, responses):
        base_response(responses)

        responses.add(
            responses.GET,
            'https://stingray:9070/api/tm/5.2/config/active/traffic_managers',
            json=ctigr.traffic_managers
        )

        responses_callback(responses, 'TestGroup')

        tigs = TrafficIPGroups(**stingray_args)
        tig = tigs.add('TestGroup', ipaddresses=['192.168.100.2'])
        assert len(tigs.traffic_ip_groups) == 4
        assert tig.name in tigs.traffic_ip_groups
        assert isinstance(tig, TrafficIPGroup)
Пример #7
0
    def test_config_traffic_ip_groups_init(self, responses):
        base_response(responses)

        tigs = TrafficIPGroups(**stingray_args)
        assert isinstance(tigs, TrafficIPGroups)
        assert tigs.config_path == "5.2/config/active/traffic_ip_groups/"
        assert len(tigs.traffic_ip_groups) == 3
        assert tigs.traffic_ip_groups['www.example.com'] == "/api/tm/5.2/config/active/traffic_ip_groups/www.example.com"