[PR #357] [MERGED] Test Mock alternative. Proof of concept. #1122

Closed
opened 2026-03-01 14:48:30 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ArchiveBox/ArchiveBox/pull/357
Author: @cdvv7788
Created: 7/7/2020
Status: Merged
Merged: 7/13/2020
Merged by: @pirate

Base: djangoHead: mock-poc


📝 Commits (4)

  • bf417f5 feat: Add bottle webserver to run along with tests
  • 8f2543f test: Refactor args tests to use local webserver instead of remote requests
  • fe80a93 test: Refactor init tests to use local webserver
  • 322997e test: Refactor util tests to use local webserver

📊 Changes

9 files changed (+487 additions, -11 deletions)

View changed files

📝 setup.py (+1 -0)
tests/conftest.py (+19 -0)
tests/mock_server/__init__.py (+0 -0)
tests/mock_server/server.py (+17 -0)
tests/mock_server/templates/example.com.html (+49 -0)
tests/mock_server/templates/iana.org.html (+390 -0)
📝 tests/test_args.py (+8 -8)
📝 tests/test_init.py (+2 -2)
📝 tests/test_util.py (+1 -1)

📄 Description

Summary

There are cases where playing with the headers and other information in the urls we pass to archivebox is actually useful. If we use something like httmock we would need to know a lot about the internals of several bits of the application, and the tests would need to be updated so they read the mocked version instead of the original one.
Instead of that, we could run a small webserver that serves real content locally, and we can update the tests to consume the content from there. This better reflects the actual behavior the application will have in real usage, and the tests will be kept clean, as the application will be doing exactly the same it does outside testing.

This is a small POC that runs a bottle server while the tests are running.

Changes these areas

  • Bugfixes
  • Feature behavior
  • Command line interface
  • Configuration options
  • Internal architecture
  • Archived data layout on disk

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ArchiveBox/ArchiveBox/pull/357 **Author:** [@cdvv7788](https://github.com/cdvv7788) **Created:** 7/7/2020 **Status:** ✅ Merged **Merged:** 7/13/2020 **Merged by:** [@pirate](https://github.com/pirate) **Base:** `django` ← **Head:** `mock-poc` --- ### 📝 Commits (4) - [`bf417f5`](https://github.com/ArchiveBox/ArchiveBox/commit/bf417f50a4fc6e290b5ff762c607e6af4b5b5d1d) feat: Add bottle webserver to run along with tests - [`8f2543f`](https://github.com/ArchiveBox/ArchiveBox/commit/8f2543fa61b5406e0b058e415f5c9309d832decf) test: Refactor args tests to use local webserver instead of remote requests - [`fe80a93`](https://github.com/ArchiveBox/ArchiveBox/commit/fe80a93a0380a11a3196f194c13bf9ae13531e4e) test: Refactor init tests to use local webserver - [`322997e`](https://github.com/ArchiveBox/ArchiveBox/commit/322997e229457bf43ee2281993ccdc30c8455244) test: Refactor util tests to use local webserver ### 📊 Changes **9 files changed** (+487 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `setup.py` (+1 -0) ➕ `tests/conftest.py` (+19 -0) ➕ `tests/mock_server/__init__.py` (+0 -0) ➕ `tests/mock_server/server.py` (+17 -0) ➕ `tests/mock_server/templates/example.com.html` (+49 -0) ➕ `tests/mock_server/templates/iana.org.html` (+390 -0) 📝 `tests/test_args.py` (+8 -8) 📝 `tests/test_init.py` (+2 -2) 📝 `tests/test_util.py` (+1 -1) </details> ### 📄 Description # Summary There are cases where playing with the headers and other information in the urls we pass to `archivebox` is actually useful. If we use something like `httmock` we would need to know a lot about the internals of several bits of the application, and the tests would need to be updated so they read the mocked version instead of the original one. Instead of that, we could run a small webserver that serves real content locally, and we can update the tests to consume the content from there. This better reflects the actual behavior the application will have in real usage, and the tests will be kept clean, as the application will be doing exactly the same it does outside testing. This is a small POC that runs a `bottle` server while the tests are running. # Changes these areas - [ ] Bugfixes - [X] Feature behavior - [ ] Command line interface - [ ] Configuration options - [ ] Internal architecture - [ ] Archived data layout on disk --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-01 14:48:30 +03:00
Sign in to join this conversation.
No milestone
No project
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
starred/ArchiveBox#1122
No description provided.