-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathtest_css_linter.py
46 lines (38 loc) · 1.29 KB
/
test_css_linter.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
import os
import pytest
from lms.lmsdb import models
from lms.lmstests.public.linters import tasks
INVALID_CODE = '''
main {
display: pita;
}
'''
INVALID_CODE_MESSAGES = 'CSS: “display”: “pita” is not a “display” value.'
VALID_CODE = '''
main {
display: flex;
}
'''
@pytest.mark.skipif(
condition=os.system('which vnu') != 0, # noqa: S605,S607
reason='should run with VNU linter in path. see VNULinter class for more information',
)
class TestCSSLinter:
def test_invalid_solution(self, solution: models.Solution):
solution_file = solution.solution_files.get()
solution_file.path = 'index.css'
solution_file.code = INVALID_CODE
solution_file.save()
tasks.run_linter_on_solution(solution.id)
comments = tuple(models.Comment.by_solution(solution))
assert comments
assert len(comments) == 1
assert comments[0].comment.text == INVALID_CODE_MESSAGES
def test_valid_solution(self, solution: models.Solution):
solution_file = solution.solution_files.get()
solution_file.path = 'index.css'
solution_file.code = VALID_CODE
solution_file.save()
tasks.run_linter_on_solution(solution.id)
comments = tuple(models.Comment.by_solution(solution))
assert not comments