%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/salt/states/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/salt/states/test.pyo

�
���^c@@s�dZddlmZmZmZddlZddlZddlm	Z	ddl
mZddlm
Z
d�Zd�Zd	�Zd
�Zd�Zeedd
�Zdd�Zdd�Zdd�Zd�Zdddddded�ZdS(u�
Test States
===========

Provide test case states that enable easy testing of things to do with state
calls, e.g. running, calling, logging, output filtering etc.

.. code-block:: yaml

    always-passes-with-any-kwarg:
      test.nop:
        - name: foo
        - something: else
        - foo: bar

    always-passes:
      test.succeed_without_changes:
        - name: foo

    always-fails:
      test.fail_without_changes:
        - name: foo

    always-changes-and-succeeds:
      test.succeed_with_changes:
        - name: foo

    always-changes-and-fails:
      test.fail_with_changes:
        - name: foo

    my-custom-combo:
      test.configurable_test_state:
        - name: foo
        - changes: True
        - result: False
        - comment: bar.baz

    is-pillar-foo-present-and-bar-is-int:
      test.check_pillar:
        - present:
            - foo
        - integer:
            - bar
i(tabsolute_importtprint_functiontunicode_literalsN(t_gen_tag(tsix(tSaltInvocationErrorcK@s
t|�S(u�
    A no-op state that does nothing. Useful in conjunction with the `use`
    requisite, or in templates which could otherwise be empty due to jinja
    rendering

    .. versionadded:: 2015.8.1
    (tsucceed_without_changes(tnametkwargs((s4/usr/lib/python2.7/site-packages/salt/states/test.pytnop;scK@s&i|d6id6td6dd6}|S(u`
    Returns successful.

    .. versionadded:: 2014.7.0

    name
        A unique string.
    unameuchangesuresultuSuccess!ucomment(tTrue(RRtret((s4/usr/lib/python2.7/site-packages/salt/states/test.pyRFs	
cK@sGi|d6id6td6dd6}tdrCt|d<d|d<n|S(u^
    Returns failure.

    .. versionadded:: 2014.7.0

    name:
        A unique string.
    unameuchangesuresultuFailure!ucommentutestu/If we weren't testing, this would be a failure!(tFalset__opts__(RRR((s4/usr/lib/python2.7/site-packages/salt/states/test.pytfail_without_changesXs	



cK@sfi|d6id6td6dd6}iidd6dd	6d
6|d<tdrbd
|d<d|d<n|S(uy
    Returns successful and changes is not empty

    .. versionadded:: 2014.7.0

    name:
        A unique string.
    unameuchangesuresultuSuccess!ucommentu	UnchangeduolduSomething pretended to changeunewutestingutestu<If we weren't testing, this would be successful with changesN(R
R
tNone(RRR((s4/usr/lib/python2.7/site-packages/salt/states/test.pytsucceed_with_changesos	



cK@sfi|d6id6td6dd6}iidd6dd	6d
6|d<tdrbd
|d<d|d<n|S(uw
    Returns failure and changes is not empty.

    .. versionadded:: 2014.7.0

    name:
        A unique string.
    unameuchangesuresultuFailure!ucommentu	UnchangeduolduSomething pretended to changeunewutestingutestu8If we weren't testing, this would be failed with changesN(RR
R(RRR((s4/usr/lib/python2.7/site-packages/salt/states/test.pytfail_with_changes�s	



ucC@s[i|d6id6td6|d6}iidd6dd6d	6}|d
krntjttg�r�||d<q�nD|tkr�||d<n+|tkr�i|d<nd}t|��|d
kr�tjttg�|d<n>|tkr�t|d<n%|tkrt|d<ntd��td
rW|tkr4tnd|d<|sJdn||d<n|S(uk
    A configurable test state which determines its output based on the inputs.

    .. versionadded:: 2014.7.0

    name:
        A unique string.
    changes:
        Do we return anything in the changes field?
        Accepts True, False, and 'Random'
        Default is True
    result:
        Do we return successfully or not?
        Accepts True, False, and 'Random'
        Default is True
        If test is True and changes is True, this will be None.  If test is
        True and and changes is False, this will be True.
    comment:
        String to fill the comment field with.
        Default is ''
    unameuchangesuresultucommentu	UnchangeduolduSomething pretended to changeunewutestinguRandomuuYou have specified the state option 'Changes' with invalid arguments. It must be either  'True', 'False', or 'Random'usYou have specified the state option 'Result' with invalid arguments. It must be either 'True', 'False', or 'Random'utestuThis is a testN(RtrandomtchoiceR
RR
R(RtchangestresulttcommentRtchange_dataterr((s4/usr/lib/python2.7/site-packages/salt/states/test.pytconfigurable_test_state�s:





cK@s;|std��ni|d6id6td6|d6}|S(u�
    Simple notification using text argument.

    .. versionadded:: 2015.8.0

    name
        A unique string.

    text
        Text to return in the comment.
    uMissing required argument text.unameuchangesuresultucomment(RR
(RttextRR((s4/usr/lib/python2.7/site-packages/salt/states/test.pytshow_notification�s

cK@s�g}dtkraxLtddD]9}t|�}t|dr!|jdj|��q!q!Wni|d6|jdt�d6|jdd�d6|jdi|d	6�d6}|S(
uM
    Call this function via a watch statement

    .. versionadded:: 2014.7.0

    Any parameters in the state return dictionary can be customized by adding
    the keywords ``result``, ``comment``, and ``changes``.

    .. code-block:: yaml

        this_state_will_return_changes:
          test.succeed_with_changes

        this_state_will_NOT_return_changes:
          test.succeed_without_changes

        this_state_is_watching_another_state:
          test.succeed_without_changes:
            - comment: 'This is a custom comment'
            - watch:
              - test: this_state_will_return_changes
              - test: this_state_will_NOT_return_changes

        this_state_is_also_watching_another_state:
          test.succeed_without_changes:
            - watch:
              - test: this_state_will_NOT_return_changes
    u__reqs__uwatchuchangesu{state}: {__id__}unameuresultucommentuWatch statement fired.uRequisites with changes(t__low__Rt__running__tappendtformattgetR
(RtsfunRthas_changestreqttagR((s4/usr/lib/python2.7/site-packages/salt/states/test.pyt	mod_watchs cC@sKtd|d�}|dkr#dS|dk	rCt||�rCtStSdS(u�
    Helper function to get pillar[key_str] and
    check if its type is key_type

    Returns None if the pillar key is missing.
    If present True or False depending on match
    of the values type.

    Can't check for None.
    u
pillar.getN(t__salt__Rt
isinstanceRR
(tkey_strtkey_typetvalue((s4/usr/lib/python2.7/site-packages/salt/states/test.pyt_check_key_typeCscC@sSt|tj�r(tjjj|�gSt|t�s@t�ntjj	j
|�S(u
    Checks if its argument is a list or a str.
    A str will be turned into a list with the
    str as its only element.
    (R'Rtstring_typestsalttutilststringutilst
to_unicodetlistt	TypeErrortdatatdecode_list(tlisting((s4/usr/lib/python2.7/site-packages/salt/states/test.pyt_if_str_then_listWs
	cC@s�|p!|p!|p!|p!|p!|s3td��n|p<g}|pHg}|pTg}|p`g}|plg}|pxg}i|d6id6td6dd6}i}	i}
i}t|�}||	d<t|�}||	t<t|�}||	t<t|�}||	tj<t|�}||	t<t|�}||	t	<x�|	j
�D]\}}
xp|
D]h}t||�}|dkr�d||<t|d<qV|s�|||<t|d<qV|rV||
|<qVqVWqCWxe|j
�D]W\}}dj
|�}|dkr|d7}n|d	j
|�7}|dc|7<q�W|r�|
r�d
}x0|
j
�D]"\}}|dj
||�7}qMW|dc|7<n|S(
u�
    Checks the presence and, optionally, the type of
    given keys in Pillar.
    Supported kwargs for types are:
    - boolean (bool)
    - integer (int)
    - string (str)
    - listing (list)
    - dictionary (dict)

    Checking for None type pillars is not implemented yet.

    .. code-block:: yaml

        is-pillar-foo-present-and-bar-is-int:
          test.check_pillar:
            - present:
                - foo
            - integer:
                - bar
    uMissing required argument text.unameuchangesuresultuucommentuPillar key "{0}" uis missing.
uis not {0}.
uThose keys passed the check:
u- {0} ({1})
N(RR
R6RtbooltintRR,R1tdicttitemsR+RR(RtpresenttbooleantintegertstringR5t
dictionarytverboseRtcheckstfinetfailedR)tkeystkeyRR((s4/usr/lib/python2.7/site-packages/salt/states/test.pytcheck_pillardsh












(t__doc__t
__future__RRRRtsalt.utils.dataR-t
salt.stateRtsalt.extRtsalt.exceptionsRR	RRRRR
RRRR%R+R6RRF(((s4/usr/lib/python2.7/site-packages/salt/states/test.pyt<module>.s.				!	!I/	

Zerion Mini Shell 1.0