From 37325c70bad38b7b4db5846a43c293cca10ae5a5 Mon Sep 17 00:00:00 2001 From: Blake Blackshear Date: Fri, 22 Jul 2022 07:56:28 -0500 Subject: [PATCH] fix plus enabled for addons --- frigate/http.py | 4 ++-- frigate/test/test_http.py | 21 +++++++++++---------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/frigate/http.py b/frigate/http.py index 323e8b476..b7ed51783 100644 --- a/frigate/http.py +++ b/frigate/http.py @@ -25,7 +25,7 @@ from flask import ( from peewee import SqliteDatabase, operator, fn, DoesNotExist from playhouse.shortcuts import model_to_dict -from frigate.const import CLIPS_DIR, PLUS_ENV_VAR +from frigate.const import CLIPS_DIR from frigate.models import Event, Recordings from frigate.stats import stats_snapshot from frigate.version import VERSION @@ -571,7 +571,7 @@ def config(): for cmd in camera_dict["ffmpeg_cmds"]: cmd["cmd"] = " ".join(cmd["cmd"]) - config["plus"] = {"enabled": PLUS_ENV_VAR in os.environ} + config["plus"] = {"enabled": current_app.plus_api.is_active()} return jsonify(config) diff --git a/frigate/test/test_http.py b/frigate/test/test_http.py index ca8f578b1..04acdd681 100644 --- a/frigate/test/test_http.py +++ b/frigate/test/test_http.py @@ -13,6 +13,7 @@ from playhouse.shortcuts import model_to_dict from frigate.config import FrigateConfig from frigate.http import create_app from frigate.models import Event, Recordings +from frigate.plus import PlusApi from frigate.test.const import TEST_DB, TEST_DB_CLEANUPS @@ -113,7 +114,7 @@ class TestHttp(unittest.TestCase): def test_get_event_list(self): app = create_app( - FrigateConfig(**self.minimal_config), self.db, None, None, None + FrigateConfig(**self.minimal_config), self.db, None, None, PlusApi() ) id = "123456.random" id2 = "7890.random" @@ -142,7 +143,7 @@ class TestHttp(unittest.TestCase): def test_get_good_event(self): app = create_app( - FrigateConfig(**self.minimal_config), self.db, None, None, None + FrigateConfig(**self.minimal_config), self.db, None, None, PlusApi() ) id = "123456.random" @@ -156,7 +157,7 @@ class TestHttp(unittest.TestCase): def test_get_bad_event(self): app = create_app( - FrigateConfig(**self.minimal_config), self.db, None, None, None + FrigateConfig(**self.minimal_config), self.db, None, None, PlusApi() ) id = "123456.random" bad_id = "654321.other" @@ -169,7 +170,7 @@ class TestHttp(unittest.TestCase): def test_delete_event(self): app = create_app( - FrigateConfig(**self.minimal_config), self.db, None, None, None + FrigateConfig(**self.minimal_config), self.db, None, None, PlusApi() ) id = "123456.random" @@ -184,7 +185,7 @@ class TestHttp(unittest.TestCase): def test_event_retention(self): app = create_app( - FrigateConfig(**self.minimal_config), self.db, None, None, None + FrigateConfig(**self.minimal_config), self.db, None, None, PlusApi() ) id = "123456.random" @@ -203,7 +204,7 @@ class TestHttp(unittest.TestCase): def test_set_delete_sub_label(self): app = create_app( - FrigateConfig(**self.minimal_config), self.db, None, None, None + FrigateConfig(**self.minimal_config), self.db, None, None, PlusApi() ) id = "123456.random" sub_label = "sub" @@ -231,7 +232,7 @@ class TestHttp(unittest.TestCase): def test_sub_label_list(self): app = create_app( - FrigateConfig(**self.minimal_config), self.db, None, None, None + FrigateConfig(**self.minimal_config), self.db, None, None, PlusApi() ) id = "123456.random" sub_label = "sub" @@ -253,7 +254,7 @@ class TestHttp(unittest.TestCase): self.db, None, None, - None, + PlusApi(), ) with app.test_client() as client: @@ -267,7 +268,7 @@ class TestHttp(unittest.TestCase): self.db, None, None, - None, + PlusApi(), ) id = "123456.random" @@ -284,7 +285,7 @@ class TestHttp(unittest.TestCase): self.db, None, None, - None, + PlusApi(), ) mock_stats.return_value = self.test_stats