3535from devservices .utils .state import StateTables
3636from testing .utils import create_config_file
3737from testing .utils import create_mock_git_repo
38+ from testing .utils import make_zip_bytes
3839from testing .utils import run_git_command
40+ from testing .utils import url_dispatch
3941
4042
4143@mock .patch ("devservices.commands.toggle.find_matching_service" )
@@ -237,7 +239,6 @@ def test_toggle_dependent_service_running(
237239 return_value = str (tmp_path / "code" ),
238240 ),
239241 ):
240- redis_repo_path = create_mock_git_repo ("blank_repo" , tmp_path / "redis" )
241242 redis_config = {
242243 "x-sentry-service-config" : {
243244 "version" : 0.1 ,
@@ -251,13 +252,6 @@ def test_toggle_dependent_service_running(
251252 "redis" : {"image" : "redis:6.2.14-alpine" },
252253 },
253254 }
254- create_config_file (redis_repo_path , redis_config )
255- run_git_command (["add" , "." ], cwd = redis_repo_path )
256- run_git_command (["commit" , "-m" , "Add devservices config" ], cwd = redis_repo_path )
257-
258- example_repo_path = create_mock_git_repo (
259- "blank_repo" , tmp_path / "example-service"
260- )
261255 example_config = {
262256 "x-sentry-service-config" : {
263257 "version" : 0.1 ,
@@ -268,7 +262,7 @@ def test_toggle_dependent_service_running(
268262 "remote" : {
269263 "repo_name" : "redis" ,
270264 "branch" : "main" ,
271- "repo_link" : f"file ://{ redis_repo_path } " ,
265+ "repo_link" : "https ://github.com/getsentry/redis " ,
272266 },
273267 },
274268 "clickhouse" : {"description" : "Clickhouse" },
@@ -281,11 +275,6 @@ def test_toggle_dependent_service_running(
281275 },
282276 },
283277 }
284- create_config_file (example_repo_path , example_config )
285- run_git_command (["add" , "." ], cwd = example_repo_path )
286- run_git_command (
287- ["commit" , "-m" , "Add devservices config" ], cwd = example_repo_path
288- )
289278
290279 example_service_path = tmp_path / "code" / "example-service"
291280 create_config_file (example_service_path , example_config )
@@ -300,15 +289,15 @@ def test_toggle_dependent_service_running(
300289 "remote" : {
301290 "repo_name" : "redis" ,
302291 "branch" : "main" ,
303- "repo_link" : f"file ://{ redis_repo_path } " ,
292+ "repo_link" : "https ://github.com/getsentry/redis " ,
304293 },
305294 },
306295 "example-service" : {
307296 "description" : "Example service" ,
308297 "remote" : {
309298 "repo_name" : "example-service" ,
310299 "branch" : "main" ,
311- "repo_link" : f"file ://{ example_repo_path } " ,
300+ "repo_link" : "https ://github.com/getsentry/example-service " ,
312301 },
313302 },
314303 },
@@ -318,39 +307,48 @@ def test_toggle_dependent_service_running(
318307 other_service_path = tmp_path / "code" / "other-service"
319308 create_config_file (other_service_path , other_config )
320309
321- install_and_verify_dependencies (
322- Service (
323- name = "other-service" ,
324- repo_path = str (other_service_path ),
325- config = ServiceConfig (
326- version = 0.1 ,
327- service_name = "other-service" ,
328- dependencies = {
329- "redis" : Dependency (
330- description = "Redis" ,
331- remote = RemoteConfig (
332- repo_name = "redis" ,
333- repo_link = f"file://{ redis_repo_path } " ,
334- branch = "main" ,
335- mode = "default" ,
310+ with mock .patch (
311+ "devservices.utils.dependencies.urllib.request.urlopen" ,
312+ side_effect = url_dispatch (
313+ {
314+ "redis" : make_zip_bytes (redis_config ),
315+ "example-service" : make_zip_bytes (example_config ),
316+ }
317+ ),
318+ ):
319+ install_and_verify_dependencies (
320+ Service (
321+ name = "other-service" ,
322+ repo_path = str (other_service_path ),
323+ config = ServiceConfig (
324+ version = 0.1 ,
325+ service_name = "other-service" ,
326+ dependencies = {
327+ "redis" : Dependency (
328+ description = "Redis" ,
329+ remote = RemoteConfig (
330+ repo_name = "redis" ,
331+ repo_link = "https://github.com/getsentry/redis" ,
332+ branch = "main" ,
333+ mode = "default" ,
334+ ),
335+ dependency_type = DependencyType .SERVICE ,
336336 ),
337- dependency_type = DependencyType . SERVICE ,
338- ) ,
339- "example-service" : Dependency (
340- description = "Example service" ,
341- remote = RemoteConfig (
342- repo_name = "example-service " ,
343- repo_link = f"file:// { example_repo_path } " ,
344- branch = "main" ,
345- mode = "default" ,
337+ "example-service" : Dependency (
338+ description = "Example service" ,
339+ remote = RemoteConfig (
340+ repo_name = "example- service" ,
341+ repo_link = "https://github.com/getsentry/example-service" ,
342+ branch = "main " ,
343+ mode = "default " ,
344+ ) ,
345+ dependency_type = DependencyType . SERVICE ,
346346 ),
347- dependency_type = DependencyType .SERVICE ,
348- ),
349- },
350- modes = {"default" : ["redis" , "example-service" ]},
351- ),
347+ },
348+ modes = {"default" : ["redis" , "example-service" ]},
349+ ),
350+ )
352351 )
353- )
354352
355353 os .chdir (example_service_path )
356354
@@ -798,7 +796,6 @@ def test_handle_transition_to_containerized_runtime_with_dependent_services(
798796 return_value = str (tmp_path / "code" ),
799797 ),
800798 ):
801- redis_repo_path = create_mock_git_repo ("blank_repo" , tmp_path / "redis" )
802799 redis_config = {
803800 "x-sentry-service-config" : {
804801 "version" : 0.1 ,
@@ -812,13 +809,6 @@ def test_handle_transition_to_containerized_runtime_with_dependent_services(
812809 "redis" : {"image" : "redis:6.2.14-alpine" },
813810 },
814811 }
815- create_config_file (redis_repo_path , redis_config )
816- run_git_command (["add" , "." ], cwd = redis_repo_path )
817- run_git_command (["commit" , "-m" , "Add devservices config" ], cwd = redis_repo_path )
818-
819- example_repo_path = create_mock_git_repo (
820- "blank_repo" , tmp_path / "example-service"
821- )
822812 example_config = {
823813 "x-sentry-service-config" : {
824814 "version" : 0.1 ,
@@ -829,7 +819,7 @@ def test_handle_transition_to_containerized_runtime_with_dependent_services(
829819 "remote" : {
830820 "repo_name" : "redis" ,
831821 "branch" : "main" ,
832- "repo_link" : f"file ://{ redis_repo_path } " ,
822+ "repo_link" : "https ://github.com/getsentry/redis " ,
833823 },
834824 },
835825 "clickhouse" : {"description" : "Clickhouse" },
@@ -842,11 +832,6 @@ def test_handle_transition_to_containerized_runtime_with_dependent_services(
842832 },
843833 },
844834 }
845- create_config_file (example_repo_path , example_config )
846- run_git_command (["add" , "." ], cwd = example_repo_path )
847- run_git_command (
848- ["commit" , "-m" , "Add devservices config" ], cwd = example_repo_path
849- )
850835
851836 example_service_path = tmp_path / "code" / "example-service"
852837 create_config_file (example_service_path , example_config )
@@ -861,15 +846,15 @@ def test_handle_transition_to_containerized_runtime_with_dependent_services(
861846 "remote" : {
862847 "repo_name" : "redis" ,
863848 "branch" : "main" ,
864- "repo_link" : f"file ://{ redis_repo_path } " ,
849+ "repo_link" : "https ://github.com/getsentry/redis " ,
865850 },
866851 },
867852 "example-service" : {
868853 "description" : "Example service" ,
869854 "remote" : {
870855 "repo_name" : "example-service" ,
871856 "branch" : "main" ,
872- "repo_link" : f"file ://{ example_repo_path } " ,
857+ "repo_link" : "https ://github.com/getsentry/example-service " ,
873858 },
874859 },
875860 },
@@ -879,39 +864,48 @@ def test_handle_transition_to_containerized_runtime_with_dependent_services(
879864 other_service_path = tmp_path / "code" / "other-service"
880865 create_config_file (other_service_path , other_config )
881866
882- install_and_verify_dependencies (
883- Service (
884- name = "other-service" ,
885- repo_path = str (other_service_path ),
886- config = ServiceConfig (
887- version = 0.1 ,
888- service_name = "other-service" ,
889- dependencies = {
890- "redis" : Dependency (
891- description = "Redis" ,
892- remote = RemoteConfig (
893- repo_name = "redis" ,
894- repo_link = f"file://{ redis_repo_path } " ,
895- branch = "main" ,
896- mode = "default" ,
867+ with mock .patch (
868+ "devservices.utils.dependencies.urllib.request.urlopen" ,
869+ side_effect = url_dispatch (
870+ {
871+ "redis" : make_zip_bytes (redis_config ),
872+ "example-service" : make_zip_bytes (example_config ),
873+ }
874+ ),
875+ ):
876+ install_and_verify_dependencies (
877+ Service (
878+ name = "other-service" ,
879+ repo_path = str (other_service_path ),
880+ config = ServiceConfig (
881+ version = 0.1 ,
882+ service_name = "other-service" ,
883+ dependencies = {
884+ "redis" : Dependency (
885+ description = "Redis" ,
886+ remote = RemoteConfig (
887+ repo_name = "redis" ,
888+ repo_link = "https://github.com/getsentry/redis" ,
889+ branch = "main" ,
890+ mode = "default" ,
891+ ),
892+ dependency_type = DependencyType .SERVICE ,
897893 ),
898- dependency_type = DependencyType . SERVICE ,
899- ) ,
900- "example-service" : Dependency (
901- description = "Example service" ,
902- remote = RemoteConfig (
903- repo_name = "example-service " ,
904- repo_link = f"file:// { example_repo_path } " ,
905- branch = "main" ,
906- mode = "default" ,
894+ "example-service" : Dependency (
895+ description = "Example service" ,
896+ remote = RemoteConfig (
897+ repo_name = "example- service" ,
898+ repo_link = "https://github.com/getsentry/example-service" ,
899+ branch = "main " ,
900+ mode = "default " ,
901+ ) ,
902+ dependency_type = DependencyType . SERVICE ,
907903 ),
908- dependency_type = DependencyType .SERVICE ,
909- ),
910- },
911- modes = {"default" : ["redis" , "example-service" ]},
912- ),
904+ },
905+ modes = {"default" : ["redis" , "example-service" ]},
906+ ),
907+ )
913908 )
914- )
915909
916910 os .chdir (example_service_path )
917911
@@ -932,7 +926,7 @@ def test_handle_transition_to_containerized_runtime_with_dependent_services(
932926 description = "Redis" ,
933927 remote = RemoteConfig (
934928 repo_name = "redis" ,
935- repo_link = f"file ://{ redis_repo_path } " ,
929+ repo_link = "https ://github.com/getsentry/redis " ,
936930 branch = "main" ,
937931 mode = "default" ,
938932 ),
0 commit comments