Overview
In this practicum, we are simulating a small shop that sells yarn for knitters.
Setup
Please do not share your work publicly, even after the class is done. We consider that to be an academic integrity violation.
Please set up your system prior to the in-class practicum - you are intended to have 50 minutes to complete the questions without having to deal with setup issues. The setup for this will look a lot like the DB setup instructions you did for the project.
- You will NOT be using your DB project repository for this, since your partner will have access to it. Instead, you will need to go to http://kgcoe-git.rit.edu/ and create a new, private project called
db-yarnshop
. - Make your instructor Reporters on the project (Prof. Meneely’s username
axmvse
) - Clone your empty practicum repository from GitLab locally to your machine.
- Copy over the following files from your DB project so your directory structure looks like this:
db-yarnshop/
├── __init__.py
├── .gitlab-ci.yml
├── .gitignore
├── config
│ ├── db.yml
│ └── gitlab-credentials.yml
├── requirements.txt
├── src
│ ├── __init__.py
└── tests
├── __init__.py
├── test_postgresql.py
- To get the rest of the starter code, go to this repository. Open up the following files one-by-one, review them, then copy them over to their equivalents in your repository. You can also use the “Download” button for this, but we recommend reviewing the files one-at-a-time anyway as part of your exam preparation.
src/swen344_db_utils.py
We have made some improvements from DB0! This will be the default for future classes. Be sure to review.src/yarnshop.py
Most of your work will be in this file.src/yarnshop_schema.sql
Our drop-and-create statements.tests/yarnshop_test_data.sql
Our test data, heavily commented. Be sure to review it!tests/test_postgresql.py
Our test for connecting to Postgrestests/test_schema.py
Our tests to make sure the database can be rebuilt. Refactored from our DB0 setup.tests/test_yarnshop.py
Our main tests. You will be adding new tests to this file as part of the takehome portion and the actual practicum.
- Once you have reviewed and copied those files over, run your unit tests. You should get all tests passing.
- Push your code to GitLab. Make sure you get the code passing on the CI as well.
- You are set up!
Make sure you are able to do this work in the classroom during class time.
Takehome
This is required
We have a few practice methods for you to see what the questions will be like.
- Uncomment the unit tests one-by-one
- Carefully read the documentation of the API method under test
- Carefully read the documentation of the test
- Implement the API method. No additional tests are needed, but you are welcome to add any.
Practicum
This is due at the end of class on Friday, February 23. Push to your master
or main
branch on your repository. Please tag your final submission as submission
.
Note: You may need to fix indentation in the copy-and-paste process
Place these into your yarnshop.py
:
# EXAM
def total_inventory_value():
"""
Returns a floating point number equal to the total price of the inventory
Your solution needs to be performant, secure, maintainable, and ACID compliant
"""
# EXAM
def list_by_weight_and_price(weight, price):
"""
List the brand, title, color name, and price of skeins of yarn.
The weight string must match, and results must have entries with prices less than or equal to the given price.
The results should be in alphabetical order by brand, title, then color name
Your solution needs to be performant, secure, maintainable, and ACID compliant
"""
# EXAM
def kit_summary():
"""
List the yarn within each of the kits with the following information:
* kit title
* an array of weights included (no repeats)
* sum of the total price, plus a 25% kit assembly fee
The summary should be sorted by price, highest first
Your solution needs to be performant, secure, maintainable, and ACID compliant
"""
Place these into your test_yarnshop.py
:
def test_total_inventory_value(self):
self.assertEqual(263.0, total_inventory_value())
def test_find_by_fiber_or_price(self):
expected = [
('Spun Right Round', "Cat's Meow", 'Smitten Kitten', 24.0),
('Wool and the Gang', 'Alpachino Merino', 'Lilac Punch', 22.0),
('Wool and the Gang', 'Alpachino Merino', 'Lime Sorbet', 20.0),
('Wool and the Gang', 'Alpachino Merino', 'Sahara Dust', 21.0)
]
self.assertEqual(expected, list_by_weight_and_price('DK', 25.0))
def test_find_by_fiber_or_price2(self):
expected = [
('MooRoo', 'Moonlight', 'Coral Pop', 32.0)
]
self.assertEqual(expected, list_by_weight_and_price('Worsted', 32.5))
def test_kit_summary(self):
expected = [
('Swanky Sweater', ['DK', 'Worsted'], 93.75),
('Kid Hat', ['DK', 'Worsted'], 66.25),
]
self.assertEqual(expected, kit_summary())
def test_kit_summary2(self):
# Remove Sahara Dust from the kid and recalculate
exec_commit('DELETE FROM kits_inventory WHERE colorway_id=2')
expected = [
('Swanky Sweater', ['DK', 'Worsted'], 67.5),
('Kid Hat', ['DK', 'Worsted'], 66.25),
]
self.assertEqual(expected, kit_summary())
When all tests are passing, there should be 17 tests passing.
Grading (100pts)
- (5 pts) Submission directions followed
- (5 pts) Tests pass
- (5 pts)
add_new_colorways
- (5 pts)
add_new_skein
- (10 pts)
brand_summary
- (10 pts)
colorways_summary
- (10 pts)
total_inventory_value
- (15 pts)
list_by_weight_and_price
- (15 pts)
kit_summary()
- (5 pts) Maintainability
- (10 pts) Security
- (5 pts) Performance
FAQ
Can I use code from my project during the exam?
Yes! But please do not copy from your partner’s code for the practicum.
Can I use the internet to look things up?
Yes! Just don’t use it to communicate with others. And no generative AI usage is allowed (e.g. GitHub Co-Pilot, ChatGPT, etc.)
The indentation is messed up?
Make sure you reindent as your editor expects. Ask your instructor to help you if you need to fix this (Hint: VS Code’s Ctrl+Shift+P
and type Convert indentation to spaces
is helpful).