fix: revive main dashboard analytics
Some checks failed
CI/CD Pipeline / Code Quality Checks (push) Failing after 2m38s
CI/CD Pipeline / Run Tests (push) Successful in 2m44s
CI/CD Pipeline / Build and Push Dev Images (push) Has been skipped
CI/CD Pipeline / Deploy Dev via Compose (push) Has been skipped

This commit is contained in:
2026-06-16 00:00:14 +02:00
parent f93663b2a4
commit 94aa22ce35
2 changed files with 136 additions and 18 deletions

View File

@@ -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/"