#!/usr/bin/partner2-test -w
{
   "name" : "Редактирование существующего правила",
   "options" : {
      "mock_bk" : true,
      "read_only" : false
   },
   "testcases" : "",
   "tests" : [
      {
         "request" : {
            "body" : {
               "data" : {
                  "attributes" : {
                     "blocks" : [
                        "R-A-41443-2"
                     ],
                     "conditions" : {
                        "browsers" : [
                           28,
                           55
                        ],
                        "devices" : [
                           "tablet",
                           "mobile"
                        ],
                        "query_args" : {
                           "puid10" : [
                              "xxx",
                              "yy"
                           ],
                           "puid20" : [
                              "foo"
                           ]
                        },
                        "regions" : [
                           73,
                           225,
                           11450
                        ],
                        "systems" : [
                           4,
                           15
                        ],
                        "urls" : [
                           "https://mail.ru"
                        ]
                     },
                     "cpm" : 15
                  },
                  "id" : "11",
                  "type" : "business_rules"
               }
            },
            "method" : "patch",
            "name" : "Редактирование правила (mocked-yan-partner) под $TOKEN - без headers и query_args.adb_enabled",
            "token" : "mocked-yan-partner",
            "url" : "/v1/business_rules/11"
         },
         "response" : {
            "body" : {
               "data" : {
                  "attributes" : {
                     "blocks" : [
                        "R-A-41443-2"
                     ],
                     "conditions" : {
                        "browsers" : [
                           28,
                           55
                        ],
                        "devices" : [
                           "tablet",
                           "mobile"
                        ],
                        "query_args" : {
                           "puid10" : [
                              "xxx",
                              "yy"
                           ],
                           "puid20" : [
                              "foo"
                           ]
                        },
                        "regions" : [
                           73,
                           225,
                           11450
                        ],
                        "systems" : [
                           4,
                           15
                        ],
                        "urls" : [
                           "https://mail.ru"
                        ]
                     },
                     "cpm" : 15
                  },
                  "id" : "11",
                  "relationships" : {},
                  "type" : "business_rules"
               },
               "links" : {
                  "self" : "https://127.0.0.1:80/v1/business_rules/11"
               },
               "meta" : {
                  "fields" : [
                     "blocks",
                     "conditions",
                     "cpm"
                  ]
               }
            },
            "content_type" : "application/vnd.api+json",
            "status" : "200"
         }
      },
      {
         "request" : {
            "body" : {
               "data" : {
                  "attributes" : {
                     "conditions" : {
                        "query_args" : {
                           "adb_enabled" : [
                              1
                           ],
                           "puid10" : [
                              "foo"
                           ]
                        }
                     }
                  },
                  "id" : "11",
                  "type" : "business_rules"
               }
            },
            "method" : "patch",
            "name" : "Пытаемся добавить условие на 'adb_enabled' под $TOKEN",
            "token" : "mocked-yan-partner",
            "url" : "/v1/business_rules/11"
         },
         "response" : {
            "body" : {
               "errors" : [
                  {
                     "detail" : "Extra values: adb_enabled",
                     "id" : "4",
                     "source" : {
                        "pointer" : "/data/attributes/conditions/query_args"
                     },
                     "title" : "Validation error"
                  }
               ]
            },
            "content_type" : "application/vnd.api+json",
            "status" : "400"
         }
      },
      {
         "request" : {
            "body" : {
               "data" : {
                  "attributes" : {
                     "cpm" : 9999
                  },
                  "id" : "21",
                  "type" : "business_rules"
               }
            },
            "method" : "patch",
            "name" : "Редактирование чужого (mocked-context-adblock-partner) правила под $TOKEN",
            "token" : "mocked-yan-partner",
            "url" : "/v1/business_rules/21"
         },
         "response" : {
            "body" : {
               "errors" : [
                  {
                     "detail" : "Not found 21",
                     "id" : "2",
                     "title" : "Conflict"
                  }
               ]
            },
            "content_type" : "application/vnd.api+json",
            "status" : "409"
         }
      },
      {
         "request" : {
            "body" : {
               "data" : {
                  "attributes" : {
                     "insert_before" : 10
                  },
                  "id" : "11",
                  "type" : "business_rules"
               }
            },
            "method" : "patch",
            "name" : "Пытаемся move при edit (передаем 'insert_before') под $TOKEN",
            "token" : "mocked-yan-manager",
            "url" : "/v1/business_rules/11"
         },
         "response" : {
            "body" : {
               "errors" : [
                  {
                     "detail" : "You can not edit the following fields: insert_before",
                     "id" : "4",
                     "source" : {
                        "pointer" : "/data/attributes/"
                     },
                     "title" : "Validation error"
                  }
               ]
            },
            "content_type" : "application/vnd.api+json",
            "status" : "400"
         }
      }
   ]
}
