[Test]VirtualCodebase - #166
Conversation
Signed-off-by: Pratik Dey <pratikrocks.dey11@gmail.com>
Signed-off-by: Pratik Dey <pratikrocks.dey11@gmail.com>
Signed-off-by: Pratik Dey <pratikrocks.dey11@gmail.com>
…ths asserts Signed-off-by: Pratik Dey <pratikrocks.dey11@gmail.com>
Signed-off-by: Pratik Dey <pratikrocks.dey11@gmail.com>
Signed-off-by: Pratik Dey <pratikrocks.dey11@gmail.com>
| self.new_files = [] # a list of [[new file1:Original path],[new file2:Original Path],...] | ||
| self.old_files = [] # a list of [[old file1:Original path],[old file2:Original Path],...] | ||
| self.new_files_fingerprint = dict() # map of { {new_file1:fingerprint},{new_file2:fingerprint},...} it will be needed when we need the fingerprints | ||
| self.old_files_fingerprint = dict() # map of { {old_file1:fingerprint},{old_file2:fingerprint},...} |
There was a problem hiding this comment.
used for preserving the fingerprints in a way such that <file_location : figerprint> it is a dictionary
| self.old_files_fingerprint = dict() # map of { {old_file1:fingerprint},{old_file2:fingerprint},...} | ||
| self.new_files_original_path = dict() #this keeps a map of the path of file with respect to original path | ||
| self.old_files_original_path = dict() | ||
|
|
There was a problem hiding this comment.
dictionary
to preserve the it is used later.
|
|
||
| if self.codebase1 is not None and self.codebase2 is not None: | ||
| self.fetch_files(self.codebase1,self.new_files, self.new_files_fingerprint) | ||
| self.fetch_files(self.codebase2,self.old_files, self.old_files_fingerprint) |
There was a problem hiding this comment.
Fetches old and new files
| for i,obj in enumerate(resources): | ||
| files.append([obj,'']) | ||
| try : | ||
| fingerprint[obj.path] = obj.fingerprint |
There was a problem hiding this comment.
stores the fingerprint which is used for similarity matchings
| f[1] = f[0].path | ||
| for f in self.old_files: | ||
| f[1] = f[0].path | ||
|
|
There was a problem hiding this comment.
fix the path as the second value in self.new_files
|
|
||
| def to_dict(self): | ||
| def copyrights_to_dict(self,file): | ||
| """ |
There was a problem hiding this comment.
Copyright comparisons
| else: | ||
| delta.update(0, category.lower() + ' added') | ||
| return | ||
|
|
There was a problem hiding this comment.
changes as per the new design
| elif category not in unique_categories: | ||
| delta.update(0, category.lower() + ' added') | ||
|
|
||
| try: |
There was a problem hiding this comment.
chages as per the new desing
| ratio = (value / total) * 100 | ||
| return round(ratio, 2) | ||
| except ZeroDivisionError: | ||
| return 0 |
There was a problem hiding this comment.
We need to handle this exception as total may be zero in cases where the codebase is not generated in case of invalid paths.
|
|
||
| test_data_dir = os.path.join(os.path.dirname(__file__), 'data') | ||
|
|
||
| # TODO: need to fix in scancode |
There was a problem hiding this comment.
cli/scan_1_file_moved_new.json is having fingerprint attribute so this test will fail as VirtualCodebase do not support fingerprint attribute
Signed-off-by: Pratik Dey <pratikrocks.dey11@gmail.com> fixed tests for test_deltacode.py Signed-off-by: Pratik Dey <pratikrocks.dey11@gmail.com>
…ense_changes Signed-off-by: Pratik Dey <pratikrocks.dey11@gmail.com>
Signed-off-by: Pratik Dey pratikrocks.dey11@gmail.com