/
test_init_package_flow.py
31 lines (24 loc) · 1.16 KB
/
test_init_package_flow.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
"""Tests for the InitPackageFlow task."""
import pytest
from selinon import FatalTaskError
from f8a_worker.workers import InitPackageFlow
from f8a_worker.workers.init_package_flow import validate_url
@pytest.mark.usefixtures("dispatcher_setup")
class TestInitPackageFlow(object):
"""Tests for the class InitPackageFlow."""
@pytest.mark.parametrize('args', [
{'ecosystem': 'maven', 'name': None, 'version': '0.1.25'},
{'ecosystem': ['maven'], 'name': 'gid:aid', 'version': '0.1.25'},
{'name': 'gid:aid', 'version': '0.1.25'}
])
def test_basic_input_validation(self, args):
"""Check that the tasks performs basic input validations."""
task = InitPackageFlow.create_test_instance(task_name='package_init_task')
with pytest.raises(FatalTaskError):
task.execute(arguments=args)
def test_validate_url(self):
"""Test the function to validate the URL."""
assert validate_url('') == ''
assert validate_url('https://github.com') == 'https://github.com'
assert validate_url('https://github.com') != ''
assert validate_url('github.com: Jordantsui/lunzi-demo.git[D') == ''