From 94aadca8b3ac9577a58245f313cdef9aee32c488 Mon Sep 17 00:00:00 2001
From: aha <edz@gengmeideMacBook-Pro.local>
Date: Thu, 22 Jul 2021 16:27:56 +0800
Subject: [PATCH] zhubo finish

---
 all_backend_api/live_request.py            |  9 ++++++++-
 all_backend_api/live_request.yaml          | 15 +++++++++++++--
 path_setting.py                            |  4 ++++
 test_backend_case/live_case/test_finish.py | 17 +++++++++++++++++
 test_backend_data/live_data/finish.yaml    |  7 +++++++
 5 files changed, 49 insertions(+), 3 deletions(-)
 create mode 100644 test_backend_case/live_case/test_finish.py
 create mode 100644 test_backend_data/live_data/finish.yaml

diff --git a/all_backend_api/live_request.py b/all_backend_api/live_request.py
index 66ca024..faebab0 100644
--- a/all_backend_api/live_request.py
+++ b/all_backend_api/live_request.py
@@ -34,8 +34,15 @@ class living_request(BaseRequest):
         self.params["version"] = version
         return self.api_send(self.data["leave"])
 
+    #直播结束-主播下播
+    def finish(self,channel_id, version, device_id="97B6764B-2135-4761-9911-701C38CBC272"):
+        self.params["channel_id"] = channel_id
+        self.params["version"] = version
+        return self.api_send(self.data["finish"])
+
 
 
 if __name__ == '__main__':
     (living_request().danmu_v2("739", "1"))
-    (living_request().pushlive_info("小冤家", "2021/04/22/1003/cef471cff5e6", "", "1", "1", "1"))
\ No newline at end of file
+    (living_request().pushlive_info("小冤家", "2021/04/22/1003/cef471cff5e6", "", "1", "1", "1"))
+    print(living_request().finish("745", "746.0"))
\ No newline at end of file
diff --git a/all_backend_api/live_request.yaml b/all_backend_api/live_request.yaml
index 6261ac5..1fa7211 100644
--- a/all_backend_api/live_request.yaml
+++ b/all_backend_api/live_request.yaml
@@ -26,7 +26,7 @@ pushlive_info:
 
 #观众进入直播间
 enter:
-  method: get
+  method: GET
   url: /api/live/enter
   params:
     channel_id: ${channel_id}
@@ -38,7 +38,7 @@ enter:
 
 #观众离开直播间
 leave:
-  method: get
+  method: GET
   url: /api/live/leave
   params:
     channel_id: ${channel_id}
@@ -47,4 +47,15 @@ leave:
   json: {}
   isLogin: 1
 
+#直播结束-主播下播
+finish:
+  method: POST
+  url: /api/live/finish
+  params:
+    version: ${version}
+  data:
+    channel_id: ${channel_id}
+  json: {}
+  isLogin: 1
+
 
diff --git a/path_setting.py b/path_setting.py
index de97f0d..96ce66f 100644
--- a/path_setting.py
+++ b/path_setting.py
@@ -587,6 +587,10 @@ ENTER = os.path.join(BASE_DIR, "backend_auto/test_backend_data/live_data", "ente
 LEAVE_CONFIG = os.path.join(BASE_DIR, "backend_auto/all_backend_api", "live_request.yaml")
 LEAVE = os.path.join(BASE_DIR, "backend_auto/test_backend_data/live_data", "leave.yaml")
 
+#直播结束-主播下播
+FINISH_CONFIG = os.path.join(BASE_DIR, "backend_auto/all_backend_api", "live_request.yaml")
+FINISH = os.path.join(BASE_DIR, "backend_auto/test_backend_data/live_data", "finish.yaml")
+
 #主播标记讲解商品+取消标记
 MARK_LIVE_SERVICE_CONFIG = os.path.join(BASE_DIR, "backend_auto/all_backend_api", "janus_live_request.yaml")
 MARK_LIVE_SERVICE = os.path.join(BASE_DIR, "backend_auto/test_backend_data/janus_live_data", "mark_live_service.yaml")
diff --git a/test_backend_case/live_case/test_finish.py b/test_backend_case/live_case/test_finish.py
new file mode 100644
index 0000000..a966469
--- /dev/null
+++ b/test_backend_case/live_case/test_finish.py
@@ -0,0 +1,17 @@
+import pytest
+from ids_list import get_ids
+import path_setting
+from in_common.base_request import BaseRequest
+from all_backend_api.live_request import living_request
+
+
+class TestFinish:
+    data = BaseRequest().api_load(path_setting.FINISH)
+    finish_case, finish_data = get_ids(data,"finish")
+
+    @pytest.mark.parametrize("param", finish_data, ids=finish_case)
+    def test_finish(self, param):
+        r = living_request().finish(param["channel_id"], param["version"])
+        print("主播下播了,呜呜呜")
+        if r["error"] == 0:
+            assert r["error"] == param["assert"]
\ No newline at end of file
diff --git a/test_backend_data/live_data/finish.yaml b/test_backend_data/live_data/finish.yaml
new file mode 100644
index 0000000..f0e68ff
--- /dev/null
+++ b/test_backend_data/live_data/finish.yaml
@@ -0,0 +1,7 @@
+finish:
+#主播下播了,呜呜呜
+  -
+    case: "主播下播了,呜呜呜"
+    channel_id: "745"
+    version: "7.45.0"
+    assert: 0
\ No newline at end of file
-- 
2.18.0