def test_check_smartstack_check_missing_port( mock_is_file_in_dir, mock_read_service_info, capfd, ): # smartstack.yaml, instance exists, but no ports found mock_is_file_in_dir.return_value = True instance = 'main' smartstack_dict = { instance: { 'foo': 0, }, } mock_read_service_info.return_value = smartstack_dict expected_output = "%s\n%s\n" \ % ( PaastaCheckMessages.SMARTSTACK_YAML_FOUND, PaastaCheckMessages.SMARTSTACK_PORT_MISSING, ) smartstack_check(service='fake_service', service_path='path', soa_dir='path') output, _ = capfd.readouterr() assert output == expected_output
def test_check_smartstack_check_pass( mock_is_file_in_dir, mock_read_service_info, capfd, ): # smartstack.yaml exists and port is found mock_is_file_in_dir.return_value = True port = 80 instance = 'main' smartstack_dict = { 'smartstack': { instance: { 'proxy_port': port, }, }, } mock_read_service_info.return_value = smartstack_dict expected_output = "%s\n%s\n" \ % ( PaastaCheckMessages.SMARTSTACK_YAML_FOUND, PaastaCheckMessages.smartstack_port_found( instance, port, ), ) smartstack_check(service='fake_service', service_path='path', soa_dir='path') output, _ = capfd.readouterr() assert output == expected_output
def test_check_smartstack_check_is_ok_when_no_smartstack(mock_stdout, mock_is_file_in_dir): mock_is_file_in_dir.return_value = False expected_output = "" smartstack_check('fake_service', 'path') output = mock_stdout.getvalue() assert output == expected_output
def test_check_smartstack_check_is_ok_when_no_smartstack(mock_is_file_in_dir, capfd): mock_is_file_in_dir.return_value = False expected_output = "" smartstack_check(service='fake_service', service_path='path', soa_dir='path') output, _ = capfd.readouterr() assert output == expected_output
def test_check_smartstack_check_is_ok_when_no_smartstack(mock_stdout, mock_is_file_in_dir): mock_is_file_in_dir.return_value = False expected_output = "" smartstack_check(service='fake_service', service_path='path', soa_dir='path') output = mock_stdout.getvalue() assert output == expected_output
def test_check_smartstack_check_missing_instance( mock_stdout, mock_is_file_in_dir, mock_read_service_info): # smartstack.yaml exists, but no instances found mock_is_file_in_dir.return_value = True smartstack_dict = {} mock_read_service_info.return_value = smartstack_dict expected_output = "%s\n%s\n" \ % (PaastaCheckMessages.SMARTSTACK_YAML_FOUND, PaastaCheckMessages.SMARTSTACK_PORT_MISSING) smartstack_check('fake_service', 'path') output = mock_stdout.getvalue() assert output == expected_output
def test_check_smartstack_check_missing_instance( mock_stdout, mock_is_file_in_dir, mock_read_service_info): # smartstack.yaml exists, but no instances found mock_is_file_in_dir.return_value = True smartstack_dict = {} mock_read_service_info.return_value = smartstack_dict expected_output = "%s\n%s\n" \ % (PaastaCheckMessages.SMARTSTACK_YAML_FOUND, PaastaCheckMessages.SMARTSTACK_PORT_MISSING) smartstack_check(service='fake_service', service_path='path', soa_dir='path') output = mock_stdout.getvalue() assert output == expected_output
def test_check_smartstack_check_missing_port(mock_stdout, mock_is_file_in_dir, mock_read_service_info): # smartstack.yaml, instance exists, but no ports found mock_is_file_in_dir.return_value = True instance = 'main' smartstack_dict = {instance: {'foo': 0}} mock_read_service_info.return_value = smartstack_dict expected_output = "%s\n%s\n" \ % (PaastaCheckMessages.SMARTSTACK_YAML_FOUND, PaastaCheckMessages.SMARTSTACK_PORT_MISSING) smartstack_check('fake_service', 'path') output = mock_stdout.getvalue() assert output == expected_output
def test_check_smartstack_check_missing_instance( mock_is_file_in_dir, mock_read_service_info, capfd ): # smartstack.yaml exists, but no instances found mock_is_file_in_dir.return_value = True smartstack_dict = {} mock_read_service_info.return_value = smartstack_dict expected_output = "{}\n{}\n".format( PaastaCheckMessages.SMARTSTACK_YAML_FOUND, PaastaCheckMessages.SMARTSTACK_PORT_MISSING, ) smartstack_check(service="fake_service", service_path="path", soa_dir="path") output, _ = capfd.readouterr() assert output == expected_output
def test_check_smartstack_check_pass(mock_stdout, mock_is_file_in_dir, mock_read_service_info): # smartstack.yaml exists and port is found mock_is_file_in_dir.return_value = True port = 80 instance = 'main' smartstack_dict = {'smartstack': {instance: {'proxy_port': port}}} mock_read_service_info.return_value = smartstack_dict expected_output = "%s\n%s\n" \ % (PaastaCheckMessages.SMARTSTACK_YAML_FOUND, PaastaCheckMessages.smartstack_port_found( instance, port)) smartstack_check('fake_service', 'path') output = mock_stdout.getvalue() assert output == expected_output
def test_check_smartstack_check_pass( mock_is_file_in_dir, mock_read_service_info, capfd ): # smartstack.yaml exists and port is found mock_is_file_in_dir.return_value = True port = 80 instance = "main" smartstack_dict = {"smartstack": {instance: {"proxy_port": port}}} mock_read_service_info.return_value = smartstack_dict expected_output = "{}\n{}\n".format( PaastaCheckMessages.SMARTSTACK_YAML_FOUND, PaastaCheckMessages.smartstack_port_found(instance, port), ) smartstack_check(service="fake_service", service_path="path", soa_dir="path") output, _ = capfd.readouterr() assert output == expected_output
def test_check_smartstack_check_missing_port( mock_stdout, mock_is_file_in_dir, mock_read_service_info): # smartstack.yaml, instance exists, but no ports found mock_is_file_in_dir.return_value = True instance = 'main' smartstack_dict = { instance: { 'foo': 0 } } mock_read_service_info.return_value = smartstack_dict expected_output = "%s\n%s\n" \ % (PaastaCheckMessages.SMARTSTACK_YAML_FOUND, PaastaCheckMessages.SMARTSTACK_PORT_MISSING) smartstack_check(service='fake_service', service_path='path', soa_dir='path') output = mock_stdout.getvalue() assert output == expected_output
def test_check_smartstack_check_pass(mock_stdout, mock_is_file_in_dir, mock_read_service_info): # smartstack.yaml exists and port is found mock_is_file_in_dir.return_value = True port = 80 instance = 'main' smartstack_dict = { 'smartstack': { instance: { 'proxy_port': port } } } mock_read_service_info.return_value = smartstack_dict expected_output = "%s\n%s\n" \ % (PaastaCheckMessages.SMARTSTACK_YAML_FOUND, PaastaCheckMessages.smartstack_port_found( instance, port)) smartstack_check('fake_service', 'path') output = mock_stdout.getvalue() assert output == expected_output