Skip to content

Commit 712eb9a

Browse files
Fix all broken unit tests and minor refactoring.
* Add `type` field in the test JSONs. * Replace `get_resource_from_path` method with `get_resource` method. * Refactor `create_deltas` method signature - remove path parameters. Signed-off-by: Arnav Mandal <arnav.mandal1234@gmail.com>
1 parent aa713f8 commit 712eb9a

68 files changed

Lines changed: 71 additions & 31 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/deltacode/__init__.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def similarity(self):
121121
)
122122

123123
def create_deltas(
124-
self, new_resource, old_resource, new_path, old_path, score, status
124+
self, new_resource, old_resource, score, status
125125
):
126126
"""
127127
Creates the Delta Objects and appends them to the member list.
@@ -153,7 +153,7 @@ def determine_delta(self):
153153
)
154154
# If the resource is a file align its path
155155

156-
old_resource = self.codebase2.get_resource_from_path(path_new)
156+
old_resource = self.codebase2.get_resource(path_new)
157157
# Check in the old codebase weather a resource with such a path exists or not
158158
# if it exists and their corresponding sha's are same then its an unmodified delta
159159

@@ -163,7 +163,7 @@ def determine_delta(self):
163163
paths.split(old_resource.path)[Delta.OLD_CODEBASE_OFFSET :]
164164
)
165165
self.create_deltas(
166-
new_resource, old_resource, path_new, path_old, 0, "unmodified",
166+
new_resource, old_resource, 0, "unmodified",
167167
)
168168
self.stats.num_unmodified += 1
169169

@@ -196,8 +196,6 @@ def determine_delta(self):
196196
self.create_deltas(
197197
new_resource,
198198
old_resource,
199-
path_new,
200-
path_old,
201199
0,
202200
"unmodified",
203201
)
@@ -209,8 +207,6 @@ def determine_delta(self):
209207
self.create_deltas(
210208
new_resource,
211209
old_resource,
212-
path_new,
213-
path_old,
214210
20,
215211
"modified",
216212
)
@@ -225,8 +221,6 @@ def determine_delta(self):
225221
self.create_deltas(
226222
new_resource,
227223
old_resource,
228-
path_new,
229-
path_old,
230224
0,
231225
"moved",
232226
)
@@ -236,7 +230,7 @@ def determine_delta(self):
236230
if ADDED:
237231
# If none of the above criteria matches then the delta is an added one.
238232
self.create_deltas(
239-
new_resource, None, path_new, None, 100, "added",
233+
new_resource, None, 100, "added",
240234
)
241235
self.stats.num_added += 1
242236

@@ -253,7 +247,7 @@ def determine_delta(self):
253247
]
254248
)
255249
self.create_deltas(
256-
None, old_resource_remaining, None, path_old, 0, "removed",
250+
None, old_resource_remaining, 0, "removed",
257251
)
258252
self.stats.num_removed += 1
259253

tests/data/deltacode/scan_modified_old_license_added.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
{
3838
"path": "some/path/b/b1.py",
3939
"type": "file",
40-
"name": "b2.py",
40+
"name": "b1.py",
4141
"size": 200,
4242
"sha1": "333647771481d39dd3a53f6dc210c26abac37748",
4343
"licenses": [

tests/data/utils/update_from_copyright_info_copyright_info_added_new.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
{
1111
"path":"test/path.txt",
1212
"name": "path.txt",
13+
"type": "file",
1314
"sha1": "a",
1415
"original_path": "",
1516
"copyrights": [

tests/data/utils/update_from_copyright_info_copyright_info_added_old.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
{
1111
"path":"test/path.txt",
1212
"name": "path.txt",
13+
"type": "file",
1314
"sha1": "a_modified",
1415
"original_path": "",
1516
"copyrights": []

tests/data/utils/update_from_copyright_info_copyright_info_removed_new.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
{
1111
"path":"test/path.txt",
1212
"name": "path.txt",
13+
"type": "file",
1314
"sha1": "a",
1415
"original_path": "",
1516
"copyrights": []

tests/data/utils/update_from_copyright_info_copyright_info_removed_old.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
{
1111
"path":"test/path.txt",
1212
"name": "path.txt",
13+
"type": "file",
1314
"sha1": "a_modified",
1415
"original_path": "",
1516
"copyrights": [

tests/data/utils/update_from_copyright_info_file_added_one_copyright_new.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
{
2020
"path":"test/path.txt",
2121
"name": "path.txt",
22+
"type": "file",
2223
"sha1": "a",
2324
"original_path": "",
2425
"copyrights": [

tests/data/utils/update_from_copyright_info_no_copyright_changes_new.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
{
1111
"path":"test/path.txt",
1212
"name": "path.txt",
13+
"type": "file",
1314
"sha1": "a",
1415
"original_path": "",
1516
"copyrights": [

tests/data/utils/update_from_copyright_info_no_copyright_changes_old.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
{
1111
"path":"test/path.txt",
1212
"name": "path.txt",
13+
"type": "file",
1314
"sha1": "a_modified",
1415
"original_path": "",
1516
"copyrights": [

tests/data/utils/update_from_copyright_info_no_copyright_key_value_new.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
{
1111
"path":"test/path.txt",
1212
"name": "path.txt",
13+
"type": "file",
1314
"sha1": "a",
1415
"original_path": ""
1516
}

0 commit comments

Comments
 (0)