예제 #1
0
import sys
import unittest
from unittest.mock import patch, Mock, call
from argparse import ArgumentParser
from types import SimpleNamespace
from io import StringIO

from sap.errors import SAPCliError
import sap.cli.atc
from sap.adt.objects import ADTObjectSets

from mock import Connection, Response

from infra import generate_parse_args

parse_args = generate_parse_args(sap.cli.atc.CommandGroup())


class TestConfiguration(unittest.TestCase):
    @patch('sap.adt.atc.fetch_customizing')
    def test_default(self, fake_fetch_customizing):
        connection = Mock()

        fake_fetch_customizing.return_value = Mock()
        fake_fetch_customizing.return_value.system_check_variant = 'THE_VARIANT'

        args = parse_args('customizing')
        with patch('sap.cli.atc.printout', Mock()) as fake_printout:
            args.execute(connection, args)

        fake_fetch_customizing.assert_called_once_with(connection)
예제 #2
0
#!/usr/bin/env python3

import unittest
from unittest.mock import MagicMock, patch, Mock, PropertyMock

import sap.cli.gcts

from mock import (ConsoleOutputTestCase, PatcherTestCase, GCTSLogBuilder,
                  GCTSLogMessages, GCTSLogProtocol, make_gcts_log_error)

from infra import generate_parse_args

parse_args = generate_parse_args(sap.cli.gcts.CommandGroup())


def dummy_gcts_error_log():
    log_builder = GCTSLogBuilder()

    log_builder.log_error(
        make_gcts_log_error('Line 1',
                            protocol=GCTSLogProtocol(
                                'Program',
                                GCTSLogMessages('protocol 1', 'protocol 2'))))

    log_builder.log_error(make_gcts_log_error('Line 2'))
    log_builder.log_exception('Message', 'ERROR')
    return log_builder.get_contents()


class TestgCTSDumpError(ConsoleOutputTestCase, unittest.TestCase):
    def test_dump_first_level(self):
예제 #3
0
import unittest
from types import SimpleNamespace
from unittest.mock import patch, mock_open, call, Mock

import sap.cli.strust
from sap.errors import SAPCliError
from sap.rfc.strust import CLIENT_ANONYMOUS, CLIENT_STANDART

from infra import generate_parse_args

parse_args = generate_parse_args(sap.cli.strust.CommandGroup())


class RFCCall:
    def __init__(self, function, **kwargs):
        self.function = function
        self.kwargs = kwargs

    def __repr__(self):
        return self.__str__()

    def __str__(self):
        params = ', '.join(
            (f'{name}={value}' for name, value in self.kwargs.items()))
        return f'{self.function}({params})'

    def __eq__(self, other):
        if not isinstance(other, self.__class__):
            return False

        return self.function == other.function and self.kwargs == other.kwargs
예제 #4
0
# pylint: disable=protected-access,missing-function-docstring

import unittest
from unittest.mock import Mock, patch, call

from mock import (
    ConsoleOutputTestCase,
    PatcherTestCase,
)

import sap.cli.abapgit

from infra import generate_parse_args

parse_args = generate_parse_args(sap.cli.abapgit.CommandGroup())


class TestAbapgitLink(PatcherTestCase, ConsoleOutputTestCase):
    '''Test Abapgit Link command'''
    def setUp(self):
        super().setUp()
        ConsoleOutputTestCase.setUp(self)
        assert self.console is not None

        self.connection = Mock()

        self.patch_console(console=self.console)
        self.link_patch = self.patch('sap.adt.abapgit.Repository.link')
        self.link_patch.return_value = Mock()