Repository navigation
Halyna R. #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
halyna1995
wants to merge
5
commits into
HackYourAssignment:main
Choose a base branch
from
halyna1995:week2-attempt
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Halyna R. #1
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
51393e7
Complete week 2 clean pipeline assignment
halyna1995 2c60192
Add transaction_id field to Transaction model
halyna1995 ae91844
Modify write_csv to return on empty input
halyna1995 60305df
Fix append syntax for result list in transforms.py
halyna1995 cc0b661
Refactor tests and add transformation sequence
halyna1995 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| transaction_id,product_name,category,price,quantity,customer_email,date,revenue,vat | ||
| 1,Laptop Pro,Electronics,999.99,2,[email protected],2024-03-15,1999.98,420.0 | ||
| 2,Wireless Mouse,Electronics,29.99,5,[email protected],2024-03-15,149.95,31.49 | ||
| 3,Usb Cable,Electronics,4.99,10,,2024-03-16,49.9,10.48 | ||
| 4,Office Chair,Furniture,349.5,1,[email protected],2024-03-16,349.5,73.39 | ||
| 5,Standing Desk,Furniture,599.0,1,[email protected],not_a_date,599.0,125.79 | ||
| 9,Webcam Hd,Electronics,54.99,1,,2024-03-18,54.99,11.55 | ||
| 10,Desk Lamp,Furniture,34.99,4,[email protected],2024-03-19,139.96,29.39 | ||
| 11,Noise Cancelling Headphones,Electronics,199.99,1,[email protected],2024-03-19,199.99,42.0 | ||
| 12,Cable Management Kit,Furniture,15.99,6,[email protected],2024-03-20,95.94,20.15 | ||
| 13,Ergonomic Mouse Pad,Furniture,24.99,3,[email protected],2024-03-20,74.97,15.74 | ||
| 14,Laptop Stand,Furniture,45.99,2,[email protected],2024-03-21,91.98,19.32 | ||
| 15,Bluetooth Speaker,Unknown,39.99,1,[email protected],2024-03-21,39.99,8.4 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file added
BIN
+8.94 KB
task-1/tests/__pycache__/test_transforms.cpython-311-pytest-9.0.3.pyc
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ | |
| - test_calculate_revenue_adds_fields | ||
| - test_no_mutation | ||
| """ | ||
| import pytest | ||
| from copy import deepcopy | ||
|
|
||
| from src.transforms import ( | ||
| calculate_revenue, | ||
|
|
@@ -15,26 +15,41 @@ | |
| remove_invalid, | ||
| ) | ||
|
|
||
|
|
||
| def test_remove_invalid_drops_empty_names(): | ||
| # TODO: feed in 3 rows (one valid, one empty product_name, one | ||
| # whitespace-only product_name); assert only the valid one survives. | ||
| raise NotImplementedError | ||
|
|
||
|
|
||
| def test_clean_fields_normalizes_names(): | ||
| # TODO: feed a row with messy product_name and uppercase email; assert | ||
| # the output has stripped + title-cased name and lowercase email. | ||
| raise NotImplementedError | ||
|
|
||
|
|
||
| def test_calculate_revenue_adds_fields(): | ||
| # TODO: feed a row with price=100, quantity=3; assert output has | ||
| # revenue=300.0 and vat=63.0 (default VAT rate is 0.21). | ||
| raise NotImplementedError | ||
|
|
||
|
|
||
|
|
||
| def test_no_mutation(): | ||
| # TODO: feed in a list, run any transform on it, assert the original | ||
| # list is unchanged. This is the most important test in the file. | ||
| raise NotImplementedError | ||
| """Run all transforms and assert the original list is unchanged.""" | ||
| original = [ | ||
| { | ||
| "transaction_id": "1", | ||
| "product_name": " laptop ", | ||
| "category": "", | ||
| "price": "100", | ||
| "quantity": "2", | ||
| "customer_email": " [email protected] ", | ||
| "date": "2025-01-15", | ||
| }, | ||
| { | ||
| "transaction_id": "2", | ||
| "product_name": "Mouse", | ||
| "category": "Accessories", | ||
| "price": "25", | ||
| "quantity": "0", | ||
| "customer_email": "[email protected]", | ||
| "date": "2025-01-16", | ||
| }, | ||
| ] | ||
|
|
||
| transforms = [ | ||
| remove_invalid, | ||
| clean_fields, | ||
| filter_zero_quantity, | ||
| calculate_revenue, | ||
| ] | ||
|
|
||
| for transform in transforms: | ||
| rows = deepcopy(original) | ||
| expected = deepcopy(rows) | ||
|
|
||
| transform(rows) | ||
|
|
||
| assert rows == expected | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.