aws-samples/aws-cdk-intro-workshop

Incorrect HitCounter Construct Import Statement

Opened this issue · 1 comments

Describe the bug

HitCounter Construct import syntax is incorrect, pytest will error attempting to find HitCounter in the cdk_workshop submodule.

Expected Behavior

Expected behavior is successful test run:

pytest
============================================================================== test session starts ===============================================================================
platform darwin -- Python 3.12.0, pytest-6.2.5, py-1.11.0, pluggy-1.3.0
rootdir: /Users/phward/development/cdk_workshop
plugins: typeguard-2.13.3
collected 1 item

tests/unit/test_cdk_workshop_stack.py .                                                                                                                                    [100%]

================================================================================ warnings summary ================================================================================
.venv/lib/python3.12/site-packages/dateutil/tz/tz.py:37
  /Users/phward/development/cdk_workshop/.venv/lib/python3.12/site-packages/dateutil/tz/tz.py:37: DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC).
    EPOCH = datetime.datetime.utcfromtimestamp(0)

-- Docs: https://docs.pytest.org/en/stable/warnings.html
========================================================================== 1 passed, 1 warning in 2.58s ==========================================================================

Current Behavior

Currently pytest fails after initialy creating first assertion test as per workshop instructions:

pytest
============================================================================== test session starts ===============================================================================
platform darwin -- Python 3.12.0, pytest-6.2.5, py-1.11.0, pluggy-1.3.0
rootdir: /Users/phward/development/cdk_workshop
plugins: typeguard-2.13.3
collected 0 items / 1 error

===================================================================================== ERRORS =====================================================================================
_____________________________________________________________ ERROR collecting tests/unit/test_cdk_workshop_stack.py _____________________________________________________________
ImportError while importing test module '/Users/phward/development/cdk_workshop/tests/unit/test_cdk_workshop_stack.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
../../.pyenv/versions/3.12.0/lib/python3.12/importlib/__init__.py:90: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/unit/test_cdk_workshop_stack.py:7: in <module>
    from cdk_workshop.hitcounter import HitCounter
E   ModuleNotFoundError: No module named 'cdk_workshop.hitcounter'
================================================================================ warnings summary ================================================================================
.venv/lib/python3.12/site-packages/dateutil/tz/tz.py:37
  /Users/phward/development/cdk_workshop/.venv/lib/python3.12/site-packages/dateutil/tz/tz.py:37: DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC).
    EPOCH = datetime.datetime.utcfromtimestamp(0)

-- Docs: https://docs.pytest.org/en/stable/warnings.html
============================================================================ short test summary info =============================================================================
ERROR tests/unit/test_cdk_workshop_stack.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
========================================================================== 1 warning, 1 error in 2.52s ===========================================================================

Reproduction Steps

Reproducable by implementing the initial DynamoDB assertion test in Python CDK Workshop

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

No response

Section

No response

Browser

No response

Language

No response

The page https://cdkworkshop.com/30-python/40-hit-counter/100-api.html creates a new file under cdk_workshop called hitcounter.py. Whereas the test at https://cdkworkshop.com/30-python/70-advanced-topics/100-construct-testing/1000-assertion-test.html appears to use the from cdk_workshop.hitcounter import HitCounter (notice cdk_workshop).

  • Needs to be tested by following the workshop end-to-end.
  • Needs to be fixed in both English and Japanese versions, as applicable.