@@ -41,13 +41,53 @@ def context_get_mock(self, url: str, params=None):
41
41
else :
42
42
raise RuntimeError ("Invalid request for src/file_implicitly_modified content" )
43
43
elif url == "changes/test_get_change/revisions/current/files/src%2Ffile_deleted/content" :
44
- # This file is modified , so there is new and parent contents
44
+ # This file is deleted , so only support getting the old contents
45
45
if params is None :
46
46
raise RuntimeError ("The src/file_deleted file is deleted, so the patched version should not be requested" )
47
47
elif params == {"parent" : "1" }:
48
48
return "file_deleted line 1\n file_deleted line 2\n "
49
49
else :
50
50
raise RuntimeError ("Invalid request for src/file_implicitly_modified content" )
51
+ elif url == "changes/test_get_change/revisions/current/files/src%2Ffile_renamed/content" :
52
+ # This is the new path of a renamed file, so only support getting the new contents
53
+ if params is None :
54
+ return "file_renamed line 1\n file_renamed base line 2\n "
55
+ elif params == {"parent" : "1" }:
56
+ raise RuntimeError ("The src/file_renamed file is added, so the base version should not be requested" )
57
+ else :
58
+ raise RuntimeError ("Invalid request for src/file_renamed content" )
59
+ elif url == "changes/test_get_change/revisions/current/files/old%2Ffile_renamed/content" :
60
+ # This is the old path of a renamed file, so only support getting the old contents
61
+ if params is None :
62
+ raise RuntimeError ("The old/file_renamed file was renamed, so the patched version should not be requested" )
63
+ elif params == {"parent" : "1" }:
64
+ return "file_renamed line 1\n file_renamed patched line 2\n "
65
+ else :
66
+ raise RuntimeError ("Invalid request for old/file_renamed content" )
67
+ elif url == "changes/test_get_change/revisions/current/files/src%2Ffile_copied/content" :
68
+ # This is the new path of a copied file, so only support getting the new contents
69
+ if params is None :
70
+ return "file_copied line 1\n file_copied base line 2\n "
71
+ elif params == {"parent" : "1" }:
72
+ raise RuntimeError ("The src/file_copied file is added, so the base version should not be requested" )
73
+ else :
74
+ raise RuntimeError ("Invalid request for src/file_copied content" )
75
+ elif url == "changes/test_get_change/revisions/current/files/old%2Ffile_copied/content" :
76
+ # This is the old path of a copied file, so only support getting the old contents
77
+ if params is None :
78
+ raise RuntimeError ("The old/file_copied file was copied in this change, so the patched version should not be requested" )
79
+ elif params == {"parent" : "1" }:
80
+ return "file_copied line 1\n file_copied patched line 2\n "
81
+ else :
82
+ raise RuntimeError ("Invalid request for old/file_copied content" )
83
+ elif url == "changes/test_get_change/revisions/current/files/src%2Ffile_rewritten/content" :
84
+ # This file is modified, so there is new and parent contents
85
+ if params is None :
86
+ return "file_rewritten line 1\n 2Ffile_rewritten base line 2\n "
87
+ elif params == {"parent" : "1" }:
88
+ return "file_rewritten line 1\n 2Ffile_rewritten patched line 2\n "
89
+ else :
90
+ raise RuntimeError ("Invalid request for src/file_rewritten content" )
51
91
raise ValueError ("Input URL is not mocked: %s" % url )
52
92
53
93
0 commit comments