Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 7d0aa304

Přidáno uživatelem Stanislav Král před asi 4 roky(ů)

Re #8472 - Added few unit tests that perform further testing of _run_for_output method

Zobrazit rozdíly:

proj/services/cryptography.py
57 57

  
58 58
            if proc.returncode != 0:
59 59
                # if the process did not result in zero result code, then raise an exception
60
                if err is not None:
60
                if err is not None and len(err) > 0:
61 61
                    raise CryptographyException(executable, args, err.decode())
62 62
                else:
63 63
                    raise CryptographyException(executable, args,
proj/tests/services/cryptography/run_for_output_test.py
1
import pytest
2

  
3
from proj.services.cryptography import CryptographyException
4

  
5

  
6
def test_simple_exec(service):
7
    out = service._run_for_output(["version"])
8
    assert "OpenSSL" in out.decode()
9

  
10

  
11
def test_simple_exec_without_parameters(service):
12
    out = service._run_for_output()
13
    assert "OpenSSL>" in out.decode()
14

  
15

  
16
def test_nonexistent_executable(service):
17
    with pytest.raises(CryptographyException) as e:
18
        service._run_for_output(executable="nonexistent_executable#")
19
    assert """"nonexistent_executable#" not found in the current PATH.""" in e.value.message
20

  
21

  
22
def test_exception_str(service):
23
    with pytest.raises(CryptographyException) as e:
24
        service._run_for_output(executable="nonexistent_executable")
25
    assert """EXECUTABLE: nonexistent_executable
26
        ARGS: ('nonexistent_executable',)
27
        MESSAGE: "nonexistent_executable" not found in the current PATH.""" in e.value.__str__()

Také k dispozici: Unified diff