#!/usr/bin/partner2-test -w
{
   "name" : "Получение списка правил",
   "options" : {
      "fields" : {
         "business_rules" : [
            "blocks_count",
            "caption",
            "cpm",
            "multistate_name",
            "position"
         ]
      },
      "mock_bk" : true,
      "read_only" : true
   },
   "tests" : [
      {
         "request" : {
            "method" : "get",
            "name" : "Получение всех доступных правил под $TOKEN",
            "token" : "mocked-yan-partner",
            "url" : "/v1/business_rules/?$FIELDS[business_rules]"
         },
         "response" : {
            "body" : {
               "data" : [
                  {
                     "attributes" : {
                        "blocks_count" : 2,
                        "caption" : "Rule #10 - working (mocked-yan-partner)",
                        "cpm" : 99,
                        "multistate_name" : "Working.",
                        "position" : 1
                     },
                     "id" : "10",
                     "links" : {
                        "self" : "https://127.0.0.1:80/v1/business_rules/10"
                     },
                     "relationships" : {},
                     "type" : "business_rules"
                  },
                  {
                     "attributes" : {
                        "blocks_count" : 0,
                        "caption" : "Rule #11 - working (mocked-yan-partner)",
                        "cpm" : 19,
                        "multistate_name" : "Working.",
                        "position" : 2
                     },
                     "id" : "11",
                     "links" : {
                        "self" : "https://127.0.0.1:80/v1/business_rules/11"
                     },
                     "relationships" : {},
                     "type" : "business_rules"
                  },
                  {
                     "attributes" : {
                        "blocks_count" : 0,
                        "caption" : "Rule #12 - stopped (mocked-yan-partner)",
                        "cpm" : 9999,
                        "multistate_name" : "Stopped.",
                        "position" : 3
                     },
                     "id" : "12",
                     "links" : {
                        "self" : "https://127.0.0.1:80/v1/business_rules/12"
                     },
                     "relationships" : {},
                     "type" : "business_rules"
                  },
                  {
                     "attributes" : {
                        "blocks_count" : 0,
                        "caption" : "Rule #13 - deleted (mocked-yan-partner)",
                        "cpm" : 29,
                        "multistate_name" : "Stopped.\nArchived.",
                        "position" : 3
                     },
                     "id" : "13",
                     "links" : {
                        "self" : "https://127.0.0.1:80/v1/business_rules/13"
                     },
                     "relationships" : {},
                     "type" : "business_rules"
                  }
               ],
               "links" : {
                  "add_fields" : "https://127.0.0.1:80/v1/business_rules/add_fields"
               },
               "meta" : {
                  "count" : 4,
                  "fields" : [
                     "blocks_count",
                     "caption",
                     "cpm",
                     "multistate_name",
                     "position"
                  ],
                  "filters" : [
                     {
                        "label" : "Block ID",
                        "name" : "block_public_id",
                        "type" : "text"
                     },
                     {
                        "label" : "Page ID",
                        "name" : "blocks.page_id",
                        "type" : "number"
                     },
                     {
                        "label" : "Business rule caption",
                        "name" : "caption",
                        "type" : "text"
                     },
                     {
                        "label" : "Multistate",
                        "name" : "multistate",
                        "type" : "multistate",
                        "values" : [
                           {
                              "id" : "deleted",
                              "label" : "Archived"
                           },
                           {
                              "id" : "need_update",
                              "label" : "Need update"
                           },
                           {
                              "id" : "stopped",
                              "label" : "Stopped"
                           },
                           {
                              "id" : "updating",
                              "label" : "Updating"
                           },
                           {
                              "id" : "working",
                              "label" : "Working"
                           }
                        ]
                     },
                     {
                        "label" : "Rule ID",
                        "name" : "rule_id",
                        "type" : "number"
                     }
                  ]
               }
            },
            "content_type" : "application/vnd.api+json",
            "status" : "200"
         }
      },
      {
         "request" : {
            "method" : "get",
            "name" : "Получение пустого множества правил c фильтром по чужому логину 'mocked-context-adblock-partner' под $TOKEN",
            "token" : "mocked-yan-partner",
            "url" : "/v1/business_rules/?$FIELDS[business_rules]&filter={\"users.login\":\"mocked-context-adblock-partner\"}"
         },
         "response" : {
            "body" : {
               "data" : [],
               "links" : {
                  "add_fields" : "https://127.0.0.1:80/v1/business_rules/add_fields"
               },
               "meta" : {
                  "count" : 0,
                  "fields" : [
                     "blocks_count",
                     "caption",
                     "cpm",
                     "multistate_name",
                     "position"
                  ],
                  "filters" : [
                     {
                        "label" : "Block ID",
                        "name" : "block_public_id",
                        "type" : "text"
                     },
                     {
                        "label" : "Page ID",
                        "name" : "blocks.page_id",
                        "type" : "number"
                     },
                     {
                        "label" : "Business rule caption",
                        "name" : "caption",
                        "type" : "text"
                     },
                     {
                        "label" : "Multistate",
                        "name" : "multistate",
                        "type" : "multistate",
                        "values" : [
                           {
                              "id" : "deleted",
                              "label" : "Archived"
                           },
                           {
                              "id" : "need_update",
                              "label" : "Need update"
                           },
                           {
                              "id" : "stopped",
                              "label" : "Stopped"
                           },
                           {
                              "id" : "updating",
                              "label" : "Updating"
                           },
                           {
                              "id" : "working",
                              "label" : "Working"
                           }
                        ]
                     },
                     {
                        "label" : "Rule ID",
                        "name" : "rule_id",
                        "type" : "number"
                     }
                  ]
               }
            },
            "content_type" : "application/vnd.api+json",
            "status" : "200"
         }
      }
   ]
}
