def test_project_has_tests(data):
    project_name = project.create_random_project()
    response = project.get_project_has_tests(project_name)
    assert response.json() is False
    project.create_random_test(project_name)
    response = project.get_project_has_tests(project_name)
    assert response.json() is True
def setup(data):
    project.using_project('general')
    data.suite = project.create_random_suite(data.project)
    data.test = project.create_random_test(data.project)
    suite.save_suite(data.project, data.suite, tests=[data.test])
    response = suite.run_suite(data.project, data.suite)
    actions.store('timestamp', response.json())
def test_project_health(data):
    # project without executions
    response = project.get_project_health(data.project)
    assert response.status_code == 200
    assert response.json() == {}

    # project with one execution without tests
    suite_name = project.create_random_suite(data.project)
    response = suite.run_suite(data.project, suite_name)
    timestamp = response.json()
    report.wait_for_execution_to_finish(data.project, suite_name, timestamp)

    response = project.get_project_health(data.project)

    assert response.json()[suite_name]['total'] == 0
    assert response.json()[suite_name]['execution'] == timestamp
    assert response.json()[suite_name]['totals_by_result'] == {}

    # project with two executions, last one has one test
    # project-health should return the last one
    test_name = project.create_random_test(data.project)
    suite.save_suite(data.project, suite_name, tests=[test_name])
    response = suite.run_suite(data.project, suite_name)
    timestamp = response.json()
    report.wait_for_execution_to_finish(data.project, suite_name, timestamp)

    response = project.get_project_health(data.project)

    assert response.json()[suite_name]['total'] == 1
    assert response.json()[suite_name]['execution'] == timestamp
    assert response.json()[suite_name]['totals_by_result'] == {'success': 1}
Beispiel #4
0
def test_create_test_existing_name(data):
    test_name = project.create_random_test(data.project)
    response = project.create_test(data.project, test_name)
    assert response.status_code == 200
    assert response.json()['errors'] == [
        'A test with that name already exists'
    ]
Beispiel #5
0
def test_rename_test(data):
    test_one = project.create_random_test(data.project)
    new_test_name = actions.random_str()
    response = test_.rename_test(data.project, test_one, new_test_name)
    assert response.status_code == 200
    assert response.json()['errors'] == []
    assert not project.test_exists(data.project, test_one)
    assert project.test_exists(data.project, new_test_name)
Beispiel #6
0
def test_save_test_code_with_an_error(data):
    test_name = project.create_random_test(data.project)
    code = 'def test_one(data):\n    print('
    response = test_.save_test_code(data.project, test_name, code)
    assert response.status_code == 200
    assert 'print(' in response.json()['testError']
    assert 'SyntaxError: unexpected EOF while parsing' in response.json()['testError']
    assert response.json()['dataErrors'] == []
Beispiel #7
0
def test(data):
    response = project.get_project_test_tags(data.project)
    assert response.status_code == 200
    assert response.json() == {}
    # add a test with one tag
    test_name = project.create_random_test(data.project)
    test_.save_test(data.project, test_name, tags=['tag1'])
    response = project.get_project_test_tags(data.project)
    assert response.json() == {test_name: ['tag1']}
Beispiel #8
0
def test_save_test_code(data):
    test_name = project.create_random_test(data.project)
    code = 'def test_one(data):\n    assert True'
    response = test_.save_test_code(data.project, test_name, code)
    assert response.status_code == 200
    assert response.json()['testError'] is None
    assert response.json()['dataErrors'] == []
    response = test_.get_test_components(data.project, test_name)
    assert response.json()['components']['code'] == code
Beispiel #9
0
def setup(data):
    project.using_project('general')
    data.suite = project.create_random_suite(data.project)
    data.test_name = project.create_random_test(data.project)
    suite.save_suite(data.project, data.suite, tests=[data.test_name])
    response = suite.run_suite(data.project, data.suite)
    data.timestamp = response.json()
    report.wait_for_execution_to_finish(data.project, data.suite,
                                        data.timestamp)
Beispiel #10
0
def test_save_test_with_internal_data(data):
    test_name = project.create_random_test(data.project)
    test_data = {
        'csv': None,
        'json': None,
        'internal': 'data = [{"a": "b"}]'
    }
    response = test_.save_test(data.project, test_name, test_data=test_data)
    assert response.status_code == 200
    assert response.json()['errors'] == []
Beispiel #11
0
def test_rename_test_with_invalid_name(data):
    test_name = project.create_random_test(data.project)
    new_name = 'test-{}'.format(actions.random_str())
    response = test_.rename_test(data.project, test_name, new_name)
    assert response.status_code == 200
    assert response.json()['errors'] == [
        'Only letters, numbers and underscores are allowed'
    ]
    assert project.test_exists(data.project, test_name)
    assert not project.test_exists(data.project, new_name)
Beispiel #12
0
def test_save_test_code_with_csv_data(data):
    test_name = project.create_random_test(data.project)
    test_data = {
        'csv': [{'a': 'b'}],
        'json': None,
        'internal': None
    }
    response = test_.save_test_code(data.project, test_name, '', test_data)
    assert response.status_code == 200
    assert response.json()['testError'] is None
    assert response.json()['dataErrors'] == []
Beispiel #13
0
def test_delete_test(data):
    test_one = project.create_random_test(data.project)
    response = test_.delete_test(data.project, test_one)
    assert response.status_code == 200
    assert response.json() == []
    assert not project.test_exists(data.project, test_one)

    test_two = '{}.{}'.format(actions.random_str(), actions.random_str())
    project.create_test(data.project, test_two)
    test_.delete_test(data.project, test_two)
    assert not project.test_exists(data.project, test_two)
Beispiel #14
0
def test_save_test_with_json_data_invalid_json(data):
    test_name = project.create_random_test(data.project)
    test_data = {
        'csv': None,
        'json': '[{"a": "b}]',
        'internal': None
    }
    response = test_.save_test(data.project, test_name, test_data=test_data)
    assert response.status_code == 200
    msg = 'json.decoder.JSONDecodeError: Unterminated string starting at: line 1 column 8'
    assert len(response.json()['errors']) == 1
    assert msg in response.json()['errors'][0]
Beispiel #15
0
def test_save_test_with_internal_data_invalid(data):
    test_name = project.create_random_test(data.project)
    test_data = {
        'csv': None,
        'json': None,
        'internal': 'data = [{"a": "b}]'
    }
    response = test_.save_test(data.project, test_name, test_data=test_data)
    assert response.status_code == 200
    assert len(response.json()['errors']) == 1
    msg = 'SyntaxError: EOL while scanning string literal'
    assert msg in response.json()['errors'][0]
Beispiel #16
0
def test_save_test_code(data):
    test_name = project.create_random_test(data.project)
    code = 'def test_one(data):\n    assert True'
    test_.save_test_code(data.project, test_name, code)

    response = test_.get_test_components(data.project, test_name)
    expected = {
        'description': '',
        'pages': [],
        'tags': [],
        'skip': False,
        'test_functions': {
            'test_one': [{
                'code': 'assert True',
                'type': 'code-block'
            }]
        },
        'test_function_list': ['test_one'],
        'test_hooks': {},
        'test_hook_list': [],
        'code': 'def test_one(data):\n    assert True',
    }
    assert response.json()['components'] == expected
Beispiel #17
0
def test_save_test(data):
    test_name = project.create_random_test(data.project)
    steps = {
        'hooks': {},
        'tests': {
            'test_one': [
                {'type': 'function-call', 'action': 'step', 'parameters': ["'msg'"]}
            ]
        }
    }
    response = test_.save_test(data.project, test_name, description='', pages=[],
                               steps=steps, tags=[], skip=False)
    assert response.status_code == 200
    assert response.json()['errors'] == []

    response = test_.get_test_components(data.project, test_name)
    expected = [{
        'code': "step('msg')",
        'function_name': 'step',
        'parameters': ["'msg'"],
        'type': 'function-call'
    }]
    assert response.json()['components']['test_functions']['test_one'] == expected
Beispiel #18
0
def setup(data):
    project.using_project('general')
    data.test = project.create_random_test(data.project)
    response = test_.run_test(data.project, data.test)
    actions.store('timestamp', response.json())
Beispiel #19
0
def test_rename_test_destination_exists(data):
    test_one = project.create_random_test(data.project)
    response = test_.rename_test(data.project, test_one, test_one)
    assert response.json()['errors'] == [
        'A file with that name already exists'
    ]
Beispiel #20
0
def setup(data):
    project.using_project('general')
    data.test_one = project.create_random_test(data.project)
    data.test_two = '{}.{}'.format(actions.random_str(), actions.random_str())
    project.create_test(data.project, data.test_two)
Beispiel #21
0
def test_duplicate_test_destination_exists(data):
    test_name = project.create_random_test(data.project)
    response = test_.duplicate_test(data.project, data.test, test_name)
    assert response.status_code == 200
    assert response.json() == ['A test with that name already exists']
Beispiel #22
0
def setup(data):
    project.using_project('general')
    data.test_one = project.create_random_test(data.project)
Beispiel #23
0
def setup(data):
    data.project = project.create_random_project()
    data.test = project.create_random_test(data.project)