mirror of https://github.com/zulip/zulip.git
analytics: Create analytics/views/ directory.
This commit is contained in:
parent
0a1eaf0384
commit
9c8ddef5f2
|
@ -9,7 +9,7 @@ from django.utils.timezone import now as timezone_now
|
||||||
from analytics.lib.counts import COUNT_STATS, CountStat
|
from analytics.lib.counts import COUNT_STATS, CountStat
|
||||||
from analytics.lib.time_utils import time_range
|
from analytics.lib.time_utils import time_range
|
||||||
from analytics.models import FillState, RealmCount, UserCount
|
from 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_labels
|
||||||
from corporate.lib.stripe import add_months, update_sponsorship_status
|
from corporate.lib.stripe import add_months, update_sponsorship_status
|
||||||
from corporate.models import Customer, CustomerPlan, LicenseLedger, get_customer_by_realm
|
from corporate.models import Customer, CustomerPlan, LicenseLedger, get_customer_by_realm
|
||||||
from zerver.lib.actions import (
|
from zerver.lib.actions import (
|
||||||
|
@ -800,7 +800,8 @@ class TestSupportEndpoint(ZulipTestCase):
|
||||||
check_lear_realm_query_result(result)
|
check_lear_realm_query_result(result)
|
||||||
|
|
||||||
with mock.patch(
|
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.client_post("/accounts/home/", {"email": self.nonreg_email("test")})
|
||||||
self.login("iago")
|
self.login("iago")
|
||||||
|
@ -838,7 +839,7 @@ class TestSupportEndpoint(ZulipTestCase):
|
||||||
check_realm_reactivation_link_query_result(result)
|
check_realm_reactivation_link_query_result(result)
|
||||||
check_zulip_realm_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:
|
def test_change_billing_method(self, m: mock.Mock) -> None:
|
||||||
cordelia = self.example_user("cordelia")
|
cordelia = self.example_user("cordelia")
|
||||||
self.login_user(cordelia)
|
self.login_user(cordelia)
|
||||||
|
@ -884,7 +885,7 @@ class TestSupportEndpoint(ZulipTestCase):
|
||||||
iago = self.example_user("iago")
|
iago = self.example_user("iago")
|
||||||
self.login_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(
|
result = self.client_post(
|
||||||
"/activity/support", {"realm_id": f"{iago.realm_id}", "plan_type": "2"}
|
"/activity/support", {"realm_id": f"{iago.realm_id}", "plan_type": "2"}
|
||||||
)
|
)
|
||||||
|
@ -907,7 +908,7 @@ class TestSupportEndpoint(ZulipTestCase):
|
||||||
iago = self.example_user("iago")
|
iago = self.example_user("iago")
|
||||||
self.login("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(
|
result = self.client_post(
|
||||||
"/activity/support", {"realm_id": f"{lear_realm.id}", "discount": "25"}
|
"/activity/support", {"realm_id": f"{lear_realm.id}", "discount": "25"}
|
||||||
)
|
)
|
||||||
|
@ -995,14 +996,14 @@ class TestSupportEndpoint(ZulipTestCase):
|
||||||
|
|
||||||
self.login("iago")
|
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(
|
result = self.client_post(
|
||||||
"/activity/support", {"realm_id": f"{lear_realm.id}", "status": "deactivated"}
|
"/activity/support", {"realm_id": f"{lear_realm.id}", "status": "deactivated"}
|
||||||
)
|
)
|
||||||
m.assert_called_once_with(lear_realm, acting_user=self.example_user("iago"))
|
m.assert_called_once_with(lear_realm, acting_user=self.example_user("iago"))
|
||||||
self.assert_in_success_response(["lear deactivated"], result)
|
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(
|
result = self.client_post(
|
||||||
"/activity/support", {"realm_id": f"{lear_realm.id}", "status": "active"}
|
"/activity/support", {"realm_id": f"{lear_realm.id}", "status": "active"}
|
||||||
)
|
)
|
||||||
|
@ -1067,7 +1068,7 @@ class TestSupportEndpoint(ZulipTestCase):
|
||||||
iago = self.example_user("iago")
|
iago = self.example_user("iago")
|
||||||
self.login_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(
|
result = self.client_post(
|
||||||
"/activity/support",
|
"/activity/support",
|
||||||
{
|
{
|
||||||
|
@ -1080,7 +1081,9 @@ class TestSupportEndpoint(ZulipTestCase):
|
||||||
["zulip marked for downgrade at the end of billing cycle"], result
|
["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(
|
result = self.client_post(
|
||||||
"/activity/support",
|
"/activity/support",
|
||||||
{
|
{
|
||||||
|
@ -1093,8 +1096,10 @@ class TestSupportEndpoint(ZulipTestCase):
|
||||||
["zulip downgraded without creating additional invoices"], result
|
["zulip downgraded without creating additional invoices"], result
|
||||||
)
|
)
|
||||||
|
|
||||||
with mock.patch("analytics.views.downgrade_now_without_creating_additional_invoices") as m1:
|
with mock.patch(
|
||||||
with mock.patch("analytics.views.void_all_open_invoices", return_value=1) as m2:
|
"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(
|
result = self.client_post(
|
||||||
"/activity/support",
|
"/activity/support",
|
||||||
{
|
{
|
||||||
|
@ -1121,14 +1126,14 @@ class TestSupportEndpoint(ZulipTestCase):
|
||||||
|
|
||||||
self.login("iago")
|
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(
|
result = self.client_post(
|
||||||
"/activity/support", {"realm_id": f"{lear_realm.id}", "scrub_realm": "scrub_realm"}
|
"/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"))
|
m.assert_called_once_with(lear_realm, acting_user=self.example_user("iago"))
|
||||||
self.assert_in_success_response(["lear scrubbed"], result)
|
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}"})
|
result = self.client_post("/activity/support", {"realm_id": f"{lear_realm.id}"})
|
||||||
self.assert_json_error(result, "Invalid parameters")
|
self.assert_json_error(result, "Invalid parameters")
|
||||||
m.assert_not_called()
|
m.assert_not_called()
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from django.conf.urls import include
|
from django.conf.urls import include
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
|
|
||||||
from analytics.views import (
|
from analytics.views.legacy import (
|
||||||
get_activity,
|
get_activity,
|
||||||
get_chart_data,
|
get_chart_data,
|
||||||
get_chart_data_for_installation,
|
get_chart_data_for_installation,
|
||||||
|
|
Loading…
Reference in New Issue