1 - Assignment 1 - Problem Statements

Practice creating a well-defined problem statement, and then implementing it.

“Programming all too often begins without a clear understanding of the problem.”

– J.M. Yohe1

A good problem statement has the following structure in clearly-labeled sections2:

  1. Concise and precise statement of the problem.
    • Provide a summary of the problem. What is the problem you are trying to solve?
    • If appropriate, include relevant calculations or computations provided by your customer/boss/instructor.
    • Do not write the precise algorithm you will implement.
  2. Clearly specified input format. Input includes function arguments, file contents, or user console input. What does the data look like? For example:
    • three integer values separated by spaces on a line.
    • each bank record consists of the id number (integer), a name (string), and current balance (a float). These values are read from a file. Each line corresponds to a single record, and the values are separated by commas.
    • the user will be prompted to enter their first name, last name, and date of birth in the console as strings.
  3. Clearly specified output format.
    • Output could be printed to the screen, text written to a file, or the values returned from a function.
    • As with input, describe what does this data look like?
  4. Define exceptional conditions, e.g., things you should check for (like invalid values) and what you should do if they occur. For example:
    • The user enters a float when an integer is expected. What will you do?
    • The user provides a filename to read that doesn’t exist. What will you do?
  5. Sample input. This needs to be as exact and precise as possible. For example (matching #2 above):
    • 22,56,999
    • 850123456,"Bob Smith",500.00
    • First name: "Bob", Last name: "Smith", DOB: "01/02/2004"
  6. Sample output. Exact and precise as possible as with the sample input.

Part A - write a problem statement

This will be completed in class.

With a partner (required): Write a problem statement using the best practices described in class. Here is the high-level problem:

Write a program where the user enters three side lengths and the program says if they can form a triangle or not. This is the Triangle Inequality Theorem.

Suppose we label the numbers a, b, and c. They can form a triangle if:
a + b ≥ c, and
b + c ≥ a, and
a + c ≥ b.

The user will input the values from the console. The three sides should be entered separately. Your program must accept the input values, produce a result, and then terminate. You may include a loop that allows the user to repeat the process multiple times before quitting. It’s up to you.

Use this plain text template to write your problem statement. You must save it as a plain .txt file, not Word or anything else.

Grading

I expect that each spec.txt will be different, and that is okay. I am looking for the completion of the problem statement sections that address the functionality required.

Rubric

  • (6 pts) All elements of the template are completed. Sample input values and sample output values must include normal and exceptional behaviors.
  • (1 pts) At least two exceptional conditions are specified.
  • (3 pts) Correct spelling and grammar.

Submission due by Thursday, February 6

Each partner submits their team’s spec.txt to the Canvas assignment 1.A page.

Part B - Implementation

Individually create triangle.py and implement the problem you specified in spec.txt.

The goal is to warm-up your Python skills, and to see how the implementations of two people working from the same spec will be different.

You may not share code under any circumstances. Getting answers to simple Python questions from your peers is fine. Review the Syllabus section on Collaboration and Cheating for what is allowed and not allowed. If in doubt, ask me – I promise I won’t be mad if you ask.

Grading

You are graded on the correctness of your code, not the correctness of the spec.txt. If you discover an error in your spec.txt, you may communicate it with your partner.

Rubric

  • (10 pts): Functionally correct implementation that (a) accepts user input according to the format in your spec, and (b) produces correct output as to whether the input can form a triangle or not for several valid input values.
  • (5 pts): The program detects and handles at least two exceptional conditions you specified in spec.txt. “Handling” means it does not crash with an exception, but terminates or continues gracefully.

You will receive 0 points if your program does not run due to syntax errors or does not complete under “normal” conditions.

Submission due by Sunday, February 9

Submit your triangle.py file to the Canvas assignment 1.B page.


  1. Yohe, J. M. (1974). An Overview of Programming Practices. ACM Computing Surveys (CSUR), 6(4), 221–245. ↩︎

  2. Ledgard, Henry F. (1975). Programming Proverbs. Hayden Book Co. ↩︎

2 - Assignment 2 - Unit testing

Practice implementing and testing simple functions.

Objective

The goal of this assignment is to gain more practice with the tools we have used so far, including implementing a unit test with pytest.

Setup

  1. Create a new project directory named assn2/ or something similar.
    • Mac and Ubuntu on VirtualBox users: Open that directory using PyCharm as usual.
    • WSL users: Follow the setup process as the bottom of the page.
  2. Download grades.py to the assn2/ folder

Instructions

The assignment is to be completed alone. Refer to the Syllabus for policies on what is allowed and what is not.

Implementation

  1. Put your name at the top.
  2. You may not change the main() function in any way.
  3. You may add to the __main__ block to help test if you want.
  4. Complete the functions calculate_average() and determine_grade() according to their docstring descriptions:
    • The docstring tells you what the function must do, the parameters passed to it, the type that must be returned, and any exceptions you need to raise.
    • You may not add any parameters, change the return type, or add to or alter the exceptions required.
    • You must not call print() or input() from these functions.

Testing

  1. Create a test file for grades.py.
  2. Put your name at the top of your test file in a comment.
  3. Write one or more test cases in your test file for calculate_average().
    • The test case must invoke calculate_average() by providing a list, e.g., calculate_average([1,2,6]). Use assert statements to ensure the computed value is correct. You should have multiple asserts to check the calculation.
    • You must write test cases that check the exceptional conditions that raise value errors. Refer to the lab on testing for exceptions.
  4. Write one or more test cases in your test file for determine_grade(). This function does not knowingly raise exceptions, so you do not need to test for them. Test only for expected output given an input.
  5. Run your test file using pytest.

Rubric

  • (15 pts): Your implementation of calculate_average() passes my test cases, which exercises all the details of the function’s docstring.
  • (10 pts): Your implementation of determine_grade() passes my test cases, which exercises all the details of the function’s docstring.
  • (15 pts): Create a control flow graph (CFG) for each of your implementations of calculate_average() and determine_grade() following the rules from class.
    • You may use an online flow chart tool such as draw.io, Canva, or Lucidchart.
    • You may draw your CFG on paper and take a picture. Ensure it is legible.
    • In both cases, export your CVG image to a PDF to submit to Canvas.
  • (25 pts): Your test file can be run using pytest, has multiple test cases, and thoroughly tests the parameters, returns, computations, and exceptions raised of the functions as specified by their docstrings.
  • Your assignment will receive a score of 0 pts for any of the following:
    • print() or input() statements in calculate_average() or determine_grade()
    • Changing main() in any way
    • Changing the method signature of calculate_average() or determine_grade()
    • Your code or tests fail due to syntax error.

Submission due Feb 23

Submit your grades.py, your test file, and your CFG PDF file to the Canvas assignment page.

Setup for WSL Users

You will follow this process for every project on WSL from now on.

  1. Open PyCharm and select the File menu, then Close Project.
  2. Select WSL on the left, then the + button to create a new project.
  3. Select the ... button to pick the Project directory.
  4. Pick your Ubuntu instance at the top, then navigate to home/<your_id>/seng-201/ and create a new folder (icon at the top) for assn2/.
  5. Select the new directory and hit OK.
  6. Click Start IDE and Connect on the screen. PyCharm will take a minute to finish configuring. It should open a new window with a main.py file showing some boilerplate code.
  7. Select the File menu, then Settings.
  8. Select Project: assn2 in the left pane, then click the Python Interpreter link.
  9. Select the Add Interpreter link near the top right, then Add Local Interpreter.
  10. Leave the default options selected and hit OK. If you see a red error message, contact the instructor.
  11. OK out of the settings screen.
  12. Finally, open a new Terminal within PyCharm. Type which pip. You should see something like
    • /home/<your_id>/seng-201/assn2/.venv/bin/pip, or;
    • /home/<your_id>/virtualenvs/assn2/bin/pip
    • but not /usr/bin/python
  13. You will run all subsequent Terminal commands from the integrated Terminal in PyCharm.
  14. run the following in the integrated Terminal:
    pip install pytest pytest-cov
    
  15. Complete the setup instructions at the top of this lab.

3 - Assignment 3 - Information Literacy

Putting your information literacy skills to the test.

Objectives

  • Write effective Internet search queries and use official documentation to research answers.
  • Examine and compare information from various sources to evaluate its accuracy, authority, currency, and relevance.
  • Properly cite and apply the researched information to help solve software engineering problems.

Overview

Software engineers constantly use the Internet to learn how to achieve functionality and to help debug errors.

You will find plenty of wrong or misleading answers on the Internet. Who has time for that? You need to be able to discern between good sources from time wasters.

Instructions

Download and complete assignment_3.docx. Complete it with a partner in class and submit to Canvas.

Code for Task 1

Run the following Python code. You will get an error and stack trace:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
def calculate_cart_total(cart_items, tax_rate):
    """Calculate total cart cost including tax."""
    subtotal = sum(item["price"] * item["quantity"] for item in cart_items)
    return subtotal + (subtotal * tax_rate)

def display_cart_summary(cart_items, tax_rate):
    """Display a summary of the cart."""
    total_cost = calculate_cart_total(cart_items, tax_rate)
    print(f"Total cost (including tax): ${total_cost:.2f}")

def main():
    """Main function to simulate a shopping cart."""
    cart = [
        {"name": "Laptop", "price": 1000.0, "quantity": 1.0},
        {"name": "Headphones", "price": 200.0, "quantity": 2.0},
        {"name": "Mouse", "price": 50.0, "quantity": 1.0},
        {"name": "Keyboard", "price": 150.0, "quantity": 1.0},
        {"name": "Monitor", "price": 300.0, "quantity": 1.0},
        {"name": "HDMI Cable", "price": 10.0, "quantity": 2.0},
        {"name": "USB Drive", "price": "20.0", "quantity": 3.0},
        {"name": "External Hard Drive", "price": 100.0, "quantity": 1.0},
    ]
    tax_rate = 0.07  # 7% sales tax
    display_cart_summary(cart, tax_rate)

if __name__ == "__main__":
    main()

Submission due Friday Feb 28 @ 11:59pm via Canvas

Upload your completed assignment_3.docx to the Canvas assignment page.

4 - Assignment 4 - Meteoric Design, Implementation, and Test

Apply low-level design rules to implement and test your application.

Code resources

Submitting code or other solutions from anywhere other than your own brains is cheating.

  • Can you research how to use a particular function or library such as pytest? Yes.
  • Can you get code that solves all or part of your homework? No.
  • When in doubt, ask. I will not be upset if you ask.

Refer to the full details in the Syllabus on Canvas.

Setup

You will complete a program to analyze the NASA Meteorite Landings dataset: https://data.nasa.gov/widgets/gh4g-9sfh. Setup

  1. Download assignment4.zip and unzip it. It contains three files:
    • meteorite_landings.csv
    • meteoric.py
    • test_meteoric.py
  2. Place these files in an assignment4/ directory if not done for you.
  3. Open the assignment4 directory as a PyCharm project.
  4. Configure pytest:
    • Mac and Ubuntu on VirtualBox users: Open that directory using PyCharm as usual.
    • Windows users: You can use either native Windows or WSL.
      • If using WSL, follow the setup process at the bottom of this page.
      • If you prefer to use native Windows, run the command pip install pytest pytest-cov from the PyCharm Terminal. Let me know if you get errors and I will help.

Implementation

  1. Implement a solution in meteoric.py to the Problem Statement below.
  2. Put your name at the top of meteoric.py in the module docstring.
  3. You may create classes and files and use imported libraries, but these things are not necessary.
  4. Your solution must adhere to the 6 rules of low-level program design. Ask if you have any questions!
  5. You are free to modify the provided code, including load_data() code.
  6. You will need to implement the haversine formula. You may use code from the web, but include the link to the source website in a code comment.
  7. Add docstrings following our conventions to any functions, classes, and files you create.
  8. The code must adhere to the PEP8 coding conventions discussed in class.

Testing

  1. Add test cases to test_meteoric.py. Any additional source files you create must also have a test_*.py test.
  2. All test cases must run from the CLI with pytest.
  3. Use pytest --cov --cov-branch --cov-report=html to generate a branch coverage HTML report in your project directory.
  4. You must achieve 90% branch coverage in all source files except for the main() function.

Rubric

  • (5pts) PEP8 coding conventions followed
  • (5pts) Docstring conventions followed for modules (files), classes (if any), and functions.
  • (25pts) User commands are correctly implemented, including exception handling of user input errors.
  • (10pts) Adherence to our 6 low level design rules.
  • (15pts) Multiple test cases with proper test structure for your source code. pytest branch coverage HTML report demonstrating ≥90% branch coverage of all source code except for main().

Problem Statement

Problem outline

Write a program the analyzes the NASA Meteorite Landings dataset available at https://data.nasa.gov/widgets/gh4g-9sfh. The program runs from the Terminal/CLI. The program will have two primary capabilities. The first is to display all meteorites discovered in a given year. The second is to display the meteorite geographically closest to a provided latitude and longitude.

The program must run from the CLI as python meteoric.py <command> <argument>. See the input format and sample inputs for examples of running the program.

Input format

The program must understand the following commands:

  • year <integer>: Print out the meteorite name, latitude, and longitude for all meteorites discovered in the <integer> year. It is possible that no meteorites were discovered in a given year. Example usage: python meteoric.py year 1999
  • geopoint <latitude,longitude>: Print out the meteorite name, latitude, and longitude for the meteorite with the closest great-circle distance to the coordinates. Latitude is a float in the range [-90.0, 90.0]. Longitude is a float in the range [-180.0, 180.0]. Example usage: python meteoric.py geopoint 34.2257,-77.9447

The data in meteorite_landings.csv looks like this:

name,id,year,reclat,reclong
Aachen,1,1880,50.775,6.08333
Aarhus,2,1951,56.18333,10.23333
Abee,6,1952,54.21667,-113
Acapulco,10,1976,16.88333,-99.9
...
FieldDescription
nameA name for the specific meteorite.
idA unique integer identifier for the meteorite.
yearThe year the meteorite was found or observed. Years are positive 4-digit integers.
reclatThe latitude at which the meteorite was found. Latitudes are floats in the range [-90.0,90.0].
reclongThe longitude at which the meteorite was found. Longitudes are floats in the range [-180.0,180.0].

Important: a load_data() function is provided in meteoric.py that loads the data from meteorite_landings.csv into a list of lists. You do not need to validate the data in the CSV file, however, some fields may be blank if the information is missing.

Output format

  • Print meteorite data to the console in a human-friendly format.
  • When searching for all meteorites that were discovered in a given year the program will either: (a) display a list of meteorites discovered, or (b) display a message stating no meteorites were found for the given year.
  • When searching for the closest meteorite landing from a specific location, the program will display the name (or names if two or more meteorites have an equal distance from the specified location) of the meteorite closest to the location given by the user.
  • If the user fails to provide a valid command or valid arguments, the console displays an error message indicating what the user did incorrectly.

Exceptional conditions

Do not assume the <command> or <argument> are present or valid. The program must print an error message, not an exception or stack trace, if given bad arguments.

  • user can put in an invalid command keyword
  • user does not give an argument
  • user gives an invalid data type with the year keyword
  • user enters a year with no meteorite
  • user inputs latitude and longitude incorrectly
  • user enters multiple arguments
  • user gives an out of range latitude or longitude

Sample input

  1. python meteoric.py test: invalid command
  2. python meteoric.py year: missing argument
  3. python meteoric.py geopoint: missing argument
  4. python meteoric.py year s: invalid argument
  5. python meteoric.py geopoint abcdef: invalid argument
  6. python meteoric.py year 1999 2001 asd: invalid arguments
  7. python meteoric.py geopoint 120.884,300.475: invalid latitude and longitude
  8. python meteoric.py geopoint 32.558,78.854: valid search by geopoint
  9. python meteoric.py year 1818: valid search by year
  10. python meteoric.py year 55: valid search by year, no meteorites match that year

Sample output

You may change these to be more precised if you like, but not less precise.

  1. Invalid command and argument. Correct format is python meteoric.py <command> <argument>.

  2. Invalid command and argument. Correct format is python meteoric.py <command> <argument>.

  3. Invalid command and argument. Correct format is python meteoric.py <command> <argument>.

  4. Invalid argument. year argument must be an integer.

  5. Invalid argument. geopoint argument must be latitude,longitude.

  6. Invalid command and argument. Correct format is python meteoric.py <command> <argument>.

  7. Invalid argument. geopoint latitude or longitude out of range.

  8. Meteorite(s) discovered closest to 32.4, 103.92:
        Guangyuan, latitude: 32.4, longitude: 105.9
    
  9. Meteorite(s) discovered in 1818: 
        Seres, latitude: 41.05, longitude: 23.56667
        Slobodka, latitude: 55, longitude: 35
        Zaborzika, latitude: 50.28333, longitude: 27.68333
        Cambria, latitude: 43.2, longitude: -78.8
        Cape York, latitude: 76.13333, longitude: -64.93333
    
  10. No meteorites found for the year 55.

Submission due Sunday, March 30

Upload all .py files from your project directory to Assignment 4 on Canvas.

Setup for WSL Users

  1. Open PyCharm and select the File menu, then Close Project.
  2. Select WSL on the left, then the + button to create a new project.
  3. Select the ... button to pick the Project directory.
  4. Pick your Ubuntu instance at the top, then navigate to home/<your_id>/seng-201/ and create a new folder (icon at the top) for assignment4.
  5. Select the new directory and hit OK.
  6. Click Start IDE and Connect on the screen. PyCharm will take a minute to finish configuring. It should open a new window with a main.py file showing some boilerplate code.
  7. Select the File menu, then Settings.
  8. Select Project: assignment4 in the left pane, then click the Python Interpreter link.
  9. Select the Add Interpreter link near the top right, then Add Local Interpreter.
  10. Leave the default options selected and hit OK. If you see a red error message, contact the instructor.
  11. OK out of the settings screen.
  12. Finally, open a new Terminal within PyCharm. Type which pip. You should see something like
    • /home/<your_id>/seng-201/assignment4/.venv/bin/pip, or;
    • /home/<your_id>/virtualenvs/assignment4/bin/pip
    • but not /usr/bin/python
  13. You will run all subsequent Terminal commands from the integrated Terminal in PyCharm.
  14. run the following in the integrated Terminal:
    pip install pytest pytest-cov
    
  15. Complete the setup instructions at the top of this lab.

5 - Assignment 5 - Simple Git

Practicing basic Git commands

Objectives

  • Practice the basic Git commands: add and commit and, if necessary, reset
  • Navigate to a remote GitHub repository and push code to it.

Setup

  1. You must have completed both Lab: Git and GitHub setup and Lab: GitHub CLI setup prior to starting this assignment.

  2. Click this link: https://classroom.github.com/a/YpAD2CPJ

  3. Select your name on the “Join the classroom” page and continue.

  4. Select “Accept this assignment” on the next page. You will see a confirmation screen similar to the one below. Refresh the page if you don’t see it.

    Classroom assignment confirmation

  5. Click on the link to your assignment repository. You will see a GitHub remote repository containing a README.md file:

    starting point of the repo for the assignment

  6. Open a Terminal open with your seng-201/ as the working directory. Run the commands below separately, replacing YOUR_REPOSITORY_URL with the URL of your assignment repository from the previous step.

    git clone YOUR_REPOSITORY_URL  # copy the code from GitHub to a new local repostiory
    
  7. In the Terminal, type cd YOUR_NEW_DIRECTORY to change into the project directory. It will be something like cd git-calc-LASTNAME

  8. Run the command git checkout -b more-options

This will create a new subdirectory named git-calc-YOUR_NAME that is a “clone” of a Git repository I created. The checkout -b command creates a new branch, which will be explained in the future.

Open the git-calc directory in your IDE. You will see two files, calc.py and .gitignore. You will do all your work in calc.py.

Instructions

Run calc.py and to try it out with the options. You are going to add to the functionality.

Follow the style in the code. Do not worry about our design rules, unit testing, input validation, or error handling.

  1. Create a separate commit with a brief, meaningful message for each option below. You must have at least two new commits to the more-options branch:
    1. Add a “power” option to raise one number to the power of another. Stage and commit it.
    2. Add a “logarithm” option that computes the log(x, base). Import the standard math library and use the log() function.
    3. The options must be incorporated into the user menu.
  2. All pre-existing options must continue to work, including “Quit”.
  3. Run the command git push to send your completed code to the remote (GitHub).
    • Verify that your changes are in GitHub by visiting your remote repository’s web URL and changing the main dropdown to say more-options.

Rubric

Partial credit is not awarded for these items: all or nothing.

  • (5 pts) Version history (git log) of submission shows a minimum of two new commits (in addition to my initial commit) with are meaningful, concise, and accurate. Commit messages are short summaries of the changes.
  • (5 pts) Your remote repo’s version history show that you contributes a minimum of two versions on the more-options branch.
  • (5 pts) All options (original features + your additions) correctly work in the final commit.

Submission due April 13

Your code is pushed to your GitHub repository.

6 - Assignment 6 - GitHub Flow

Properly using Git to collaborate on teams

Objectives

  • More practice with Git branching and merging
  • Practice of a proper Git workflow to handle merge conflicts properly in a team environment

Interactive class

The Setup, Part A, and Part B of this assignment were worked on in an interactive class. The video of that class is below:

Setup

  1. You must have completed Lab: GitHub CLI setup prior to starting this assignment.
  2. Run the command git config pull.rebase merge
  3. Click this link: https://classroom.github.com/a/SIP7ZMX7
  4. Teams:
    • The first teammate: Create a name like “Team A” that reflects the team assignment in class.
    • The second (and third) teammate: Join the team your partner made.
  5. Finally, accept the assignment.
  6. Click the link to your team repo on the confirmation page.
  7. You will see a repo like the following:
    Assignment 6 repo
  8. git clone the repository to your computer, and open the directory in PyCharm.
  9. Configure pytest:
    • Mac and Ubuntu on VirtualBox users: Open that directory using PyCharm as usual.
    • Windows users: You can use either native Windows or WSL.
      • If using WSL, follow the setup process at the bottom of this page.
      • If you prefer to use native Windows, run the command pip install pytest pytest-cov from the PyCharm Terminal. Let me know if you get errors and I will help.

PAUSE HERE and wait for the instructor

Part A - race to main

  1. Run main.py, which won’t do much, but may create some additional files in your workspace.
  2. You should be on the main branch. Add a comment with only your name to the top of main.py in a comment, e.g., # Alice Bobberton.
  3. Stage, commit, and push the change. Some of you will not be able to…

PAUSE HERE and wait for the instructor

What happens? How do you fix the problem?

  1. The partners need to pull, resolve the conflicts, add, commit, and push the changes.
  2. Make sure that each partner has added, committed, and pushed their name.
  3. Once done, all partners git pull the main branch.

PAUSE HERE and wait for the instructor

Committing to the same branch in a remote repository is a race. Two, three, five, or 10 people committing to the same branch is chaos.

Part B - proper git flow

B.1 - Group discussion

  1. Make sure that main.py in the remote repo’s main branch contains all team members’ names.
  2. Make sure everyone’s local main branch is up to date with the remote main branch by running git pull.
  3. Open string_stuff.py and discuss:
    1. Who will implement reverse_words()
    2. Who will implement count_vowels()
    3. (If you have a 3-person team): who will implement is_palindrome()
    4. You do not need to edit main.py for this assignment.
  4. Each person creates a new feature branch to work in. Use a descriptive branch name reflective of the work you will be doing, not your name.

PAUSE HERE and wait for the instructor

B.2 - Individual work

  1. Each person implements their function in their branch – not in the main/master branch. Talk to and help one another. You can use internet resources, but cite them in a comment if you do.
    • All of your work should be in string_stuff.py
    • Do not worry about writing test code yet.
  2. Remember to do small, incremental commits when appropriate.
  3. Run main.py and manually test your work.
  4. Stage, commit, and push your changes to the remote. Pay attention to the console because you may have to run a variant of the git push command.

PAUSE HERE and wait for the instructor

Integrate your work with main

Now it is time to integrate your changes into main. It will not be painless as there is still a race, but there is a right way and a wrong way to do it. We already did the wrong way. Here is the right way:

  1. git switch main
  2. git pull: make sure you have the latest changes from the main branch in case someone else committed something.
  3. git switch <your-branch>
  4. git merge main: this merges the changes from main into your branch.
  5. Resolve any conflicts in your branch and commit the changes to your branch.
  6. git switch main: now we switch back to main
  7. git merge <your-branch>: bring the changes from your branch into main. This should be smooth because you already resolved merge conflicts between your-branch and main.
  8. git push: now push the updated main to the remote.

This flow will help ensure that main is “good, clean, code”. Merge conflicts will usually only happen in your branch, which is where you want to deal with them.

If each person completes steps 1-7 before anyone else pushes to main, the process will be smooth. If main changes while you are in the middle of these steps, you will not be allowed to push in step 7. You will have to pull main and resolve the merge conflicts either in main or in your-branch.

Good communication helps

A simple heads-up to your partner of, “Hey, I just pushed some changes to main. Make sure to integrate them into your branch” goes a long way.

And “I’m getting ready to integrate to main. Please don’t push anything yet” also helps.

B.3 - Integrate group work

Ensure that everyone’s changes to their branches are integrated into the main branch using proper merging. Make sure main.py runs and works properly for the completed functions.

Part C - for homework due Monday

Part C will add tests to the project to give you some more practice writing test cases in addition to practicing your Git workflow. Code really isn’t complete until it is tested, and developers write unit tests for the code they implement.

Preparation

  1. Complete Part B first.
  2. Ensure that your main remote branch is up-to-date, correct, and “good code”.
  3. Ensure that each partner has checked out and pulled the main branch updates.
  4. Ensure that each partner has merged main into their branch.

At this point, all branches and main should be at the same version, so everyone is starting from the same place.

Instructions

You will write pytest unit test cases in test_string_stuff.py for each of the functions. Refer to the testing labs as necessary. Work with your partners.

  • Individual work
    • The partner who wrote a function also writes the tests for that same function in test_string_stuff.py.
    • Each partner must write a minimum of two test cases: (1) testing “normal” input, (2) verifying the assertions are raised correctly.
    • Commit and push your work to the same branch you worked on while implementing the function, not to main.
    • You do not need to write test cases for main.py.
  • Group integration: Follow the Git Flow from your worksheet to integrate your work into main. Each person:
    1. git switch main
    2. git pull: make sure you have the latest changes from the main branch in case someone else committed something.
    3. git switch <your-branch>
    4. git merge main: this merges the changes from main into your branch.
    5. Resolve any conflicts in your branch and commit the changes to your branch.
    6. git switch main: now we switch back to main
    7. git merge <your-branch>: bring the changes from your branch into main. This should be smooth because you already resolved merge conflicts between your-branch and main.
    8. git push: now push the updated main to the remote.
  • Finishing up:
    • Make sure that all functions and tests work in the main branch.
    • Ensure that you have total branch coverage of the functions you implemented in string_stuff.py.
      • You do not need to commit any coverage information to your repo. The .gitignore file should be ignoring these files, and that’s okay!
    • Make sure that your “final” version of main is pushed to GitHub.

Assignment 6 Rubric

  • (15pts) git log history shows multiple commits to each partner’s branch and integration into main following the prescribed Git Flow
  • (15pts) Final version of main contains functionally correct implementations and test cases achieving 100% branch coverage of all functions implemented in string_stuff.py.

Final submission due Monday, April 28

You will push all your branches and finished code to GitHub.

Setup for WSL Users

  1. Open PyCharm and select the File menu, then Close Project.
  2. Select WSL on the left, then the + button to create a new project.
  3. Select the ... button to pick the Project directory.
  4. Pick your Ubuntu instance at the top, then navigate to home/<your_id>/seng-201/ and create a new folder (icon at the top) for assignment4.
  5. Select the new directory and hit OK.
  6. Click Start IDE and Connect on the screen. PyCharm will take a minute to finish configuring. It should open a new window with a main.py file showing some boilerplate code.
  7. Select the File menu, then Settings.
  8. Select Project: assignment4 in the left pane, then click the Python Interpreter link.
  9. Select the Add Interpreter link near the top right, then Add Local Interpreter.
  10. Leave the default options selected and hit OK. If you see a red error message, contact the instructor.
  11. OK out of the settings screen.
  12. Finally, open a new Terminal within PyCharm. Type which pip. You should see something like
    • /home/<your_id>/seng-201/assignment4/.venv/bin/pip, or;
    • /home/<your_id>/virtualenvs/assignment4/bin/pip
    • but not /usr/bin/python
  13. You will run all subsequent Terminal commands from the integrated Terminal in PyCharm.
  14. run the following in the integrated Terminal:
    pip install pytest pytest-cov
    
  15. Complete the setup instructions at the top of this lab.