コード例 #1
0
def test_fetch_indicators_command(category_list, expected_indicators):
    """
    Given:
    - Global feed url and category list.
    (A) - Full category list.
    (B) - Category list containing only Optimize.
    (C) - Category list containing only Allow.

    When:
     - Fetching incidents.

    Then:
     - Ensure that the incidents returned are as expected.
     (A) - all incidents from response are handled and returned.
     (B) - only incidents with 'Optimize' category are returned.
    (C) - Empty list as there aren't any indicators with 'Allow' category.
    """
    with requests_mock.Mocker() as mock:
        url_dict = {
            "FeedURL": 'https://endpoints.office.com/endpoints/worldwide',
            "Region": 'Worldwide',
            "Service": 'Any'
        }
        mock.get(url_dict.get('FeedURL'), json=RESPONSE_DATA)
        client = Client([url_dict], category_list)
        indicators = fetch_indicators_command(client)
        assert len(indicators) == expected_indicators
コード例 #2
0
def test_fetch_indicators_command():
    with requests_mock.Mocker() as mock:
        url_dict = {
            "FeedURL": 'https://endpoints.office.com/endpoints/worldwide',
            "Region": 'Worldwide',
            "Service": 'Any'
        }
        mock.get(url_dict.get('FeedURL'), json=RESPONSE_DATA)
        client = Client([url_dict])
        indicators = fetch_indicators_command(client)
        assert len(indicators) == 10