Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

Incorrect HitCounter Construct Import Statement #1311

Closed
phil-ward opened this issue Jan 22, 2024 · 2 comments
Closed

Incorrect HitCounter Construct Import Statement #1311

phil-ward opened this issue Jan 22, 2024 · 2 comments
Labels
bug This issue is a bug. effort/small Small work item – less than a day of effort p2

Comments

@phil-ward
Copy link

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

@phil-ward phil-ward added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jan 22, 2024
@ashishdhingra
Copy link
Contributor

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.

@ashishdhingra ashishdhingra added effort/small Small work item – less than a day of effort p2 and removed needs-triage This issue or PR still needs to be triaged. labels Apr 16, 2024
@kellertk kellertk closed this as completed Aug 1, 2024
Copy link

github-actions bot commented Aug 1, 2024

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue is a bug. effort/small Small work item – less than a day of effort p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants