1
1
Fork
You've already forked spatula
0

WIP: add some test_utils to experiment with #38

Draft
jamesturk wants to merge 4 commits from test_utils into main
pull from: test_utils
merge into: jpt:main
jpt:main
jpt:gh-pages
jamesturk commented 2023年08月06日 07:24:39 +02:00 (Migrated from github.com)
Copy link

Aims to address #37
CachedTestURL is the workhorse here, it replaces URL (and can be hot swapped in for it) and instead of always making a request, it favors a locally cached copy. These copies could be generated manually, but there is also an environment variable that will tell spatula to fetch them if they are missing.

Right now it takes the same properties as URL, but could be extended to take response text as suggested in #37
(Also, needs to use all properties of request/response in caching.)

This branch also adds two helper methods so people don't have to work with this directly if they don't want to:

  • cached_page_response(page: Page) -> Page - returns a page where a request has already been made using CachedTestURL -- allowing you to call methods on your page object as if you're inside of do_scrape
  • cached_page_items(page: Page) -> list[item] - returns the result of do_scrape collected into a list
Aims to address #37 `CachedTestURL` is the workhorse here, it replaces URL (and can be hot swapped in for it) and instead of always making a request, it favors a locally cached copy. These copies could be generated manually, but there is also an environment variable that will tell spatula to fetch them if they are missing. Right now it takes the same properties as URL, but could be extended to take response text as suggested in #37 (Also, needs to use all properties of request/response in caching.) This branch also adds two helper methods so people don't have to work with this directly if they don't want to: - `cached_page_response(page: Page) -> Page` - returns a page where a request has already been made using `CachedTestURL` -- allowing you to call methods on your page object as if you're inside of `do_scrape` - `cached_page_items(page: Page) -> list[item]` - returns the result of `do_scrape` collected into a list
This pull request has changes conflicting with the target branch.
  • .gitignore
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin test_utils:test_utils
git switch test_utils

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch main
git merge --no-ff test_utils
git switch test_utils
git rebase main
git switch main
git merge --ff-only test_utils
git switch test_utils
git rebase main
git switch main
git merge --no-ff test_utils
git switch main
git merge --squash test_utils
git switch main
git merge --ff-only test_utils
git switch main
git merge test_utils
git push origin main
Sign in to join this conversation.
No reviewers
Labels
Clear labels
No items
No labels
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
jpt/spatula!38
Reference in a new issue
jpt/spatula
No description provided.
Delete branch "test_utils"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?