Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions tests/test_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from trakt.api import HttpClient
from trakt.core import api
from trakt.tv import TVShow


def test_api_singleton():
"""Test that api() returns the same HttpClient instance when called multiple times."""
api1 = api()
api2 = api()
assert isinstance(api1, HttpClient), "api() should return an HttpClient instance"
assert api1 == api2, "Multiple calls to api() should return the same instance"


def test_tvshow_properties():
show = TVShow("Game of Thrones")
assert show.title == "Game of Thrones"
assert show.certification == "TV-MA"
Comment on lines +14 to +17
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Test assumes undefined behavior for certification

The test asserts that show.certification equals "TV-MA", but the TVShow class implementation shows that:

  • The certification attribute is initialized as None
  • There's no implementation for setting or retrieving the certification value
  • No evidence of dynamic fetching from API or configuration

This test is likely to fail and needs to be fixed along with the TVShow implementation.

🔗 Analysis chain

Improve test robustness and documentation.

The test could be improved in several ways:

  1. Add a docstring explaining the test purpose
  2. Consider using parameterized testing for different show scenarios
  3. Verify the source of the certification value

Let's verify how the certification is determined:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for certification-related code in TVShow class
ast-grep --pattern 'class TVShow {
  $$$
  certification $$$
  $$$
}'

# Search for TV-MA constant or configuration
rg -l "TV-MA"

Length of output: 130


Script:

#!/bin/bash
# Find and show TVShow class implementation
ast-grep --pattern 'class TVShow'
# Show mock data content
cat tests/mock_data/shows.json
# Find any property definitions for certification
ast-grep --pattern '@property
def certification'

Length of output: 33265


Script:

#!/bin/bash
# Find TVShow class implementation
rg -A 10 "class TVShow"
# Alternative search for certification in Python files
rg -t py "certification"

Length of output: 989