Example #1
0
def test_load_results_folder():
    """ Test that load_results takes a folder with a file named results.json """
    with utils.tempdir() as tdir:
        with open(os.path.join(tdir, 'results.json'), 'w') as tfile:
            tfile.write(json.dumps(utils.JSON_DATA))

        results.load_results(tdir)
Example #2
0
def test_load_results_folder():
    """ Test that load_results takes a folder with a file named results.json """
    with utils.tempdir() as tdir:
        with open(os.path.join(tdir, 'results.json'), 'w') as tfile:
            tfile.write(json.dumps(utils.JSON_DATA))

        results.load_results(tdir)
Example #3
0
def test_testrunresult_write():
    """ TestrunResult.write() works

    This tests for a bug where TestrunResult.write() wrote a file containing
    {}, essentially if it dumps a file that is equal to what was provided then
    it's probably working

    """
    with utils.resultfile() as f:
        result = results.load_results(f.name)
        with utils.tempdir() as tdir:
            result.write(os.path.join(tdir, 'results.json'))
            new = results.load_results(os.path.join(tdir, 'results.json'))

    nt.assert_dict_equal(result.__dict__, new.__dict__)
Example #4
0
def test_testrunresult_write():
    """ TestrunResult.write() works

    This tests for a bug where TestrunResult.write() wrote a file containing
    {}, essentially if it dumps a file that is equal to what was provided then
    it's probably working

    """
    with utils.resultfile() as f:
        result = results.load_results(f.name)
        with utils.tempdir() as tdir:
            result.write(os.path.join(tdir, 'results.json'))
            new = results.load_results(os.path.join(tdir, 'results.json'))

    nt.assert_dict_equal(result.__dict__, new.__dict__)
Example #5
0
def test_info_split():
    """ Version 1: info can split into any number of elements """
    data = copy.copy(DATA)
    data['tests']['sometest']['info'] = \
        'Returncode: 1\n\nErrors:stderr\n\nOutput: stdout\n\nmore\n\nstuff'

    with utils.with_tempfile(json.dumps(data)) as f:
        results._update_zero_to_one(results.load_results(f))
Example #6
0
    'group3/groupA/test': {
        'info': 'Returncode: 1\n\nErrors:stderr\n\nOutput:stdout\n',
        'subtest': {
            'subtest 1': 'pass',
            'subtest 2': 'pass',
            'subtest 3': 'pass',
        },
        'returncode': 0,
        'command': 'this is a command',
        'result': 'pass',
        'time': 0.1
    },
})

with utils.with_tempfile(json.dumps(DATA)) as f:
    RESULT = results._update_zero_to_one(results.load_results(f))


def test_dmesg():
    """ version 1: dmesg is converted from a list to a string """
    assert RESULT.tests['sometest']['dmesg'] == 'this\nis\ndmesg'


def test_subtests_remove_duplicates():
    """ Version 1: Removes duplicate entries """
    assert 'group1/groupA/test/subtest 1' not in RESULT.tests
    assert 'group1/groupA/test/subtest 2' not in RESULT.tests


def test_subtests_add_test():
    """ Version 1: Add an entry for the actual test """
Example #7
0
def test_load_results_file():
    """ Test that load_results takes a file """
    with utils.resultfile() as tfile:
        results.load_results(tfile.name)
Example #8
0
def test_load_results_file():
    """ Test that load_results takes a file """
    with utils.resultfile() as tfile:
        results.load_results(tfile.name)