@@ -1859,6 +1859,77 @@ def test_retrieve_org_with_account(self):
18591859 self .assertDictEqual (response .data ["plan" ], expected_response ["plan" ])
18601860 self .assertDictEqual (response .data , expected_response )
18611861
1862+ def test_retrieve_with_sentry_merge_account_uses_owner_fields (self ):
1863+ org = OwnerFactory (
1864+ plan = PlanName .CODECOV_PRO_YEARLY .value ,
1865+ plan_user_count = 10 ,
1866+ stripe_customer_id = "cus_test123" ,
1867+ delinquent = True ,
1868+ )
1869+ org .plan_activated_users = []
1870+ org .save ()
1871+
1872+ activated_owner = OwnerFactory (
1873+ service = Service .GITHUB .value ,
1874+ user = UserFactory (),
1875+ organizations = [org .ownerid ],
1876+ )
1877+ org .plan_activated_users = [activated_owner .ownerid ]
1878+ org .admins = [activated_owner .ownerid ]
1879+ org .save ()
1880+
1881+ account = AccountFactory (
1882+ plan = PlanName .SENTRY_MERGE_PLAN .value ,
1883+ plan_seat_count = 5 ,
1884+ is_delinquent = False ,
1885+ )
1886+ InvoiceBillingFactory (account = account , is_active = True )
1887+ org .account = account
1888+ org .save ()
1889+
1890+ self .client .force_login_owner (activated_owner )
1891+ response = self ._retrieve (
1892+ kwargs = {"service" : Service .GITHUB .value , "owner_username" : org .username }
1893+ )
1894+ assert response .status_code == status .HTTP_200_OK
1895+
1896+ expected_response = {
1897+ "activated_user_count" : 1 ,
1898+ "activated_student_count" : 0 ,
1899+ "delinquent" : True ,
1900+ "uses_invoice" : False ,
1901+ "plan" : {
1902+ "marketing_name" : "Pro" ,
1903+ "value" : PlanName .CODECOV_PRO_YEARLY .value ,
1904+ "billing_rate" : "annually" ,
1905+ "base_unit_price" : 10 ,
1906+ "benefits" : [
1907+ "Configurable # of users" ,
1908+ "Unlimited public repositories" ,
1909+ "Unlimited private repositories" ,
1910+ "Priority Support" ,
1911+ ],
1912+ "quantity" : 10 ,
1913+ },
1914+ "root_organization" : None ,
1915+ "integration_id" : org .integration_id ,
1916+ "plan_auto_activate" : org .plan_auto_activate ,
1917+ "inactive_user_count" : 0 ,
1918+ "subscription_detail" : None ,
1919+ "checkout_session_id" : None ,
1920+ "name" : org .name ,
1921+ "email" : org .email ,
1922+ "nb_active_private_repos" : 0 ,
1923+ "repo_total_credits" : 99999999 ,
1924+ "plan_provider" : org .plan_provider ,
1925+ "student_count" : 0 ,
1926+ "schedule_detail" : None ,
1927+ }
1928+ self .assertDictEqual (response .data ["plan" ], expected_response ["plan" ])
1929+ self .assertEqual (response .data ["activated_user_count" ], 1 )
1930+ self .assertEqual (response .data ["delinquent" ], True )
1931+ self .assertEqual (response .data ["uses_invoice" ], False )
1932+
18621933
18631934@override_settings (IS_ENTERPRISE = True )
18641935class EnterpriseAccountViewSetTests (APITestCase ):
0 commit comments