{"id":19891183,"url":"https://github.com/barbarpotato/tdd-bdd-final-project","last_synced_at":"2026-05-14T10:35:58.059Z","repository":{"id":219544477,"uuid":"749296803","full_name":"Barbarpotato/TDD-BDD-Final-Project","owner":"Barbarpotato","description":"Test Driven Development / Behavior Driven Development Final Project  On IBM","archived":false,"fork":false,"pushed_at":"2024-01-28T07:19:42.000Z","size":127,"stargazers_count":0,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-11T19:35:40.961Z","etag":null,"topics":["behavior-driven-development","integration-testing","python","selenium-webdriver","system-testing","test-driven-development","unit-testing"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Barbarpotato.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2024-01-28T06:30:26.000Z","updated_at":"2024-03-22T13:06:47.000Z","dependencies_parsed_at":"2024-01-28T08:26:41.643Z","dependency_job_id":"208502dc-c6c5-472a-9b70-2de7d310c3d2","html_url":"https://github.com/Barbarpotato/TDD-BDD-Final-Project","commit_stats":null,"previous_names":["barbarpotato/tdd-bdd-final-project"],"tags_count":0,"template":false,"template_full_name":"ibm-developer-skills-network/xgcyk-tdd-bdd-final-project-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Barbarpotato%2FTDD-BDD-Final-Project","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Barbarpotato%2FTDD-BDD-Final-Project/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Barbarpotato%2FTDD-BDD-Final-Project/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Barbarpotato%2FTDD-BDD-Final-Project/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Barbarpotato","download_url":"https://codeload.github.com/Barbarpotato/TDD-BDD-Final-Project/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241317693,"owners_count":19943203,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["behavior-driven-development","integration-testing","python","selenium-webdriver","system-testing","test-driven-development","unit-testing"],"created_at":"2024-11-12T18:17:21.974Z","updated_at":"2026-05-14T10:35:58.006Z","avatar_url":"https://github.com/Barbarpotato.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TDD / BDD Final Project Template\n\nThis repository contains the template to be used for the Final Project for the Coursera course **Introduction to TDD/BDD**.\n\n## Usage\n\nThis repository is to be used as a template to create your own repository in your own GitHub account. No need to Fork it as it has been set up as a Template. This will avoid confusion when making Pull Requests in the future.\n\nFrom the GitHub **Code** page, press the green **Use this template** button to create your own repository from this template. \n\nName your repo: `tdd-bdd-final-project`.\n\n## Setup\n\nAfter entering the lab environment you will need to run the `setup.sh` script in the `./bin` folder to install the prerequisite software.\n\n```bash\nbash bin/setup.sh\n```\n\nThen you must exit the shell and start a new one for the Python virtual environment to be activated.\n\n```bash\nexit\n```\n\n## Tasks\n\nIn this project you will use good Test Driven Development (TDD) and Behavior Driven Development (BDD) techniques to write TDD test cases, BDD scenarios, and code, updating the following files:\n\n```bash\ntests/test_models.py\ntests/test_routes.py\nservice/routes.py\nfeatures/products.feature\nfeatures/steps/load_steps.py\n```\n\nYou will be given partial implementations in each of these files to get you started. Use those implementations as examples of the code you should write.\n\n## License\n\nLicensed under the Apache License. See [LICENSE](/LICENSE)\n\n## Author\n\nJohn Rofrano, Senior Technical Staff Member, DevOps Champion, @ IBM Research\n\n## \u003ch3 align=\"center\"\u003e © IBM Corporation 2023. All rights reserved. \u003ch3/\u003e\n\n## Excercise 1: Create Fake Products\nIn the tests/factories.py file, use the Faker providers and Fuzzy attributes to create fake data for the name, description, price, available, and category fields by adding them to the ProductFactory class.\n\n### Solution\n```py\nclass ProductFactory(factory.Factory):\n    \"\"\"Creates fake products for testing\"\"\"\n\n    class Meta:\n        \"\"\"Maps factory to data model\"\"\"\n\n        model = Product\n\n    id = factory.Sequence(lambda n: n)\n    name = FuzzyChoice(\n        choices=[\n            \"Hat\",\n            \"Pants\",\n            \"Shirt\",\n            \"Apple\",\n            \"Banana\",\n            \"Pots\",\n            \"Towels\",\n            \"Ford\",\n            \"Chevy\",\n            \"Hammer\",\n            \"Wrench\"\n        ]\n    )\n    description = factory.Faker(\"text\")\n    price = FuzzyDecimal(0.5, 2000.0, 2)\n    available = FuzzyChoice(choices=[True, False])\n    category = FuzzyChoice(\n        choices=[\n            Category.UNKNOWN,\n            Category.CLOTHS,\n            Category.FOOD,\n            Category.HOUSEWARES,\n            Category.AUTOMOTIVE,\n            Category.TOOLS,\n        ]\n    )\n```\n\n## Exercise 2: Create Test Cases for the Model\nBefore we proceed with creating test cases for the Product Model, let us see the different attributes used in this model:\n\u003ctable\u003e\n\u003cthead\u003e\n\u003ctr\u003e\n\u003cth\u003eAttribute\u003c/th\u003e\n\u003cth\u003eDescription\u003c/th\u003e\n\u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\u003ctr\u003e\n\u003ctd\u003eid\u003c/td\u003e\n\u003ctd\u003eThe id of the product\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003ename\u003c/td\u003e\n\u003ctd\u003eThe name of the product\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003edescription\u003c/td\u003e\n\u003ctd\u003eThe description of the product\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003eprice\u003c/td\u003e\n\u003ctd\u003eThe price of the product\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003eavailable\u003c/td\u003e\n\u003ctd\u003eTrue if the product is available, otherwise False\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003ecategory\u003c/td\u003e\n\u003ctd\u003eThe category under which the product belongs\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\u003c/table\u003e\nPlease refer to the Reading: About the Product Model (include link to the course reading) to understand the classes and methods used in the models.py file.\n\nThe first thing you need to do while creating test cases for the Model, is ensure that the database model is working correctly. Someone wrote all of the code but only wrote a test case for create. You have no idea if the other functions work properly or not.\n\n### Task\nCreate test cases in tests/test_models.py to exercise the code in service/models.py to test that the Product model works.\n\n1. Write test case to read a product and ensure that it passes\n2. Write test case to update a product and ensure that it passes\n3. Write test case to delete a product and ensure that it passes\n4. Write test case to list all products\n5. Write test case to search for a product by name and ensure that it passes\n6. Write test case to search for a product by category and ensure that it passes\n7. Write test case to search for a product by availability and ensure that it passes\n\n\n## Exercise 3: Create Test Cases and Code for REST API\nNow that you know that the model is working, you can move on to developing the REST API which will accept json requests, call the model, and return an answer as json.\n\nYour REST API must implement the following endpoints:\n\n- Create a Product\n- Read a Product\n- Update a Product\n- Delete a Product\n- List all Products\n- List Products by Category, Availability, and Name\n\n### Task\nEdit the test cases in tests/test_routes.py and code in service/routes.py for a RESTful endpoint using Flask that contains the following endpoints:\n\n1. Write a test case to Read a Product and watch it fail\n2. Write the code to make the Read test case pass\n3. Write a test case to Update a Product and watch it fail\n4. Write the code to make the Update test case pass\n5. Write a test case to Delete a Product and watch it fail\n6. Write the code to make the Delete test case pass\n7. Write a test case to List all Products and watch it fail\n8. Write the code to make the List all test case pass\n9. Write a test case to List by name a Product and watch it fail\n10. Write the code to make the List by name test case pass\n11. Write a test case to List by category a Product and watch it fail\n12. Write the code to make the List by category test case pass\n13. Write a test case to List by availability a Product and watch it fail\n14. Write the code to make the List by availability test case pass\n\n## Exercise 4: Load BDD background data\nThe first thing you will need to do for BDD testing, is write the Python code to load the data from the background: statement in the products.feature file. Remember that the data is stored in the context.table attribute and each row is a Python dictionary (dict) that you can dereference using the names at the top of the columns in the background: statement.\n\n### Task\nUpdate the features/steps/load_steps.py file to load background data from your BDD scenarios into your service before each scenario executes.\n\nThe code to delete all of the products is already given to you. You just need to write the code to load the products from context.table.\n\n## Exercise 5: Create BDD Scenarios\nNow that the background data is loaded, it’s time to write the scenarios to test the UI. The Create a Product scenario is already written as an example of what you need to do.\n\nThe service already contains a UI that looks like this:\u003cbr\u003e\n\u003cimg src=\"https://cf-courses-data.s3.us.cloud-object-storage.appdomain.cloud/IBM-CD0241EN-SkillsNetwork/images/final-product-ui.png\"/\u003e\u003cbr\u003e\n\n### Task\n- Update the features/products.feature file with BDD Scenarios that prove that the following behaviors of the UI work as expected:\n1. Read a Product\n2. Update a Product\n3. Delete a Product\n4. List all Products\n5. Search for Products by Category\n6. Search for Products by Availability\n7. Search for Products by Name\n\n## Exercise 6: Implementing Steps\nIn BDD, test scenarios are often written in a human-readable format, such as Gherkin, and these scenarios are translated into automated tests using step definitions.\n\nThe web_steps.py file contains the step definitions for the web-related actions on the UI.\n\nPlease check [Hands-on Lab: Implementing Your First Steps](link to the lab page to be included) for any reference you may need to understand about how step definitions are implemented, before proceeding further.\n\nThe step definitions for the first few steps are already given to you.\n\n\n### Task\nUpdate the features/steps/web_steps.py file with the remaining step definitions.\n\nStart by opening the file web_steps.py.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbarbarpotato%2Ftdd-bdd-final-project","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbarbarpotato%2Ftdd-bdd-final-project","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbarbarpotato%2Ftdd-bdd-final-project/lists"}