Skip to content

Add tests for Tag API methods#146

Merged
beaufour merged 3 commits intomasterfrom
add-tag-tests
Jan 23, 2026
Merged

Add tests for Tag API methods#146
beaufour merged 3 commits intomasterfrom
add-tag-tests

Conversation

@beaufour
Copy link
Collaborator

Summary

Add tests for Tag.getHotList, Tag.getListUser, and Tag.getListUserPopular using example responses from the API documentation.

Depends on #145

Changes

Tests (test/test_tags.py)

  • Tests for three Tag API methods using example responses from api-docs
  • Includes xml_to_flickr_json() utility to convert XML examples to Flickr's JSON format
  • Validates correct parsing of API responses

Bug Fixes (flickr_api/objects.py)

  • Tag.getListUser: Changed from Tag(**t) to Tag(text=t) to handle string responses correctly (matching Person.getTags behavior)
  • Tag class: Added missing count converter for getListUserPopular

Other

  • Include 3 api-docs files needed for tests (modify .gitignore to allow)

Test plan

  • Run uv run --python 3.11 python3 -m unittest discover test/ -v - all 13 tests pass

🤖 Generated with Claude Code

beaufour and others added 2 commits January 23, 2026 13:17
Creates scrape_api_docs.py which fetches all 224 API method docs from
flickr.com/services/api/ and saves them as JSON files in api-docs/.
This enables creating test cases from official API documentation.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add tests for Tag.getHotList, Tag.getListUser, and Tag.getListUserPopular
using example responses from the api-docs directory. Includes XML-to-JSON
converter to transform scraped examples into the format returned by the API.

Bug fixes in objects.py:
- Tag.getListUser: Use Tag(text=t) instead of Tag(**t) to match
  Person.getTags behavior. After clean_content(), tags with only text
  content become strings, not dicts.
- Tag class: Add count converter (dict_converter(["count"], int)) which
  was missing but present in Place.Tag, needed for getListUserPopular.

Include the 3 api-docs files needed for tests (modify .gitignore to allow).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Base automatically changed from add-api-scraper to master January 23, 2026 18:34
@beaufour beaufour merged commit 33d8bbe into master Jan 23, 2026
@beaufour beaufour deleted the add-tag-tests branch January 23, 2026 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant