Skip to content

Commit f4186e0

Browse files
committed
Removed reference to nosetests
1 parent c042e8f commit f4186e0

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

README.md

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ As Software Engineers we need to have the discipline to ensure that our code wor
2020

2121
You can read more about my thoughts on TDD in the article: [A Case for Test Driven Development](https://johnrofrano.medium.com/a-case-for-test-driven-development-7d9a552e0a16)
2222

23-
This lab introduces **Test Driven Development** using `PyUnit` and `nose` (a.k.a. `nosetests`). It also demonstrates how to create a simple RESTful service using Python Flask and PostgreSQL. The resource model is persistences using SQLAlchemy to keep the application simple. It's purpose is to show the correct API calls and return codes that should be used for a REST API.
23+
This lab introduces **Test Driven Development** using `PyUnit` and `PyTest`. It also demonstrates how to create a simple RESTful service using Python Flask and PostgreSQL. The resource model is persistence using SQLAlchemy to keep the application simple. It's purpose is to show the correct API calls and return codes that should be used for a REST API.
2424

25-
**Note:** The base service code is contained in `routes.py` while the business logic for manipulating Pets is in the `models.py` file. This follows the popular Model View Controller (MVC) separation of duities by keeping the model separate from the controller. As such, we have two test suites: one for the model (`test_models.py`) and one for the service itself (`test_routes.py`)
25+
**Note:** The base service code is contained in `routes.py` while the business logic for manipulating Pets is in the `models.py` file. This follows the popular Model View Controller (MVC) separation of duties by keeping the model separate from the controller. As such, we have two test suites: one for the model (`test_models.py`) and one for the service itself (`test_routes.py`)
2626

2727
## Prerequisite Software Installation
2828

@@ -45,8 +45,8 @@ You can read more about creating these environments in my article: [Creating Rep
4545
To bring up the development environment you should clone this repo, change into the repo directory:
4646

4747
```bash
48-
$ git clone https://github.com/nyu-devops/lab-flask-tdd.git
49-
$ cd lab-flask-tdd
48+
git clone https://github.com/nyu-devops/lab-flask-tdd.git
49+
cd lab-flask-tdd
5050
```
5151

5252
Depending on which development environment you created, pick from the following:
@@ -56,7 +56,7 @@ Depending on which development environment you created, pick from the following:
5656
Open Visual Studio Code using the `code .` command. VS Code will prompt you to reopen in a container and you should say **yes**. This will take a while as it builds the Docker image and creates a container from it to develop in.
5757

5858
```bash
59-
$ code .
59+
code .
6060
```
6161

6262
Note that there is a period `.` after the `code` command. This tells Visual Studio Code to open the editor and load the current folder of files.
@@ -68,9 +68,9 @@ Once the environment is loaded you should be placed at a `bash` prompt in the `/
6868
Bring up the virtual machine using Vagrant.
6969

7070
```shell
71-
$ vagrant up
72-
$ vagrant ssh
73-
$ cd /vagrant
71+
vagrant up
72+
vagrant ssh
73+
cd /vagrant
7474
```
7575

7676
This will place you in the virtual machine in the `/vagrant` folder which has been shared with your computer so that your source files can be edited outside of the VM and run inside of the VM.
@@ -79,35 +79,35 @@ This will place you in the virtual machine in the `/vagrant` folder which has be
7979

8080
As developers we always want to run the tests before we change any code. That way we know if we broke the code or if someone before us did. Always run the test cases first!
8181

82-
Run the tests using `nosetests`
82+
Run the unit tests using `pytest`
8383

8484
```shell
85-
$ nosetests
85+
make test
8686
```
8787

88-
Nose is configured via the included `setup.cfg` file to automatically include the flags `--with-spec --spec-color` so that red-green-refactor is meaningful. If you are in a command shell that supports colors, passing tests will be green while failing tests will be red.
88+
PyTest is configured via the included `setup.cfg` file to automatically include the `--pspec` flag so that red-green-refactor is meaningful. If you are in a command shell that supports colors, passing tests will be green while failing tests will be red.
8989

90-
Nose is also configured to automatically run the `coverage` tool and you should see a percentage-of-coverage report at the end of your tests. If you want to see what lines of code were not tested use:
90+
PyTest is also configured to automatically run the `coverage` tool and you should see a percentage-of-coverage report at the end of your tests. If you want to see what lines of code were not tested use:
9191

9292
```shell
93-
$ coverage report -m
93+
coverage report -m
9494
```
9595

9696
This is particularly useful because it reports the line numbers for the code that have not been covered so you know which lines you want to target with new test cases to get higher code coverage.
9797

98-
You can also manually run `nosetests` with `coverage` (but `setup.cfg` does this already)
98+
You can also manually run `pytest` with `coverage` (but `setup.cfg` does this already)
9999

100100
```shell
101-
$ nosetests --with-coverage --cover-package=service
101+
$ pytest --pspec --cov=service --cov-fail-under=95
102102
```
103103

104104
Try and get as close to 100% coverage as you can.
105105

106-
It's also a good idea to make sure that your Python code follows the PEP8 standard. Both `flake8` and `pylint` have been included in the `requirements.txt` file so that you can check if your code is compliant like this:
106+
It's also a good idea to make sure that your Python code follows the PEP8 standard. Both `flake8` and `pylint` have been included in the `pyproject.toml` file so that you can check if your code is compliant like this:
107107

108108
```shell
109-
$ flake8 . --count --max-complexity=10 --max-line-length=127 --statistics
110-
$ pylint service tests --max-line-length=127
109+
flake8 . --count --max-complexity=10 --max-line-length=127 --statistics
110+
pylint service tests --max-line-length=127
111111
```
112112

113113
Visual Studio Code is configured to use `pylint` while you are editing. This catches a lot of errors while you code that would normally be caught at runtime. It's a good idea to always code with pylint active.
@@ -117,7 +117,7 @@ Visual Studio Code is configured to use `pylint` while you are editing. This cat
117117
The project uses *honcho* which gets it's commands from the `Procfile`. To start the service simply use:
118118

119119
```shell
120-
$ honcho start
120+
honcho start
121121
```
122122

123123
You should be able to reach the service at: http://localhost:8000. The port that is used is controlled by an environment variable defined in the `.flaskenv` file which Flask uses to load it's configuration from the environment by default.
@@ -129,27 +129,27 @@ If you are using Visual Studio Code with Docker, simply existing Visual Studio C
129129
If you are using Vagrant and VirtualBox, when you are done, you can exit and shut down the vm with:
130130

131131
```shell
132-
$ exit
133-
$ vagrant halt
132+
exit
133+
vagrant halt
134134
```
135135

136136
If the VM is no longer needed you can remove it with:
137137

138138
```shell
139-
$ vagrant destroy
139+
vagrant destroy
140140
```
141141

142142
## What's featured in the project?
143143

144-
* app/routes.py -- the main Service routes using Python Flask
145-
* app/models.py -- the data model using SQLAlchemy
146-
* tests/test_routes.py -- test cases against the Pet service
147-
* tests/test_models.py -- test cases against the Pet model
144+
- app/routes.py -- the main Service routes using Python Flask
145+
- app/models.py -- the data model using SQLAlchemy
146+
- tests/test_routes.py -- test cases against the Pet service
147+
- tests/test_models.py -- test cases against the Pet model
148148

149149
## License
150150

151-
Copyright (c) John Rofrano. All rights reserved.
151+
Copyright (c) 2016, 2024 [John Rofrano](https://www.linkedin.com/in/JohnRofrano/). All rights reserved.
152152

153153
Licensed under the Apache License. See [LICENSE](LICENSE)
154154

155-
This repo is part of the NYU masters class: **CSCI-GA.2820-001 DevOps and Agile Methodologies** conceived, created and taught by *John Rofrano*
155+
This repository is part of the New York University (NYU) masters class: **CSCI-GA.2820-001 DevOps and Agile Methodologies** created and taught by [John Rofrano](https://cs.nyu.edu/~rofrano/), Adjunct Instructor, NYU Courant Institute, Graduate Division, Computer Science, and NYU Stern School of Business.

0 commit comments

Comments
 (0)