def test_succeeds_with_required_parameters(self): # Test using positional parameters mock_args = [ '/tmp/rancher-gen/bin/rancher-gen', '--host', '192.168.0.15', '--port', '8080', '--access-key', '1234567890', '--secret-k', '1234567890abcd', '--project-id', '1a5', '/tmp/in.j2', '/tmp/out.txt' ] with patch.object(sys, 'argv', mock_args): with patch.object(RancherConnector, '__call__') as mock: main() assert mock.called # Test using the named parameter template mock_args = [ '/tmp/rancher-gen/bin/rancher-gen', '--host', '192.168.0.15', '--port', '8080', '--access-key', '1234567890', '--secret-k', '1234567890abcd', '--project-id', '1a5', '--template', '/tmp/in.j2:/tmp/out.txt' ] with patch.object(sys, 'argv', mock_args): with patch.object(RancherConnector, '__call__') as mock: main() assert mock.called
def test_fails_with_missing_host(self): mock_args = [ '/tmp/rancher-gen/bin/rancher-gen', '--port', '8080', '--access-key', '1234567890', '--secret-k', '1234567890abcd', '--project-id', '1a5', '--template', '/tmp/in.j2:/tmp/out.txt' ] with patch.object(sys, 'argv', mock_args): with patch('sys.stdout', new_callable=StringIO) as mock_stdout: main() assert mock_stdout.getvalue() == 'error: Missing host parameter\n'
def test_fails_with_missing_template(self): mock_args = [ '/tmp/rancher-gen/bin/rancher-gen', '--host', '192.168.0.15', '--port', '8080', '--access-key', '1234567890', '--secret-k', '1234567890abcd', '--project-id', '1a5' ] with patch.object(sys, 'argv', mock_args): with patch('sys.stdout', new_callable=StringIO) as mock_stdout: main() assert mock_stdout.getvalue() ==\ 'error: Missing at least one template and destination parameter\n'
def test_fails_with_missing_project_id(self): mock_args = [ '/tmp/rancher-gen/bin/rancher-gen', '--host', '192.168.0.15', '--port', '8080', '--access-key', '1234567890', '--secret-k', '1234567890abcd', '/tmp/in.j2', '/tmp/out.txt' ] with patch.object(sys, 'argv', mock_args): with patch('sys.stdout', new_callable=StringIO) as mock_stdout: main() assert mock_stdout.getvalue() ==\ 'error: Missing Rancher project id parameter\n'