<commit_before>Feature: Ingest Provider

    @auth
    Scenario: List empty providers
        Given empty "ingest_providers"
        When we get "/ingest_providers"
        Then we get list with 0 items

    @auth
    @notification
    Scenario: Create new ingest_provider
        Given empty "ingest_providers"
        When we post to "ingest_providers"
	    """
        [{
          "type": "reuters",
          "name": "reuters 4",
          "source": "reuters",
          "is_closed": false,
          "config": {"username": "foo", "password": "<PASSWORD>"}
        }]
	    """
        And we get "/ingest_providers"
        Then we get list with 1 items
	    """
        {"_items": [{
          "type": "reuters",
          "name": "reuters 4",
          "content_expiry": 2880,
          "source": "reuters",
          "is_closed": false,
          "config": {"username": "foo", "password": "<PASSWORD>"},
          "notifications": {
              "on_update": true,
              "on_error": true,
              "on_close": true,
              "on_open": true
          }
        }]}
	    """
        When we get "/activity/"
        Then we get existing resource
        """
        {"_items": [{"data": {"name": "reuters 4"}, "message": "created Ingest Channel {{name}}"}]}
        """
        Then we get notifications
        """
        [
          {"event": "activity", "extra": {"_dest": {"#CONTEXT_USER_ID#": 0}}},
          {"event": "ingest_provider:create", "extra": {"provider_id": "#ingest_providers._id#"}}
        ]
        """
        Then we get emails
        """
        [
          {"body": "created Ingest Channel reuters 4"}
        ]

        """

    @auth
    @notification
    Scenario: Update ingest_provider
        Given "ingest_providers"
	    """
        [{
        "type": "reuters",
        "name": "reuters 4",
        "source": "reuters",
        "is_closed": false,
        "config": {"username": "foo", "password": "<PASSWORD>"}
        }]
	    """
        When we patch "/ingest_providers/#ingest_providers._id#"
        """
        {"name":"the test of the test ingest_provider modified"}
        """
        Then we get updated response
        """
        {"name":"the test of the test ingest_provider modified"}
        """
        When we get "/activity/"
        Then we get existing resource
         """
         {"_items": [{"data": {"name": "the test of the test ingest_provider modified"}, "message": "updated Ingest Channel {{name}}"}]}
         """
        Then we get notifications
        """
        [{"event": "activity", "extra": {"_dest": {"#CONTEXT_USER_ID#": 0}}},
         {"event": "ingest_provider:create", "extra": {"provider_id": "#ingest_providers._id#"}},
         {"event": "ingest_provider:update", "extra": {"provider_id": "#ingest_providers._id#"}}]
        """
        Then we get emails
        """
        [
          {"body": "updated Ingest Channel the test of the test ingest_provider modified"}
        ]

        """

    @auth
    @notification
    Scenario: Open/Close ingest_provider
        Given "ingest_providers"
	    """
        [{
        "type": "reuters",
        "name": "reuters 4",
        "source": "reuters",
        "is_closed": false,
        "config": {"username": "foo", "password": "<PASSWORD>"}
        }]
	    """
        When we patch "/ingest_providers/#ingest_providers._id#"
        """
        {"is_closed": true}
        """
        Then we get updated response
        """
        {"is_closed": true}
        """
        When we get "/activity/"
        Then we get existing resource
         """
         {"_items":
            [
              {"data": {"name": "reuters 4"}, "message": "updated Ingest Channel {{name}}"},
              {"data": {"status": "closed", "name": "reuters 4"},
                "message": "{{status}} Ingest Channel {{name}}"
               }
            ]
         }<commit_msg>Modified the open close ingest provider behave test.<commit_after>Feature: Ingest Provider

    @auth
    Scenario: List empty providers
        Given empty "ingest_providers"
        When we get "/ingest_providers"
        Then we get list with 0 items

    @auth
    @notification
    Scenario: Create new ingest_provider
        Given empty "ingest_providers"
        When we post to "ingest_providers"
	    """
        [{
          "type": "reuters",
          "name": "reuters 4",
          "source": "reuters",
          "is_closed": false,
          "config": {"username": "foo", "password": "<PASSWORD>"}
        }]
	    """
        And we get "/ingest_providers"
        Then we get list with 1 items
	    """
        {"_items": [{
          "type": "reuters",
          "name": "reuters 4",
          "content_expiry": 2880,
          "source": "reuters",
          "is_closed": false,
          "config": {"username": "foo", "password": "<PASSWORD>"},
          "notifications": {
              "on_update": true,
              "on_error": true,
              "on_close": true,
              "on_open": true
          }
        }]}
	    """
        When we get "/activity/"
        Then we get existing resource
        """
        {"_items": [{"data": {"name": "reuters 4"}, "message": "created Ingest Channel {{name}}"}]}
        """
        Then we get notifications
        """
        [
          {"event": "activity", "extra": {"_dest": {"#CONTEXT_USER_ID#": 0}}},
          {"event": "ingest_provider:create", "extra": {"provider_id": "#ingest_providers._id#"}}
        ]
        """
        Then we get emails
        """
        [
          {"body": "created Ingest Channel reuters 4"}
        ]

        """

    @auth
    @notification
    Scenario: Update ingest_provider
        Given "ingest_providers"
	    """
        [{
        "type": "reuters",
        "name": "reuters 4",
        "source": "reuters",
        "is_closed": false,
        "config": {"username": "foo", "password": "<PASSWORD>"}
        }]
	    """
        When we patch "/ingest_providers/#ingest_providers._id#"
        """
        {"name":"the test of the test ingest_provider modified"}
        """
        Then we get updated response
        """
        {"name":"the test of the test ingest_provider modified"}
        """
        When we get "/activity/"
        Then we get existing resource
         """
         {"_items": [{"data": {"name": "the test of the test ingest_provider modified"}, "message": "updated Ingest Channel {{name}}"}]}
         """
        Then we get notifications
        """
        [{"event": "activity", "extra": {"_dest": {"#CONTEXT_USER_ID#": 0}}},
         {"event": "ingest_provider:create", "extra": {"provider_id": "#ingest_providers._id#"}},
         {"event": "ingest_provider:update", "extra": {"provider_id": "#ingest_providers._id#"}}]
        """
        Then we get emails
        """
        [
          {"body": "updated Ingest Channel the test of the test ingest_provider modified"}
        ]

        """

    @auth
    @notification
    Scenario: Open/Close ingest_provider
        Given "ingest_providers"
	    """
        [{
        "type": "reuters",
        "name": "reuters 4",
        "source": "reuters",
        "is_closed": false,
        "config": {"username": "foo", "password": "<PASSWORD>"}
        }]
	    """
        When we patch "/ingest_providers/#ingest_providers._id#"
        """
        {"is_closed": true, "last_closed": {"message": "system misbehaving."}}
        """
        Then we get updated response
        """
        {
          "is_closed": true,
          "last_closed": {"closed_by":"#CONTEXT_USER_ID#", "message": "system misbehaving."}
        }
        """
        When we get "/activity/"
        Then we get existing resource
         """
         {"_items":
            [
              {"data": {"name": "reuters 4"}, "message": "updated Ingest Channel {{name}}"},
              {"data": {"status": "closed", "name": "reuters 4"},
                "message": "{{status}} Ingest Channel {{name}}"
               }
            ]
         }
{'fraction_non_alphanumeric': 0.16111801242236024, 'fraction_numerical': 0.003975155279503106, 'mean_word_length': 1.8189775910364145, 'pattern_counts': {'":': 153, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7575330', 'n_tokens_mistral': 2372, 'n_tokens_neox': 2263, 'n_words': 612}