8000 Revert some changes to the code that aren't reflected in the tests, n… · SWCodeG/testing-python-apps@5585a1c · GitHub
[go: up one dir, main page]

Skip to content

Commit 5585a1c

Browse files
committed
Revert some changes to the code that aren't reflected in the tests, namely including 'id' in the JSON.
1 parent d59690d commit 5585a1c

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ videos/
1212
new_videos/
1313
.vscode/
1414
venv/
15+
.venv/
1516
testing-python-apps.txt
1617
theme.key
1718
data.db

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ Flask
22
Flask-RESTful
33
Flask-JWT
44
Flask-SQLAlchemy
5-
uwsgi
65
psycopg2
76
behave==1.2.5
87
beautifulsoup4==4.5.3

section3/video_code/tests/system/app_test.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
except ImportError:
55
from mock import patch
66

7-
from section3.video_code import app
7+
import app
88
from blog import Blog
99
from post import Post
1010

@@ -36,23 +36,23 @@ def test_menu_calls_create_blog(self):
3636

3737
def test_menu_calls_print_blogs(self):
3838
with patch('builtins.input') as mocked_input:
39-
with patch('section3.video_code.app.print_blogs') as mocked_print_blogs:
39+
with patch('app.print_blogs') as mocked_print_blogs:
4040
mocked_input.side_effect = ('l', 'q')
4141
app.menu()
4242

4343
mocked_print_blogs.assert_called()
4444

4545
def test_menu_calls_ask_read_blogs(self):
4646
with patch('builtins.input') as mocked_input:
47-
with patch('section3.video_code.app.ask_read_blog') as mocked_ask_read_blog:
47+
with patch('app.ask_read_blog') as mocked_ask_read_blog:
4848
mocked_input.side_effect = ('r', 'Test', 'q')
4949
app.menu()
5050

5151
mocked_ask_read_blog.assert_called()
5252

5353
def test_menu_calls_ask_create_post(self):
5454
with patch('builtins.input') as mocked_input:
55-
with patch('section3.video_code.app.ask_create_post') as mocked_ask_create_post:
55+
with patch('app.ask_create_post') as mocked_ask_create_post:
5656
mocked_input.side_effect = ('p', 'Test', 'New Post', 'New Content', 'q')
5757
app.menu()
5858

@@ -75,7 +75,7 @@ def test_ask_create_blog(self):
7575

7676
def test_ask_read_blog(self):
7777
with patch('builtins.input', return_value='Test'):
78-
with patch('section3.video_code.app.print_posts') as mocked_print_posts:
78+
with patch('app.print_posts') as mocked_print_posts:
7979
app.ask_read_blog()
8080

8181
mocked_print_posts.assert_called_with(app.blogs['Test'])
@@ -84,7 +84,7 @@ def test_print_posts(self):
8484
blog = app.blogs['Test']
8585
blog.create_post('Post title', 'Post content')
8686

87-
with patch('section3.video_code.app.print_post') as mocked_print_post:
87+
8000 with patch('app.print_post') as mocked_print_post:
8888
app.print_posts(blog)
8989

9090
mocked_print_post.assert_called_with(blog.posts[0])

section8/video_code/models/item.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ class ItemModel(db.Model):
99
price = db.Column(db.Float(precision=2))
1010

1111
store_id = db.Column(db.Integer, db.ForeignKey('stores.id'))
12-
store = db.relationship('StoreModel')
12+
store = db.relationship('StoreModel', back_populates="items")
1313

1414
def __init__(self, name, price, store_id):
1515
self.name = name
1616
self.price = price
1717
self.store_id = store_id
1818

1919
def json(self):
20-
return {'id': self.id, 'name': self.name, 'price': self.price}
20+
return {'name': self.name, 'price': self.price}
2121

2222
@classmethod
2323
def find_by_name(cls, name):

section8/video_code/models/store.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ class StoreModel(db.Model):
77
id = db.Column(db.Integer, primary_key=True)
88
name = db.Column(db.String(80))
99

10-
items = db.relationship('ItemModel', lazy='dynamic')
10+
items = db.relationship('ItemModel', lazy='dynamic', back_populates="store")
1111

1212
def __init__(self, name):
1313
self.name = name
1414

1515
def json(self):
16-
return {'id': self.id, 'name': self.name, 'items': [item.json() for item in self.items.all()]}
16+
return {'name': self.name, 'items': [item.json() for item in self.items.all()]}
1717

1818
@classmethod
1919
def find_by_name(cls, name):

0 commit comments

Comments
 (0)
0