@@ -326,6 +326,40 @@ def test_should_do_flake_detection(dbsession, mocker, config, private, plan, ex_
326326 assert result == ex_result
327327
328328
329+ @pytest .mark .django_db
330+ @pytest .mark .parametrize (
331+ "config,private,owner_plan,account_plan,ex_result" ,
332+ [
333+ # Account with free plan should override owner's paid plan
334+ (True , True , "users-inappm" , DEFAULT_FREE_PLAN , False ),
335+ # Account with paid plan should override owner's free plan
336+ (True , True , DEFAULT_FREE_PLAN , "users-inappm" , True ),
337+ # Account with paid plan, private repo, should work
338+ (True , False , DEFAULT_FREE_PLAN , "users-inappm" , True ),
339+ # Account with free plan, public repo, should work
340+ (True , False , "users-inappm" , DEFAULT_FREE_PLAN , True ),
341+ ],
342+ )
343+ def test_should_do_flake_detection_with_account (
344+ dbsession , mocker , config , private , owner_plan , account_plan , ex_result
345+ ):
346+ mock_all_plans_and_tiers ()
347+ account = Account (name = "testaccount" , plan = account_plan , is_active = True )
348+ dbsession .add (account )
349+ dbsession .flush ()
350+
351+ owner = OwnerFactory (plan = owner_plan , account = account )
352+ repo = RepositoryFactory (private = private , author = owner )
353+ dbsession .add (repo )
354+ dbsession .flush ()
355+
356+ yaml = {"test_analytics" : {"flake_detection" : config }}
357+
358+ result = should_do_flaky_detection (repo , UserYaml .from_dict (yaml ))
359+
360+ assert result == ex_result
361+
362+
329363def test_specific_error_message (mocker , snapshot ):
330364 mock_repo_service = mock .AsyncMock ()
331365 mocker .patch (
0 commit comments