GithubHelp home page GithubHelp logo

jeannefukumaru / unit-testing-workshop Goto Github PK

View Code? Open in Web Editor NEW

This project forked from davified/unit-testing-workshop

0.0 1.0 0.0 51 KB

Dockerfile 2.13% Shell 5.72% Jupyter Notebook 61.92% Python 30.23%

unit-testing-workshop's Introduction

Unit Testing Workshop

Setup

Build docker and start container

# 1. build docker image
docker build . -t unit-testing-workshop

# 2. start docker container
docker run -it -v $(pwd):/code -p 8888:8888 unit-testing-workshop

# 3. in a second terminal window, get id of running container
docker ps 

# 4. start a second bash shell in the running container
docker exec -it <container-id> bash

# 5. Open yet another terminal window and run: 
bin/configure_venv_locally.sh
# After the command completes, configure your IDE to tell it that the python interpreter is in .venv-local/
# More instructions here: https://github.com/davified/ci-workshop-app/blob/master/docs/FAQs.md#ide-configuration

# 6. Open unit-testing-workshop repo in your IDE

Commands to be run inside the docker container

# 1. add some color to your terminal
source bin/color_my_terminal.sh

# For exercise 1: run tests in watch mode
nosetests --with-watch

# For execise 2: in another docker terminal, start jupyter notebook
jupyter notebook --ip 0.0.0.0 --no-browser --allow-root

# To stop the notebook / nosetests: hit Ctrl + C
# To exit the docker container    : hit Ctrl + D

Exercises

Exercise 1: Calculator

Implement the following functions in src/calculator.py:

# subtract(a, b)
subtract(2, 1) -> 1

# multiply(a, b)
multiply(2, 3) -> 6

# divide(a, b)
divide(10, 5) -> 2

# bonus: handle rounding of floats to 2 precision points
divide(10, 3) -> 3.33

Exercise 2: Adding tests and refactoring a notebook

We will refactor this notebook by creating and extracting functions and adding tests.

unit-testing-workshop's People

Contributors

davified avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.