@@ -410,7 +410,7 @@ def test_upload_avatar(self):
410410 "sentry.integrations.github.integration.GitHubApiClient.get_repositories" ,
411411 return_value = [{"name" : "cool-repo" , "full_name" : "testgit/cool-repo" }],
412412 )
413- @with_feature ("organizations:codecov-integration" )
413+ @with_feature ([ "organizations:codecov-integration" , "organizations:dynamic-sampling-custom" ] )
414414 def test_various_options (self , mock_get_repositories ):
415415 initial = self .organization .get_audit_log_data ()
416416 with assume_test_silo_mode_of (AuditLogEntry ):
@@ -455,6 +455,7 @@ def test_various_options(self, mock_get_repositories):
455455 "metricsActivatePercentiles" : False ,
456456 "metricsActivateLastForGauges" : True ,
457457 "uptimeAutodetection" : False ,
458+ "targetSampleRate" : 0.1 ,
458459 }
459460
460461 # needed to set require2FA
@@ -493,6 +494,7 @@ def test_various_options(self, mock_get_repositories):
493494 assert options .get ("sentry:metrics_activate_percentiles" ) is False
494495 assert options .get ("sentry:metrics_activate_last_for_gauges" ) is True
495496 assert options .get ("sentry:uptime_autodetection" ) is False
497+ assert options .get ("sentry:target_sample_rate" ) == 0.1
496498
497499 # log created
498500 with assume_test_silo_mode_of (AuditLogEntry ):
@@ -940,6 +942,35 @@ def test_org_mapping_already_taken(self):
940942 self .create_organization (slug = "taken" )
941943 self .get_error_response (self .organization .slug , slug = "taken" , status_code = 400 )
942944
945+ def test_target_sample_rate_feature (self ):
946+ with self .feature ("organizations:dynamic-sampling-custom" ):
947+ data = {"targetSampleRate" : 0.1 }
948+ self .get_success_response (self .organization .slug , ** data )
949+
950+ with self .feature ({"organizations:dynamic-sampling-custom" : False }):
951+ data = {"targetSampleRate" : 0.1 }
952+ self .get_error_response (self .organization .slug , status_code = 400 , ** data )
953+
954+ @with_feature ("organizations:dynamic-sampling-custom" )
955+ def test_target_sample_rate_range (self ):
956+ # low, within and high
957+ data = {"targetSampleRate" : 0.0 }
958+ self .get_success_response (self .organization .slug , ** data )
959+
960+ data = {"targetSampleRate" : 0.1 }
961+ self .get_success_response (self .organization .slug , ** data )
962+
963+ data = {"targetSampleRate" : 1.0 }
964+ self .get_success_response (self .organization .slug , ** data )
965+
966+ # below range
967+ data = {"targetSampleRate" : - 0.1 }
968+ self .get_error_response (self .organization .slug , status_code = 400 , ** data )
969+
970+ # above range
971+ data = {"targetSampleRate" : 1.1 }
972+ self .get_error_response (self .organization .slug , status_code = 400 , ** data )
973+
943974
944975class OrganizationDeleteTest (OrganizationDetailsTestBase ):
945976 method = "delete"
0 commit comments