Skip to content

Commit df6afc3

Browse files
committed
test: tag name changes
1 parent ace2403 commit df6afc3

File tree

8 files changed

+65
-63
lines changed

8 files changed

+65
-63
lines changed

tasks.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ At this point you have a styled application. Check out the styles:
140140

141141
## 3.3 - Database Path
142142

143-
@pytest.mark.app_db_path below all of the import statements, create a constant called `PATH`, that contains the path to the already created database stored in `db/jobs.sqlite`.
143+
@pytest.mark.app_db_path Below all of the import statements, create a constant called `PATH`, that contains the path to the already created database stored in `db/jobs.sqlite`.
144144

145145
## 3.4 - Global Database Attribute
146146

@@ -177,9 +177,11 @@ In the body of `execute_sql` create a variable called `db`. Assign this variable
177177
- Set the default of `single` to `False`.
178178

179179
## 3.9 - Query Database Function Execute
180+
180181
@pytest.mark.app_execute_sql_execute In the body of `execute_sql` call the `execute` function on `connection`, pass in the `sql` and `values` variables. Assign the return value to a variable called `cursor`.
181182

182183
## 3.10 - Query Database Function Commit
184+
183185
@pytest.mark.app_execute_sql_commit In the body of `execute_sql`:
184186

185187
- Create an `if` statement to test if `commit` is `True`.
@@ -252,7 +254,7 @@ In `<p>` tag add the following:
252254
## 4.8 - Show Jobs Macro For Loop Body
253255

254256
@pytest.mark.show_jobs_macro_for_loop_body In the body of the `for` loop add a `<div>` with two classes `column` and `is_half`.
255-
257+
256258
- In this `column` `<div>` add a call to the `show_job` macro passing in an individual `job` from the `for` loop.
257259

258260
## 4.9 - Import Macros
@@ -261,7 +263,7 @@ In `<p>` tag add the following:
261263

262264
```
263265
{% from '_macros.html' import show_job, show_jobs with context %}
264-
```
266+
```
265267

266268
**Notes: Because each template extends `layouts.html` all of them will have access to these two new macros.**
267269

@@ -284,7 +286,7 @@ Above the `render_template` function, call the `execute_sql` function:
284286
- In the `render_template` function, pass a keyword argument of `jobs=jobs`.
285287

286288
**Preview**
287-
289+
288290
At this point you can see all jobs on the homepage:
289291

290292
- Open a terminal at the root of the project
@@ -302,7 +304,7 @@ At this point you can see all jobs on the homepage:
302304
In the file use an `extends` template tag to inherit `layout.html`.
303305

304306
After the `extends` tag add a template `block` called `content`. In the block call the `show_job` macro passing in `job`. **Note: Use the `{{}}` for the macro call.**
305-
307+
306308
## 5.2 - Job Route Function
307309

308310
@pytest.mark.app_job_route In `app.py` create a function called `job`. In the body return a call to the `render_template` function passing in the newly created `job.html` template.
@@ -315,7 +317,7 @@ Still in `app.py`, add a route decorator with the URL path `/job/<job_id>` to th
315317

316318
## 5.4 - Job Route Parameter
317319

318-
@pytest.mark.app_job_route_parameter. To use the `job_id`, received from the URL, we need to pass it to the `job` function. Add `job_id` to the parameter list of the `job` function.
320+
@pytest.mark.app_job_route_parameter To use the `job_id`, received from the URL, we need to pass it to the `job` function. Add `job_id` to the parameter list of the `job` function.
319321

320322
## 5.5 - Job Route Data
321323

tests/test_module1.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,36 @@
44
from .utils import *
55
from jobs import app
66

7-
@pytest.mark.app_import_flask
7+
@pytest.mark.test_app_import_flask_module1
88
def test_app_import_flask_module1():
99
assert 'Flask' in dir(app), 'Have you imported the `Flask` class from `flask`?'
1010
assert inspect.isclass(app.Flask), '`Flask` is not a class.'
1111
assert 'render_template' in dir(app), '`render_template` has not been imported.'
1212
assert inspect.isfunction(app.render_template), '`render_template` is not a function.'
1313

14-
@pytest.mark.app_create_flask_app
14+
@pytest.mark.test_app_create_flask_app_module1
1515
def test_app_create_flask_app_module1():
1616
assert 'app' in dir(app), 'Have you created an instance of the `Flask` class called `app`?'
1717
assert isinstance(app.app, app.Flask), '`app` is not an instance of the `Flask` class.'
1818

19-
@pytest.mark.templates_folder
19+
@pytest.mark.test_templates_folder_module1
2020
def test_templates_folder_module1():
2121
assert os.path.isdir('jobs/templates'), 'The `templates` folder has not been created.'
2222

23-
@pytest.mark.index_template
23+
@pytest.mark.test_index_template_module1
2424
def test_index_template_module1():
2525
assert template_exists('index'), 'The `index.html` template does not exist in the `templates` folder.'
2626
assert template_find('index', 'h1', limit=1), "The `<h1>` in the `index.html` template does not contain the contents 'Jobs'."
2727
assert template_find('index', 'h1', limit=1)[0].text == 'Jobs', "The `<h1>` in the `index.html` template does not contain the contents 'Jobs'."
2828

29-
@pytest.mark.app_index_route_function
29+
@pytest.mark.test_app_index_route_function_module1
3030
def test_app_index_route_function_module1():
3131
assert 'app' in dir(app), 'Have you created an instance of the `Flask` class called `app`?'
3232
assert 'jobs' in dir(app), 'Have you created the `jobs` function?'
3333
result = [item for item in get_functions(app.jobs) if item.startswith('render_template:index.html')]
3434
assert len(result) == 1, 'Have you called the `render_template` function.'
3535

36-
@pytest.mark.app_route_decoractors
36+
@pytest.mark.test_app_route_decoractors_module1
3737
def test_app_route_decoractors_module1():
3838
assert 'app' in dir(app), 'Have you created an instance of the `Flask` class called `app`?'
3939
assert template_exists('index'), 'The `index.html` template does not exist in the `templates` folder.'

tests/test_module2.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@
55

66
calls = template_functions('layout', 'url_for')
77

8-
@pytest.mark.layout_template
8+
@pytest.mark.test_layout_template_module2
99
def test_layout_template_module2():
1010
assert template_exists('layout'), 'The `layout.html` template does not exist in the `templates` folder.'
1111

12-
@pytest.mark.add_bulma_css_framework
12+
@pytest.mark.test_add_bulma_css_framework_module2
1313
def test_add_bulma_css_framework_module2():
1414
assert template_exists('layout'), 'The `layout.html` template does not exist in the `templates` folder.'
1515
assert 'static:filename:css/bulma.min.css' in calls, 'Looks like `bulma.min.css` is not linked in `layout.html`.'
1616

17-
@pytest.mark.add_custom_css
17+
@pytest.mark.test_add_custom_css_module2
1818
def test_add_custom_css_module2():
1919
assert template_exists('layout'), 'The `layout.html` template does not exist in the `templates` folder.'
2020
assert 'static:filename:css/app.css' in calls, 'Looks like `app.css` is not linked in `layout.html`.'
2121

22-
@pytest.mark.add_fontawesome
22+
@pytest.mark.test_add_fontawesome_module2
2323
def test_add_fontawesome_module2():
2424
assert template_exists('layout'), 'The `layout.html` template does not exist in the `templates` folder.'
2525
attr = {
@@ -28,7 +28,7 @@ def test_add_fontawesome_module2():
2828
}
2929
assert template_soup('layout').find('link', attr), 'Looks like FontAwesome is not linked in `layout.html`.'
3030

31-
@pytest.mark.extend_base_template
31+
@pytest.mark.test_extend_base_template_module2
3232
def test_extend_base_template_module2():
3333
assert template_exists('index'), 'The `index.html` template does not exist in the `templates` folder.'
3434
assert template_exists('layout'), 'The `layout.html` template does not exist in the `templates` folder.'

tests/test_module3.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,25 @@
44
from jobs import app
55
from .utils import *
66

7-
@pytest.mark.app_import_sqlite
7+
@pytest.mark.test_app_import_sqlite_module3
88
def test_app_import_sqlite_module3():
99
assert 'sqlite3' in dir(app), 'Have you imported `sqlite`?'
1010

11-
@pytest.mark.app_import_g
11+
@pytest.mark.test_app_import_g_module3
1212
def test_app_import_g_module3():
1313
assert 'g' in dir(app), 'Have you imported the `g` class from `flask`?'
1414

15-
@pytest.mark.app_db_path
15+
@pytest.mark.test_app_db_path_module3
1616
def test_app_db_path_module3():
1717
assert 'PATH' in dir(app), 'Have you created a constant called `PATH`.'
1818
assert app.PATH == 'db/jobs.sqlite', 'Have you created a constant called `PATH`?'
1919

20-
@pytest.mark.app_open_connection_get_attribute
20+
@pytest.mark.test_app_open_connection_get_attribute_module3
2121
def test_app_open_connection_get_attribute_module3():
2222
assert 'open_connection' in dir(app), 'Have you defined a function named `open_connection`.'
2323
assert 'getattr:g:_connection:None' in get_functions(app.open_connection), 'Have you used the `getattr` function to get the global `_connection`?'
2424

25-
@pytest.mark.app_open_connection_connection
25+
@pytest.mark.test_app_open_connection_connection_module3
2626
def test_app_open_connection_connection_module3():
2727
assert 'g' in dir(app), 'Have you imported the `g` class from `flask`?'
2828
assert 'app' in dir(app), 'Have you created an instance of the `Flask` class called `app`?'
@@ -33,7 +33,7 @@ def test_app_open_connection_connection_module3():
3333
_, _, db_name = app.g._connection.execute('PRAGMA database_list').fetchone()
3434
assert os.path.join(os.getcwd(), 'db', 'jobs.sqlite') == db_name, 'Did you pass the `connect` function the `PATH` constant?'
3535

36-
@pytest.mark.app_open_connection_row_factory
36+
@pytest.mark.test_app_open_connection_row_factory_module3
3737
def test_app_open_connection_row_factory_module3():
3838
assert 'g' in dir(app), 'Have you imported the `g` class from `flask`?'
3939
assert 'app' in dir(app), 'Have you created an instance of the `Flask` class called `app`?'
@@ -43,26 +43,26 @@ def test_app_open_connection_row_factory_module3():
4343
assert isinstance(db, app.sqlite3.Connection), 'Are you returning the database connection?'
4444
assert id(db.row_factory) == id(app.sqlite3.Row), 'Have you set the database `row_factory` to the sqlite3.Row class?'
4545

46-
@pytest.mark.app_execute_sql
46+
@pytest.mark.test_app_execute_sql_module3
4747
def test_app_execute_sql_module3():
4848
assert 'app' in dir(app), 'Have you created an instance of the `Flask` class called `app`?'
4949
assert 'execute_sql' in dir(app), 'Have you defined a function named `execute_sql`.'
5050
assert 'open_connection' in get_functions(app.execute_sql), 'Have you called the `open_connection` function in `execute_sql`?'
5151

52-
@pytest.mark.app_execute_sql_parameters
52+
@pytest.mark.test_app_execute_sql_parameters_module3
5353
def test_app_execute_sql_parameters_module3():
5454
assert 'execute_sql' in dir(app), 'Have you defined a function named `execute_sql`.'
5555
parameters = inspect.getfullargspec(app.execute_sql)
5656
assert parameters.args[0] == 'sql' and parameters.args[1] == 'values' and parameters.args[2] == 'commit' and parameters.args[3] == 'single', 'Have you added the correct parameters to the `execute_sql` function parameters list?'
5757
assert parameters.defaults[0] == () and parameters.defaults[1] == False and parameters.defaults[2] == False, 'Do the `args` and `one` parameters have the correct defaults in the `execute_sql` function parameters list?'
5858

59-
@pytest.mark.app_execute_sql_execute
59+
@pytest.mark.test_app_execute_sql_execute_module3
6060
def test_app_execute_sql_execute_module3():
6161
assert 'execute_sql' in dir(app), 'Have you defined a function named `execute_sql`.'
6262
assert 'execute:sql:values' in get_functions(app.execute_sql), 'Have you called the `execute` function in `execute_sql`?'
6363

64-
@pytest.mark.app_execute_sql_fetchall
65-
def test_app_execute_sql_fetchall_module3():
64+
@pytest.mark.test_app_execute_sql_results_module3
65+
def test_app_execute_sql_results_module3():
6666
assert 'execute_sql' in dir(app), 'Have you defined a function named `execute_sql`.'
6767
assert 'fetchall' in get_functions(app.execute_sql), 'Have you called the `fetchall` function in `execute_sql`?'
6868
assert 'fetchone' in get_functions(app.execute_sql), 'Have you called the `fetchone` function in `execute_sql`?'
@@ -72,13 +72,13 @@ def test_app_execute_sql_fetchall_module3():
7272
results = app.execute_sql('SELECT * FROM job', single=True)
7373
assert type(results) != list, 'Have you create an if statement to only return one result in `one` is true?'
7474

75-
@pytest.mark.app_close_connection
75+
@pytest.mark.test_app_close_connection_module3
7676
def test_app_close_connection_module3():
7777
assert 'close_connection' in dir(app), 'Have you defined a function named `close_connection`.'
7878
assert 'getattr:g:_connection:None' in get_functions(app.open_connection), 'Have you used the `getattr` function to get the global `_connection`?'
7979
assert 'close' in get_functions(app.execute_sql), 'Have you called the `close` function in `execute_sql`?'
8080

81-
@pytest.mark.app_close_connection_decorator
81+
@pytest.mark.test_app_close_connection_decorator_module3
8282
def test_app_close_connection_decorator_module3():
8383
assert 'close_connection' in dir(app), 'Have you defined a function named `close_connection`.'
8484
decorator = get_decorators(app.close_connection)['close_connection'][0][0]

tests/test_module4.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,75 +4,75 @@
44
from jobs import app
55
from .utils import *
66

7-
@pytest.mark.template_macros
7+
@pytest.mark.test_template_macros_module4
88
def test_template_macros_module4():
99
assert template_exists('_macros'), 'The `_macros.html` template does not exist in the `templates` folder.'
1010

11-
@pytest.mark.show_job_macro_definition
11+
@pytest.mark.test_show_job_macro_definition_module4
1212
def test_show_job_macro_definition_module4():
1313
assert template_exists('_macros'), 'The `_macros.html` template does not exist in the `templates` folder.'
1414
assert 'show_job:job' in template_macros('_macros'), 'Have you created the `show_job` macro and added the correct parameter?'
1515

16-
@pytest.mark.show_job_macro_html
16+
@pytest.mark.test_show_job_macro_html_module4
1717
def test_show_job_macro_html_module4():
1818
assert template_exists('_macros'), 'The `_macros.html` template does not exist in the `templates` folder.'
1919
html = template_macro_soup('_macros', 'show_job')
2020
p = html.select('.card .card-header .card-header-title')
2121
div = html.select('.card-content .content')
2222
assert len(p) == 1 and len(div) == 1, 'Has the `HTML` from `templates.html` been copied to the `show_job` macro?'
2323

24-
@pytest.mark.show_job_macro_header
24+
@pytest.mark.test_show_job_macro_header_module4
2525
def test_show_job_macro_header_module4():
2626
assert template_exists('_macros'), 'The `_macros.html` template does not exist in the `templates` folder.'
2727
assert 'job:job_id:job:id' in template_functions('_macros', 'url_for'), 'Looks like the job title link `href` is incorrect.'
2828
assert 'job:title' in template_variables('_macros'), 'Looks like the job title link does not have content.'
2929

30-
@pytest.mark.show_job_macro_body
30+
@pytest.mark.test_show_job_macro_body_module4
3131
def test_show_job_macro_body_module4():
3232
assert template_exists('_macros'), 'The `_macros.html` template does not exist in the `templates` folder.'
3333
assert 'employer:employer_id:job:employer_id' in template_functions('_macros', 'url_for'), 'Looks like the job title link `href` is incorrect.'
3434
assert 'job:employer_name' in template_variables('_macros'), 'Are you showing the employer name?'
3535
assert 'job:salary' in template_variables('_macros'), 'Are you showing the job salary?'
3636
assert 'job:description' in template_variables('_macros'), 'Are you showing the job description?'
3737

38-
@pytest.mark.show_jobs_macro_definition
38+
@pytest.mark.test_show_jobs_macro_definition_module4
3939
def test_show_jobs_macro_definition_module4():
4040
assert template_exists('_macros'), 'The `_macros.html` template does not exist in the `templates` folder.'
4141
assert 'show_jobs:jobs' in template_macros('_macros'), 'Have you created the `show_jobs` macro and added the correct parameter?'
4242

43-
@pytest.mark.show_jobs_macro_for_loop
43+
@pytest.mark.test_show_jobs_macro_for_loop_module4
4444
def test_show_jobs_macro_for_loop_module4():
4545
assert template_exists('_macros'), 'The `_macros.html` template does not exist in the `templates` folder.'
4646
html = template_macro_soup('_macros', 'show_jobs')
4747
div = html.select('div.columns.is-multiline')
4848
assert len(div) == 1, 'Has a `<div>` with classes of `columns` and `is-multiline` been added to the `show_jobs` macro?'
4949
assert 'job:jobs' in show_jobs_for(), 'Does the `show_jobs` macro contain a `for` loop?'
5050

51-
@pytest.mark.show_jobs_macro_for_loop_body
51+
@pytest.mark.test_show_jobs_macro_for_loop_body_module4
5252
def test_show_jobs_macro_for_loop_body_module4():
5353
assert template_exists('_macros'), 'The `_macros.html` template does not exist in the `templates` folder.'
5454
html = template_macro_soup('_macros', 'show_jobs')
5555
div = html.select('div.column.is-half')
5656
assert len(div) == 1, 'Has a `<div>` with classes of `column` and `is-half` been added to the `show_jobs` macro `for` loop body?'
5757
assert 'show_job:job' in show_jobs_for(), 'Does the `show_jobs` macro call `show_job`?'
5858

59-
@pytest.mark.import_macros
59+
@pytest.mark.test_import_macros_module4
6060
def test_import_macros_module4():
6161
assert template_exists('_macros'), 'The `_macros.html` template does not exist in the `templates` folder.'
6262
assert '_macros.html:show_job:show_jobs:True' == template_import('layout'), 'Have you imported `_macros.html` in `layouts.html`?'
6363

64-
@pytest.mark.index_template
64+
@pytest.mark.test_index_template_module4
6565
def test_index_template_module4():
6666
assert template_exists('index'), 'The `index.html` template does not exist in the `templates` folder.'
6767
el = template_data('index').select('.columns .column.is-one-fifth')
6868
assert len(el) == 1, 'Has the `HTML` from `templates.html` been copied to the `index.html` template?'
6969

70-
@pytest.mark.display_all_jobs
70+
@pytest.mark.test_display_all_jobs_module4
7171
def test_display_all_jobs_module4():
7272
assert template_exists('index'), 'The `index.html` template does not exist in the `templates` folder.'
7373
assert 'show_jobs:jobs' in template_functions('index', 'show_jobs'), 'Have you call the `show_jobs` macro in the `index.html` file?'
7474

75-
@pytest.mark.app_jobs_route_jobs
75+
@pytest.mark.test_app_jobs_route_jobs_module4
7676
def test_app_jobs_route_jobs_module4():
7777
assert 'jobs' in dir(app), 'Have you created the `jobs` function?'
7878
execute_sql = 'execute_sql:SELECT job.id, job.title, job.description, job.salary, employer.id as employer_id, employer.name as employer_name FROM job JOIN employer ON employer.id = job.employer_id'

0 commit comments

Comments
 (0)