---
# System prepended metadata

title: MPHY0021 - Day 5 (4th November 2021)
tags: [class, teaching, mphy0021]

---

# MPHY0021 - Day 5 (4th November 2021)

:::info
## :tada: Welcome to the fifth day! Testing code with :snake:
 

### Today
Today we will look at writing automated tests in Python.
- Testing edge cases
- Testing that that it errors when it should fail
- Automating tests
- Avoid code repetition in your tests
:::

### :stopwatch: Time keeper
- [name=Siyi] :raised_hand: 5' before the end.
 - 10:00 - 10:50
 - 11:05 - 11:55
 - 12:05 - 12:55

### Review from last week 
- :1234: Data and Python :snake: (csv, json, yaml)
- :chart_with_upwards_trend: a bit about graphs

#### What was discussed during the week :newspaper: 
- Sample solution for plotting exercise published
- Practical homework done by at least 18 people (count this morning)
- Assignment has been released, deadline: 23rd Nov - join via GitHub Classroom, submit on Moodle
  
 
### Groups :handshake: 

We will be using the breaking rooms functionality of Zoom.
We have the following groups, and each group have its own document. Each week you will be in a randomly allocated group.

Once in your breakout-room, find who is chairing that room and open the document linked to that group.

:::danger
Remember to `rename` yourself by clicking on your zoom name (in the participants list) and change it to:
`SGX - Your name` being `X` the number of the group you have been assigned to.

If you disconnect and connect again, please rename yourself again.
:::


 - [Group 1 (Alessandro)](https://hackmd.io/@UCL-MPHY0021-21-22/H1OzkCkPK)
 - [Group 2 (Nina)](https://hackmd.io/@UCL-MPHY0021-21-22/BkbxlAkDY):
 - [Group 3 (Nisha)](https://hackmd.io/@UCL-MPHY0021-21-22/rJz4lAyDY):
 - [Group 4 (Matt)](https://hackmd.io/@UCL-MPHY0021-21-22/SkgoxC1DF)
 - [Group 5 (Matthew)](https://hackmd.io/@UCL-MPHY0021-21-22/BJVTlCyDY):
 - [Group 6 (Stef)](https://hackmd.io/@UCL-MPHY0021-21-22/rJrgW0yDY):
 - [Group 7 (David)](https://hackmd.io/@UCL-MPHY0021-21-22/BJOMZRJwY):

### Discussion of preparation work
- testing terminology - on [Mentimeter](https://www.menti.com/9fi8o1xcxa).
- homework consisted of writing a unit test for `times.py`
- what else should be tested about `times.py` ([questionnaire](https://moodle.ucl.ac.uk/mod/questionnaire/view.php?id=2483635))


### Exercise: Write more tests
:::info

For this exercise, we will continue working with the `times.py` that was part of the class preparation.

In smaller groups, share a screen and discuss how to write the tests required. Then work collaboratively on the exercise.

rse-classwork repo: [:hash::one::seven:](https://github.com/UCL-MPHY0021-21-22/RSE-Classwork/issues/17) 

:::spoiler call a helper to your room
If you need help, you can ask for us to drop in click "Ask for Help" :grey_question: button in the meeting controls.
If you don't find it, [watch this video showing where it is](https://www.youtube.com/watch?v=yIOMPRLQIHA).

:::

### Discussion: 


On Mentimeter.
    
Ask about things you were unsure of, and point out anything you found interesting or unexpected.

### Time for a short-movie :film_projector: 
What can happen when tests are lacking?

### Exercise: Write a negative test
:::info

Let's keep checking the robustness of this code!

In smaller groups, share a screen, discuss how to write the required test, and work collaboratively on the exercise.

rse-classwork repo: [:hash::one::eight:](https://github.com/UCL-MPHY0021-21-22/RSE-Classwork/issues/18)

:::spoiler call a helper to your room
If you need help, you can ask for us to drop in click "Ask for Help" :grey_question: button in the meeting controls.
If you don't find it, [watch this video showing where it is](https://www.youtube.com/watch?v=yIOMPRLQIHA).

:::
### Discussion of the exercise

On [Mentimeter](https://www.menti.com/9fi8o1xcxa).

Ask about things you were unsure of, and point out anything you found interesting or unexpected.


### Exercise: :construction_worker: Running the tests automatically
:::info

Easy check that new contributions don't break stuff.

In smaller groups, share a screen and work collaboratively on the exercise.

rse-classwork repo: [:hash::one::nine:](https://github.com/UCL-MPHY0021-21-22/RSE-Classwork/issues/19) 

:::spoiler call a helper to your room
If you need help, you can ask for us to drop in click "Ask for Help" :grey_question: button in the meeting controls.
If you don't find it, [watch this video showing where it is](https://www.youtube.com/watch?v=yIOMPRLQIHA).

:::
### Discussion of the exercise

On [Mentimeter](https://www.menti.com/9fi8o1xcxa).

Ask about things you were unsure of, and point out anything you found interesting or unexpected.


### Exercise: :sunny:  DRYing the tests
:::info

Let's make these tests easier to manage!

In smaller groups, share a screen, discuss how to write the required test, and work collaboratively on the exercise.

rse-classwork repo: [:hash::two::one:](https://github.com/UCL-MPHY0021-21-22/RSE-Classwork/issues/21) 

:::spoiler call a helper to your room
If you need help, you can ask for us to drop in click "Ask for Help" :grey_question: button in the meeting controls.
If you don't find it, [watch this video showing where it is](https://www.youtube.com/watch?v=yIOMPRLQIHA).

:::
### Discussion of the exercise

On [Mentimeter](https://www.menti.com/9fi8o1xcxa).

Ask about things you were unsure of, and point out anything you found interesting or unexpected.

### Feedback

Please, fill the [mid-course feedback questionnaire](https://moodle.ucl.ac.uk/mod/questionnaire/view.php?id=2502087).

### Next... & Homework 
- Remaining exercises from week 5
- Preparation for week 6
- Next week we will send information about Submitty (10 attempts before 22nd 00:00)
- Remember to tell [us what's your github username](https://moodle.ucl.ac.uk/mod/questionnaire/view.php?id=2501711) and [your preferred office hours](https://moodle.ucl.ac.uk/mod/questionnaire/view.php?id=2379290)

# Questions

:::info
Feel free to add any question below. Remember the syntax:
```
- Example question
  - [name=student_a] Example answer
  - [name=TA_1] Example answer
```
:::

- .
  - [name=...]
- .
  - [name=...]
- .
  - [name=...]



###### tags: `mphy0021` `teaching` `class`

