Exemple #1
0
def test_from_inline():
    """Create a PyMAS instance from an inline Python function."""
    from sasctl.utils.pymas import from_inline

    result = from_inline(dummy_func)
    assert isinstance(result, PyMAS)

    with mock.patch('sasctl.utils.pymas.core.PyMAS', autospec=True) as mocked:
        _ = from_inline(dummy_func)
        assert 1 == mocked.call_count
        call_args = mocked.call_args[0]
        assert [DS2Variable('x1', 'str', False),
                DS2Variable('x2', 'int', False),
                DS2Variable('out1', 'float', True)] == call_args[1]   # Variables

    with mock.patch('sasctl.utils.pymas.core.PyMAS', autospec=True) as mocked:
        _ = from_inline(dummy_func, input_types=int)
        assert 1 == mocked.call_count
        call_args = mocked.call_args[0]
        assert [DS2Variable('x1', 'int', False),
                DS2Variable('x2', 'int', False),
                DS2Variable('result', 'float', True)] == call_args[1]   # Variables

    with mock.patch('sasctl.utils.pymas.core.PyMAS', autospec=True) as mocked:
        _ = from_inline(dummy_func, input_types=OrderedDict([('a', int), ('b', float)]))
        assert 1 == mocked.call_count
        call_args = mocked.call_args[0]
        assert [DS2Variable('a', 'int', False),
                DS2Variable('b', 'double', False),
                DS2Variable('result', 'float', True)] == call_args[1]   # Variables
Exemple #2
0
def test_score_code():
    from sasctl.utils.pymas import from_inline

    p = from_inline(dummy_func)
    assert isinstance(p, PyMAS)

    mas_code = p.score_code()
    esp_code = p.score_code(dest='ep')

    assert mas_code.lower().startswith('package _')
    assert esp_code.lower().startswith('data sasep.out;')

    cas_code = p.score_code('in_table', 'out_table', ['in1', 'in2'], dest='cas')

    pytest.xfail('Not implemented.')
Exemple #3
0
def test_from_inline():
    from sasctl.utils.pymas import from_inline, PyMAS

    p = from_inline(dummy_function)
    assert isinstance(p, PyMAS)