-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_module4.py
80 lines (67 loc) · 5.08 KB
/
test_module4.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import pytest
import sys
from jobs import app
from .utils import *
@pytest.mark.test_template_macros_module4
def test_template_macros_module4():
assert template_exists('_macros'), 'The `_macros.html` template does not exist in the `templates` folder.'
@pytest.mark.test_show_job_macro_definition_module4
def test_show_job_macro_definition_module4():
assert template_exists('_macros'), 'The `_macros.html` template does not exist in the `templates` folder.'
assert 'show_job:job' in template_macros('_macros'), 'Have you created the `show_job` macro and added the correct parameter?'
@pytest.mark.test_show_job_macro_html_module4
def test_show_job_macro_html_module4():
assert template_exists('_macros'), 'The `_macros.html` template does not exist in the `templates` folder.'
html = template_macro_soup('_macros', 'show_job')
p = html.select('.card .card-header .card-header-title')
div = html.select('.card-content .content')
assert len(p) == 1 and len(div) == 1, 'Has the `HTML` from `templates.html` been copied to the `show_job` macro?'
@pytest.mark.test_show_job_macro_header_module4
def test_show_job_macro_header_module4():
assert template_exists('_macros'), 'The `_macros.html` template does not exist in the `templates` folder.'
assert 'job:job_id:job:id' in template_functions('_macros', 'url_for'), 'Looks like the job title link `href` is incorrect.'
assert 'job:title' in template_variables('_macros'), 'Looks like the job title link does not have content.'
@pytest.mark.test_show_job_macro_body_module4
def test_show_job_macro_body_module4():
assert template_exists('_macros'), 'The `_macros.html` template does not exist in the `templates` folder.'
assert 'employer:employer_id:job:employer_id' in template_functions('_macros', 'url_for'), 'Looks like the job title link `href` is incorrect.'
assert 'job:employer_name' in template_variables('_macros'), 'Are you showing the employer name?'
assert 'job:salary' in template_variables('_macros'), 'Are you showing the job salary?'
assert 'job:description' in template_variables('_macros'), 'Are you showing the job description?'
@pytest.mark.test_show_jobs_macro_definition_module4
def test_show_jobs_macro_definition_module4():
assert template_exists('_macros'), 'The `_macros.html` template does not exist in the `templates` folder.'
assert 'show_jobs:jobs' in template_macros('_macros'), 'Have you created the `show_jobs` macro and added the correct parameter?'
@pytest.mark.test_show_jobs_macro_for_loop_module4
def test_show_jobs_macro_for_loop_module4():
assert template_exists('_macros'), 'The `_macros.html` template does not exist in the `templates` folder.'
html = template_macro_soup('_macros', 'show_jobs')
div = html.select('div.columns.is-multiline')
assert len(div) == 1, 'Has a `<div>` with classes of `columns` and `is-multiline` been added to the `show_jobs` macro?'
assert 'job:jobs' in show_jobs_for(), 'Does the `show_jobs` macro contain a `for` loop?'
@pytest.mark.test_show_jobs_macro_for_loop_body_module4
def test_show_jobs_macro_for_loop_body_module4():
assert template_exists('_macros'), 'The `_macros.html` template does not exist in the `templates` folder.'
html = template_macro_soup('_macros', 'show_jobs')
div = html.select('div.column.is-half')
assert len(div) == 1, 'Has a `<div>` with classes of `column` and `is-half` been added to the `show_jobs` macro `for` loop body?'
assert 'show_job:job' in show_jobs_for(), 'Does the `show_jobs` macro call `show_job`?'
@pytest.mark.test_import_macros_module4
def test_import_macros_module4():
assert template_exists('_macros'), 'The `_macros.html` template does not exist in the `templates` folder.'
assert '_macros.html:show_job:show_jobs:True' == template_import('layout'), 'Have you imported `_macros.html` in `layouts.html`?'
@pytest.mark.test_index_template_module4
def test_index_template_module4():
assert template_exists('index'), 'The `index.html` template does not exist in the `templates` folder.'
el = template_data('index').select('.columns .column.is-one-fifth')
assert len(el) == 1, 'Has the `HTML` from `templates.html` been copied to the `index.html` template?'
@pytest.mark.test_display_all_jobs_module4
def test_display_all_jobs_module4():
assert template_exists('index'), 'The `index.html` template does not exist in the `templates` folder.'
assert 'show_jobs:jobs' in template_functions('index', 'show_jobs'), 'Have you call the `show_jobs` macro in the `index.html` file?'
@pytest.mark.test_app_jobs_route_jobs_module4
def test_app_jobs_route_jobs_module4():
assert 'jobs' in dir(app), 'Have you created the `jobs` function?'
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'
assert execute_sql in get_functions(app.jobs), '`execute_sql` has not been called or has the wrong parameters.'
assert 'render_template:index.html:jobs:jobs' in get_functions(app.jobs), 'Have you added `jobs` to the `render_template` call.'