This repository has been archived by the owner on Jan 5, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.py
86 lines (54 loc) · 2.39 KB
/
tests.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
81
82
83
84
85
86
# -*- coding: utf8 -*-
import mock
import pytest
from frigg_test_discovery import detect_test_tasks, detect_tox_environments
@pytest.fixture
def files():
return ['_config.yml', 'Cargo.toml', 'build.sbt', 'package.json', 'gulpfile.js', 'Gruntfile.js',
'manage.py', 'setup.py', 'pom.xml', 'Rakefile', 'tox.ini', 'Makefile']
def test_detect_nothing(files):
assert detect_test_tasks([]) == []
assert detect_test_tasks(['random-file']) == []
def test_detect_make(files):
assert detect_test_tasks(files) == ['make test']
def test_detect_tox(files):
files = files[:files.index('tox.ini') + 1]
assert detect_test_tasks(files) == ['tox']
def test_detect_rake(files):
files = files[:files.index('Rakefile') + 1]
assert detect_test_tasks(files) == ['rake test']
def test_detect_maven(files):
files = files[:files.index('pom.xml') + 1]
assert detect_test_tasks(files) == ['mvn -B test']
def test_detect_python(files):
files = files[:files.index('setup.py') + 1]
assert detect_test_tasks(files) == ['python setup.py test']
def test_detect_django(files):
files = files[:files.index('manage.py') + 1]
assert detect_test_tasks(files) == ['python manage.py test']
def test_detect_grunt(files):
files = files[:files.index('Gruntfile.js') + 1]
assert detect_test_tasks(files) == ['grunt test']
def test_detect_gulp(files):
files = files[:files.index('gulpfile.js') + 1]
assert detect_test_tasks(files) == ['gulp test']
def test_detect_npm(files):
files = files[:files.index('package.json') + 1]
assert detect_test_tasks(files) == ['npm install', 'npm test']
def test_detect_sbt(files):
files = files[:files.index('build.sbt') + 1]
assert detect_test_tasks(files) == ['sbt test']
def test_detect_cargo(files):
files = files[:files.index('Cargo.toml') + 1]
assert detect_test_tasks(files) == ['cargo test']
def test_detect_jekyll(files):
files = files[:files.index('_config.yml') + 1]
assert detect_test_tasks(files) == ['jekyll build']
def test_detect_tox_environments():
runner = mock.MagicMock()
output = mock.MagicMock()
output.configure_mock(out='flake8\n')
runner.configure_mock(run=lambda *a: output)
assert detect_tox_environments(runner, '') == ['flake8']
output.configure_mock(out='flake8\nisort\ntests\n')
assert detect_tox_environments(runner, '') == ['flake8', 'isort', 'tests']