Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
analytics: Create analytics/views/ directory.
Tim Abbott9c8ddef5f210
diff --git a/analytics/tests/test_views.py b/analytics/tests/test_views.pyindex 674ed1ba071..c6e166a21a3 100644--- a/analytics/tests/test_views.py+++ b/analytics/tests/test_views.py@@ -9,7 +9,7 @@ from django.utils.timezone import now as timezone_nowfrom analytics.lib.counts import COUNT_STATS, CountStatfrom analytics.lib.time_utils import time_rangefrom analytics.models import FillState, RealmCount, UserCount-from analytics.views import rewrite_client_arrays, sort_by_totals, sort_client_labels+from analytics.views.legacy import rewrite_client_arrays, sort_by_totals, sort_client_labelsfrom corporate.lib.stripe import add_months, update_sponsorship_statusfrom corporate.models import Customer, CustomerPlan, LicenseLedger, get_customer_by_realmfrom zerver.lib.actions import (@@ -800,7 +800,8 @@ class TestSupportEndpoint(ZulipTestCase):check_lear_realm_query_result(result)with mock.patch(- "analytics.views.timezone_now", return_value=timezone_now() - timedelta(minutes=50)+ "analytics.views.legacy.timezone_now",+ return_value=timezone_now() - timedelta(minutes=50),):self.client_post("/accounts/home/", {"email": self.nonreg_email("test")})self.login("iago")@@ -838,7 +839,7 @@ class TestSupportEndpoint(ZulipTestCase):check_realm_reactivation_link_query_result(result)check_zulip_realm_query_result(result)- @mock.patch("analytics.views.update_billing_method_of_current_plan")+ @mock.patch("analytics.views.legacy.update_billing_method_of_current_plan")def test_change_billing_method(self, m: mock.Mock) -> None:cordelia = self.example_user("cordelia")self.login_user(cordelia)@@ -884,7 +885,7 @@ class TestSupportEndpoint(ZulipTestCase):iago = self.example_user("iago")self.login_user(iago)- with mock.patch("analytics.views.do_change_plan_type") as m:+ with mock.patch("analytics.views.legacy.do_change_plan_type") as m:result = self.client_post("/activity/support", {"realm_id": f"{iago.realm_id}", "plan_type": "2"})@@ -907,7 +908,7 @@ class TestSupportEndpoint(ZulipTestCase):iago = self.example_user("iago")self.login("iago")- with mock.patch("analytics.views.attach_discount_to_realm") as m:+ with mock.patch("analytics.views.legacy.attach_discount_to_realm") as m:result = self.client_post("/activity/support", {"realm_id": f"{lear_realm.id}", "discount": "25"})@@ -995,14 +996,14 @@ class TestSupportEndpoint(ZulipTestCase):self.login("iago")- with mock.patch("analytics.views.do_deactivate_realm") as m:+ with mock.patch("analytics.views.legacy.do_deactivate_realm") as m:result = self.client_post("/activity/support", {"realm_id": f"{lear_realm.id}", "status": "deactivated"})m.assert_called_once_with(lear_realm, acting_user=self.example_user("iago"))self.assert_in_success_response(["lear deactivated"], result)- with mock.patch("analytics.views.do_send_realm_reactivation_email") as m:+ with mock.patch("analytics.views.legacy.do_send_realm_reactivation_email") as m:result = self.client_post("/activity/support", {"realm_id": f"{lear_realm.id}", "status": "active"})@@ -1067,7 +1068,7 @@ class TestSupportEndpoint(ZulipTestCase):iago = self.example_user("iago")self.login_user(iago)- with mock.patch("analytics.views.downgrade_at_the_end_of_billing_cycle") as m:+ with mock.patch("analytics.views.legacy.downgrade_at_the_end_of_billing_cycle") as m:result = self.client_post("/activity/support",{@@ -1080,7 +1081,9 @@ class TestSupportEndpoint(ZulipTestCase):["zulip marked for downgrade at the end of billing cycle"], result)- with mock.patch("analytics.views.downgrade_now_without_creating_additional_invoices") as m:+ with mock.patch(+ "analytics.views.legacy.downgrade_now_without_creating_additional_invoices"+ ) as m:result = self.client_post("/activity/support",{@@ -1093,8 +1096,10 @@ class TestSupportEndpoint(ZulipTestCase):["zulip downgraded without creating additional invoices"], result)- with mock.patch("analytics.views.downgrade_now_without_creating_additional_invoices") as m1:- with mock.patch("analytics.views.void_all_open_invoices", return_value=1) as m2:+ with mock.patch(+ "analytics.views.legacy.downgrade_now_without_creating_additional_invoices"+ ) as m1:+ with mock.patch("analytics.views.legacy.void_all_open_invoices", return_value=1) as m2:result = self.client_post("/activity/support",{@@ -1121,14 +1126,14 @@ class TestSupportEndpoint(ZulipTestCase):self.login("iago")- with mock.patch("analytics.views.do_scrub_realm") as m:+ with mock.patch("analytics.views.legacy.do_scrub_realm") as m:result = self.client_post("/activity/support", {"realm_id": f"{lear_realm.id}", "scrub_realm": "scrub_realm"})m.assert_called_once_with(lear_realm, acting_user=self.example_user("iago"))self.assert_in_success_response(["lear scrubbed"], result)- with mock.patch("analytics.views.do_scrub_realm") as m:+ with mock.patch("analytics.views.legacy.do_scrub_realm") as m:result = self.client_post("/activity/support", {"realm_id": f"{lear_realm.id}"})self.assert_json_error(result, "Invalid parameters")m.assert_not_called()diff --git a/analytics/urls.py b/analytics/urls.pyindex ea2a02377b9..51049e560ec 100644--- a/analytics/urls.py+++ b/analytics/urls.py@@ -1,7 +1,7 @@from django.conf.urls import includefrom django.urls import path-from analytics.views import (+from analytics.views.legacy import (get_activity,get_chart_data,get_chart_data_for_installation,diff --git a/analytics/views/__init__.py b/analytics/views/__init__.pynew file mode 100644index 00000000000..e69de29bb2ddiff --git a/analytics/views.py b/analytics/views/legacy.pysimilarity index 100%rename from analytics/views.pyrename to analytics/views/legacy.py