Skip to content

Commit

Permalink
ran black
Browse files Browse the repository at this point in the history
  • Loading branch information
Mustaballer committed Jun 25, 2023
1 parent 2211f78 commit f58fd5f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
13 changes: 9 additions & 4 deletions openadapt/crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def export_sql(recording_id):
recording.double_click_interval_seconds,
recording.double_click_distance_pixels,
recording.platform,
recording.task_description
recording.task_description,
)

logger.info(f"Recording with ID {recording_id} exported successfully.")
Expand All @@ -178,13 +178,17 @@ def create_db(recording_id, sql, values):
timestamp = time.time()
source_file_path = config.ENV_FILE_PATH
target_file_path = f"{config.ENV_FILE_PATH}-{timestamp}"
logger.info(f"source_file_path={source_file_path}, target_file_path={target_file_path}")
logger.info(
f"source_file_path={source_file_path}, target_file_path={target_file_path}"
)
shutil.copyfile(source_file_path, target_file_path)
config.set_db_url(db_fname)

with open(config.ENV_FILE_PATH, "r") as env_file:
env_file_lines = [
f"DB_FNAME={db_fname}\n" if env_file_line.startswith("DB_FNAME") else env_file_line
f"DB_FNAME={db_fname}\n"
if env_file_line.startswith("DB_FNAME")
else env_file_line
for env_file_line in env_file.readlines()
]

Expand Down Expand Up @@ -231,6 +235,7 @@ def export_recording(recording_id):
restore_db(timestamp)
return db_file_path


def get_recording(timestamp):
return db.query(Recording).filter(Recording.timestamp == timestamp).first()

Expand Down Expand Up @@ -264,4 +269,4 @@ def get_screenshots(recording, precompute_diffs=False):


def get_window_events(recording):
return _get(WindowEvent, recording.timestamp)
return _get(WindowEvent, recording.timestamp)
2 changes: 1 addition & 1 deletion openadapt/share.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,4 @@ def receive_recording(wormhole_code):
"send": send_recording,
"receive": receive_recording,
}
)
)
14 changes: 10 additions & 4 deletions tests/openadapt/test_share.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ def test_export_recording_to_folder(self):
f.write("Recording data")

# Mock the crud.export_recording() function to return the temporary file path
with patch("openadapt.share.crud.export_recording", return_value=recording_db_path):
with patch(
"openadapt.share.crud.export_recording", return_value=recording_db_path
):
zip_file_path = share.export_recording_to_folder(recording_id)

self.assertIsNotNone(zip_file_path)
Expand All @@ -34,14 +36,18 @@ def test_send_file(self):
share.send_file(file_path)

# Verify that the command is called with the correct arguments
mock_run.assert_called_once_with(["wormhole", "send", file_path], check=True)
mock_run.assert_called_once_with(
["wormhole", "send", file_path], check=True
)

# Clean up the temporary file
os.remove(file_path)

def test_send_recording(self):
# Mock the export_recording_to_folder() function to return a zip file path
with patch("openadapt.share.export_recording_to_folder", return_value="temp.zip"):
with patch(
"openadapt.share.export_recording_to_folder", return_value="temp.zip"
):
# Mock the send_file() function to avoid sending the file
with patch("openadapt.share.send_file"):
share.send_recording(1)
Expand All @@ -62,4 +68,4 @@ def test_receive_recording(self):


if __name__ == "__main__":
unittest.main()
unittest.main()

0 comments on commit f58fd5f

Please sign in to comment.