fix: revive main dashboard analytics
This commit is contained in:
@@ -528,6 +528,89 @@ class OrganizationAnalyticsApiTest(APITestCase):
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
self.assertEqual(response.data["corporation_scope"], "roscosmos")
|
||||
|
||||
def test_dashboard_endpoint_groups_blank_clusters_by_corporation_scope(self):
|
||||
OrganizationFactory.create(
|
||||
cluster="",
|
||||
executors_count=0,
|
||||
gk_code="1",
|
||||
gk_name='Госкорпорация "Роскосмос"',
|
||||
)
|
||||
|
||||
response = self.client.get(
|
||||
"/api/v1/analytics/dashboard/?corporation_scope=roskosmos"
|
||||
)
|
||||
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
self.assertEqual(
|
||||
response.data["distribution_by_cluster"][0]["cluster"], "roscosmos"
|
||||
)
|
||||
self.assertEqual(
|
||||
response.data["distribution_by_cluster"][0]["cluster_label"],
|
||||
"Госкорпорация «Роскосмос»",
|
||||
)
|
||||
|
||||
def test_dashboard_endpoint_counts_goz_organizations_when_executors_are_missing(
|
||||
self,
|
||||
):
|
||||
OrganizationFactory.create(
|
||||
cluster="",
|
||||
executors_count=0,
|
||||
gk_code="1",
|
||||
gk_name='Госкорпорация "Роскосмос"',
|
||||
goz_participation=True,
|
||||
)
|
||||
OrganizationFactory.create(
|
||||
cluster="",
|
||||
executors_count=0,
|
||||
gk_code="1",
|
||||
gk_name='Госкорпорация "Роскосмос"',
|
||||
goz_participation=False,
|
||||
)
|
||||
|
||||
response = self.client.get(
|
||||
"/api/v1/analytics/dashboard/?corporation_scope=roskosmos"
|
||||
)
|
||||
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
self.assertEqual(
|
||||
response.data["executors_by_cluster"][0]["cluster"], "roscosmos"
|
||||
)
|
||||
self.assertEqual(
|
||||
response.data["executors_by_cluster"][0]["executors_count"], 1
|
||||
)
|
||||
|
||||
def test_dashboard_endpoint_uses_latest_available_f3_years_for_growth(self):
|
||||
organization = OrganizationFactory.create(
|
||||
cluster="space",
|
||||
executors_count=0,
|
||||
gk_code="1",
|
||||
gk_name='Госкорпорация "Роскосмос"',
|
||||
)
|
||||
FormF3RecordFactory.create(
|
||||
organization=organization,
|
||||
report_year=2023,
|
||||
report_quarter=4,
|
||||
avg_employees=100,
|
||||
)
|
||||
FormF3RecordFactory.create(
|
||||
organization=organization,
|
||||
report_year=2024,
|
||||
report_quarter=4,
|
||||
avg_employees=150,
|
||||
)
|
||||
|
||||
response = self.client.get(
|
||||
"/api/v1/analytics/dashboard/?corporation_scope=roskosmos"
|
||||
)
|
||||
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
self.assertEqual(
|
||||
response.data["headcount_growth_by_cluster"][0]["cluster"], "space"
|
||||
)
|
||||
self.assertEqual(
|
||||
response.data["headcount_growth_by_cluster"][0]["growth_percent"], 50.0
|
||||
)
|
||||
|
||||
def test_analytics_query_validation(self):
|
||||
response = self.client.get(
|
||||
f"/api/v1/organizations/{self.organization.id}/analytics/economics/"
|
||||
|
||||
Reference in New Issue
Block a user