Skip to content

Commit 2f4c5e5

Browse files
authored
Merge pull request #53 from RobertGrancsaSoftwire/main
Changed the language to Python
2 parents b68082c + b279cb1 commit 2f4c5e5

18 files changed

+132
-9170
lines changed

.editorconfig

Lines changed: 0 additions & 12 deletions
This file was deleted.

.gitignore

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
.DS_Store
2-
.idea
3-
node_modules
4-
typings
5-
app/**/*.js
6-
app/**/*.js.map
7-
test/**/*.js
8-
test/**/*.js.map
9-
coverage
10-
.nyc_output
11-
jest/__snapshots__
1+
*.pyc
2+
.cache
3+
.coverage
4+
.idea/
5+
*.iml
6+
.pytest_cache
7+
.approval_tests_temp

.nycrc.js

Lines changed: 0 additions & 17 deletions
This file was deleted.

.vscode/settings.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"python.testing.pytestArgs": [
3+
"tests"
4+
],
5+
"python.testing.unittestEnabled": false,
6+
"python.testing.pytestEnabled": true
7+
}

LICENSE

Lines changed: 0 additions & 121 deletions
This file was deleted.

README.md

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,62 +7,59 @@ The workshop is based on a popular refactoring exercise you can find out more ab
77

88
## Setup
99

10-
We recommend using [Intellij](https://www.jetbrains.com/idea/download/) as the IDE.
10+
We recommend using [Intellij](https://www.jetbrains.com/idea/download/) as the IDE, but vscode is also great for this.
1111

12-
You might also have to install [nvm-windows](https://github.com/coreybutler/nvm-windows) if you are running on Windows.
13-
14-
You will have to install [Node](https://nodejs.org/en/download/package-manager) v18.20.
15-
This should also install `npm`, the Node packet manager.
12+
You might also have to install [python](https://www.python.org/downloads/windows/) if you are running on Windows.
1613

1714
You don't need to run this in a virtual machine.
1815

19-
You might also have to install [ts-node](https://www.npmjs.com/package/ts-node#installation), after you get Node.
16+
To install the dependencies, run:
2017

2118
```console
2219
# Locally in your project.
23-
npm install -D typescript
24-
25-
npm install -D ts-node
20+
pip3 install -r requirements.txt
2621
```
2722

23+
Suggestion: create a python virtual environment for this project. See the [documentation](https://docs.python.org/3/library/venv.html)
24+
2825
## Getting started
2926

3027
**First, fork this repository and clone it on your device.**
3128

3229
Then, install dependencies:
3330

3431
```console
35-
npm install
32+
pip3 install -r requirements.txt
3633
```
3734

38-
## Run the Unit Tests from the Command-Line
35+
## Run the unit tests from the Command-Line
3936

40-
We are using [Jest](https://jestjs.io/) as the testing framework.
37+
We are using [Pytest](https://docs.pytest.org/en/stable/) as the testing framework
4138

42-
To run tests:
43-
44-
```console
45-
npm run test:jest
39+
```
40+
pytest
4641
```
4742

48-
To run all tests in watch mode:
43+
To run test with coverage
4944

50-
```console
51-
npm run test:jest:watch
5245
```
46+
pytest --cov=gilded_rose
47+
```
48+
49+
You can also use the python test windows from vscode (you must have the [python](https://marketplace.visualstudio.com/items?itemName=ms-python.python) extension installed)
5350

5451
## Running the App
5552

56-
You can run the application seeing how the `updateQuality()` function works:
53+
You can run the application seeing how the `update_quality()` function works:
5754

5855
```console
59-
npx ts-node test/golden-master-text-test.ts
56+
python3 texttest_fixture.py
6057
```
6158

6259
Or with the number of days as args:
6360

6461
```console
65-
npx ts-node test/golden-master-text-test.ts 10
62+
python3 texttest_fixture.py 10
6663
```
6764

6865
## Gilded Rose Requirements Specification

app/gilded-rose.ts

Lines changed: 0 additions & 69 deletions
This file was deleted.

gilded_rose.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# -*- coding: utf-8 -*-
2+
3+
class GildedRose(object):
4+
5+
def __init__(self, items):
6+
self.items = items
7+
8+
def update_quality(self):
9+
for item in self.items:
10+
if item.name != "Aged Brie" and item.name != "Backstage passes to a TAFKAL80ETC concert":
11+
if item.quality > 0:
12+
if item.name != "Sulfuras, Hand of Ragnaros":
13+
item.quality = item.quality - 1
14+
else:
15+
if item.quality < 50:
16+
item.quality = item.quality + 1
17+
if item.name == "Backstage passes to a TAFKAL80ETC concert":
18+
if item.sell_in < 11:
19+
if item.quality < 50:
20+
item.quality = item.quality + 1
21+
if item.sell_in < 6:
22+
if item.quality < 50:
23+
item.quality = item.quality + 1
24+
if item.name != "Sulfuras, Hand of Ragnaros":
25+
item.sell_in = item.sell_in - 1
26+
if item.sell_in < 0:
27+
if item.name != "Aged Brie":
28+
if item.name != "Backstage passes to a TAFKAL80ETC concert":
29+
if item.quality > 0:
30+
if item.name != "Sulfuras, Hand of Ragnaros":
31+
item.quality = item.quality - 1
32+
else:
33+
item.quality = item.quality - item.quality
34+
else:
35+
if item.quality < 50:
36+
item.quality = item.quality + 1
37+
38+
39+
class Item:
40+
def __init__(self, name, sell_in, quality):
41+
self.name = name
42+
self.sell_in = sell_in
43+
self.quality = quality
44+
45+
def __repr__(self):
46+
return "%s, %s, %s" % (self.name, self.sell_in, self.quality)

0 commit comments

Comments
 (0)