Skip to content

Commit

Permalink
Merge pull request #60 from CodeReviewerAi/fix-tests
Browse files Browse the repository at this point in the history
Fix tests
  • Loading branch information
johan-t authored Jan 13, 2024
2 parents 36e78e3 + ebbe395 commit 3bed5f8
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 1,029 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
.env
testing.json
training.json
test_function_changes.json
package-lock.json
path
.DS_Store
**/__pycache__
node_modules
temp.js
temp.js
testing.json
dataForTesting/
970 changes: 0 additions & 970 deletions dataForTesting/testing.json

This file was deleted.

39 changes: 0 additions & 39 deletions dataForTesting/training.json

This file was deleted.

6 changes: 4 additions & 2 deletions function_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import time
import subprocess

def get_function_data(repo_path='../inputData/testRepo'):
def get_function_data(repo_path='../inputData/testRepo', output_path='./dataForTesting/test_function_changes.json'):
script_dir = os.path.dirname(os.path.abspath(__file__))
repo_path = os.path.join(script_dir, repo_path)
repo_name = os.path.basename(repo_path) # Extract the repository name
Expand Down Expand Up @@ -196,7 +196,9 @@ def find_function(node, function_name):
'merged_function': func_info['merged_function'],
}

return repo_data
# Save to the specified output path
with open(output_path, 'w') as f:
json.dump(repo_data, f, indent=4)

if __name__ == '__main__':
start_time = time.time()
Expand Down
25 changes: 11 additions & 14 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,16 @@ def main(repos_info):
for repo_info in repos_info:
repo_path, data_type = repo_info['path'], repo_info['type']

# Run the main function from getFunctionData
print(f"Processing repository: {repo_path}, Data type: {data_type}")
function_data_output = function_data.get_function_data(repo_path)

# Output paths based on data type
# Determine the output path based on data type
if data_type == 'training':
output_path = './dataForTesting/training.json'
else: # Default to test
output_path = './dataForTesting/testing.json'

# Save function data to the appropriate file
with open(output_path, 'w') as f:
json.dump(function_data_output, f, indent=4)
# Run the main function from getFunctionData with the specified output path
print(f"Processing repository: {repo_path}, Data type: {data_type}")
function_data.get_function_data(repo_path, output_path)
print(f"Done processing repository: {repo_path}, Data type: {data_type}")

# Normalize the scores for all data
normalize_scores.normalize_and_save_change_counts('dataForTesting/training.json')
Expand All @@ -47,12 +44,12 @@ def main(repos_info):
# List of repositories and their types
repos_info = [
{'path': '../inputData/trainingData/24petwatch', 'type': 'training'},
{'path': '../inputData/trainingData/danaher-ls-aem', 'type': 'training'},
{'path': '../inputData/trainingData/mammotome', 'type': 'training'},
{'path': '../inputData/trainingData/moleculardevices', 'type': 'training'},
{'path': '../inputData/trainingData/petplace', 'type': 'training'},
{'path': '../inputData/trainingData/theplayers', 'type': 'training'},
{'path': '../inputData/trainingData/walgreens', 'type': 'training'},
#{'path': '../inputData/trainingData/danaher-ls-aem', 'type': 'training'},
#{'path': '../inputData/trainingData/mammotome', 'type': 'training'},
#{'path': '../inputData/trainingData/moleculardevices', 'type': 'training'},
#{'path': '../inputData/trainingData/petplace', 'type': 'training'},
#{'path': '../inputData/trainingData/theplayers', 'type': 'training'},
#{'path': '../inputData/trainingData/walgreens', 'type': 'training'},
{'path': '../inputData/testData/elixirsolutions', 'type': 'testing'},
]

Expand Down
2 changes: 1 addition & 1 deletion test_get_function_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class TestFunctionData(unittest.TestCase):
@classmethod
def setUpClass(cls):
# Execute the script to update the function data
function_data.get_function_data()
function_data.get_function_data(output_path='./dataForTesting/test_function_changes.json')

# Load the function changes data
with open('./dataForTesting/test_function_changes.json', 'r') as file:
Expand Down

0 comments on commit 3bed5f8

Please sign in to comment.