Skip to content

Commit

Permalink
inhabitant refactor and reminders.
Browse files Browse the repository at this point in the history
  • Loading branch information
seanchatmangpt committed Aug 24, 2024
1 parent 5c90236 commit 6f6e4eb
Show file tree
Hide file tree
Showing 79 changed files with 3,920 additions and 1,700 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
uses: docker/login-action@v3
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ github.actor }}
username: ${{ github.inhabitant }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set Docker image tag
Expand Down
6 changes: 6 additions & 0 deletions .lh/.lhignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# list file to not track by the local-history extension. comment line starts with a '#' character
# each line describe a regular expression pattern (search for 'Javascript regex')
# it will relate to the workspace directory root. for example:
# '.*\.txt' ignores any file with 'txt' extension
# '/test/.*' ignores all the files under the 'test' directory
# '.*/test/.*' ignores all the files under any 'test' directory (even under sub-folders)
30 changes: 30 additions & 0 deletions .lh/src/dspygen/experiments/auto_spider/spider_main.py.json

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions .lh/src/dspygen/experiments/reminders_models.py.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"sourceFile": "src/dspygen/experiments/reminders_models.py",
"activeCommit": 0,
"commits": [
{
"activePatchIndex": 1,
"patches": [
{
"date": 1724539089221,
"content": "Index: \n===================================================================\n--- \n+++ \n"
},
{
"date": 1724539113430,
"content": "Index: \n===================================================================\n--- \n+++ \n@@ -1,2 +1,1 @@\n-from pydantic import BaseModel, Field\n \n"
}
],
"date": 1724539089221,
"name": "Commit-0",
"content": "from pydantic import BaseModel, Field\n\n"
}
]
}
18 changes: 18 additions & 0 deletions .lh/src/dspygen/experiments/test_wa_reminders.py.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"sourceFile": "src/dspygen/experiments/test_wa_reminders.py",
"activeCommit": 0,
"commits": [
{
"activePatchIndex": 0,
"patches": [
{
"date": 1724537818741,
"content": "Index: \n===================================================================\n--- \n+++ \n"
}
],
"date": 1724537818741,
"name": "Commit-0",
"content": "import pytest\nfrom typer.testing import CliRunner\nfrom wa_reminders import app\nimport subprocess\nimport csv\nimport tempfile\nimport os\nimport pyperclip\n\nrunner = CliRunner()\n\ndef run_applescript(script):\n process = subprocess.Popen(['osascript', '-e', script], stdout=subprocess.PIPE, stderr=subprocess.PIPE)\n output, error = process.communicate()\n if error:\n raise Exception(f\"AppleScript Error: {error.decode('utf-8')}\")\n return output.decode('utf-8').strip()\n\ndef clear_reminders(list_name):\n script = f'''\n tell application \"Reminders\"\n delete every reminder of list \"{list_name}\"\n end tell\n '''\n run_applescript(script)\n\ndef get_reminders(list_name):\n script = f'''\n tell application \"Reminders\"\n set reminderList to list \"{list_name}\"\n set reminderNames to name of every reminder in reminderList\n return reminderNames\n end tell\n '''\n return run_applescript(script).split(\", \")\n\[email protected](scope=\"function\")\ndef temp_csv_file():\n with tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.csv') as temp_file:\n writer = csv.writer(temp_file)\n writer.writerow(['title', 'notes', 'due_date'])\n writer.writerow(['Test Reminder 1', 'Test Notes 1', '2023-05-01'])\n writer.writerow(['Test Reminder 2', 'Test Notes 2', '2023-05-02'])\n yield temp_file.name\n os.unlink(temp_file.name)\n\[email protected](scope=\"function\")\ndef clean_test_list():\n list_name = \"Test Reminders List\"\n clear_reminders(list_name)\n yield list_name\n clear_reminders(list_name)\n\ndef test_import_reminders(temp_csv_file, clean_test_list):\n result = runner.invoke(app, ['import-reminders', temp_csv_file, '--list-name', clean_test_list])\n assert result.exit_code == 0\n assert \"All reminders imported successfully.\" in result.stdout\n\n reminders = get_reminders(clean_test_list)\n assert \"Test Reminder 1\" in reminders\n assert \"Test Reminder 2\" in reminders\n\ndef test_import_from_clipboard(clean_test_list):\n csv_data = \"title,notes,due_date\\nClipboard Reminder,Clipboard Notes,2023-05-03\"\n pyperclip.copy(csv_data)\n\n result = runner.invoke(app, ['import-from-clipboard', '--list-name', clean_test_list])\n assert result.exit_code == 0\n assert \"All reminders imported successfully from clipboard.\" in result.stdout\n\n reminders = get_reminders(clean_test_list)\n assert \"Clipboard Reminder\" in reminders\n\ndef test_import_reminders_file_not_found():\n result = runner.invoke(app, ['import-reminders', 'non_existent_file.csv'])\n assert result.exit_code != 0\n assert \"Error: CSV file 'non_existent_file.csv' not found.\" in result.stdout\n\ndef test_import_reminders_invalid_csv(temp_csv_file, clean_test_list):\n with open(temp_csv_file, 'w') as f:\n f.write(\"invalid,csv,data\\n1,2,3\")\n\n result = runner.invoke(app, ['import-reminders', temp_csv_file, '--list-name', clean_test_list])\n assert result.exit_code != 0\n assert \"Error validating row\" in result.stdout\n\ndef test_import_from_clipboard_invalid_csv(clean_test_list):\n invalid_csv_data = \"invalid,csv,data\\n1,2,3\"\n pyperclip.copy(invalid_csv_data)\n\n result = runner.invoke(app, ['import-from-clipboard', '--list-name', clean_test_list])\n assert result.exit_code != 0\n assert \"Error validating row\" in result.stdout\n"
}
]
}
Loading

0 comments on commit 6f6e4eb

Please sign in to comment.