示例#1
0
def test_renders_new_after_error():
    assert render_yaml(USER_CREATE_SCHEMA, [{
        "uid": 1000
    }], [
        Mock(attribute="user_create.uid",
             errmsg="User with such an UID already exists",
             errno=errno.EEXIST),
        Mock(attribute="user_create.invalid_field",
             errmsg="Unconsumed error",
             errno=errno.EEXIST),
    ]) == textwrap.dedent("""\
        # ERROR: Unconsumed error

        # Object: user_create
        user_create:
          # Integer: Unix user ID
          # ERROR: User with such an UID already exists
          uid: 1000

          # String: Username
          username:

          # Array: UNIX groups
          # groups:
            # Integer
            # -

          # Object: Additional attributes
          # attributes:

        # String: Force user creation
        # force: false
    """)
示例#2
0
def test_renders_new():
    assert render_yaml(USER_CREATE_SCHEMA, [], []) == textwrap.dedent("""\
        # Object: user_create
        user_create:
          # Array: UNIX groups
          # groups:

    """)
示例#3
0
def test_renders_new():
    assert render_yaml(CLOUD_SYNC_CREATE_SCHEMA, [],
                       []) == textwrap.dedent("""\
        # Object: cloud_sync_create
        cloud_sync_create:
          # Array: bwlimit
          # bwlimit:
            # Object: cloud_sync_bwlimit
            # - # String: time
            #   time:

            #   # Integer | Null: bandwidth
            #   bandwidth:


    """)
示例#4
0
def test_renders_new():
    assert render_yaml(USER_CREATE_SCHEMA, [], []) == textwrap.dedent("""\
        # Object: user_create
        user_create:
          # Integer: Unix user ID
          # uid:

          # String: Username
          username:

          # Array: UNIX groups
          # groups:
            # Integer
            # -

          # Object: Additional attributes
          # attributes:

        # String: Force user creation
        # force: false
    """)
示例#5
0
def test_renders_edit():
    assert render_yaml(USER_CREATE_SCHEMA, [{
        "uid": 1000,
        "username": "******",
        "groups": [1, 2, 3],
        "attributes": {
            "extra_attribute": {
                "child": 0.5
            }
        },
    }, True], [
        Mock(attribute="user_create.groups.1",
             errmsg="You are not welcome here",
             errno=errno.EEXIST),
    ]) == textwrap.dedent("""\
        # Object: user_create
        user_create:
          # Integer: Unix user ID
          uid: 1000

          # String: Username
          username: themylogin

          # Array: UNIX groups
          groups:
            # Integer
            - 1
            # ERROR: You are not welcome here
            - 2
            - 3

          # Object: Additional attributes
          attributes:
            extra_attribute:
              child: 0.5

        # String: Force user creation
        force: true
    """)
示例#6
0
def test_renders_existing():
    assert render_yaml(CLOUD_SYNC_CREATE_SCHEMA, [{
        "bwlimit": [
            {
                "time": "09:00",
                "bandwidth": 512000
            },
            {
                "time": "18:00 ",
                "bandwidth": None
            },
        ],
    }], [
        Mock(attribute="cloud_sync_create.bwlimit.1.time",
             errmsg="Incorrect time",
             errno=errno.EINVAL),
    ]) == textwrap.dedent("""\
        # Object: cloud_sync_create
        cloud_sync_create:
          # Array: bwlimit
          bwlimit:
            # Object: cloud_sync_bwlimit
            - # String: time
              time: 09:00

              # Integer | Null: bandwidth
              bandwidth: 512000

            # Object: cloud_sync_bwlimit
            - # String: time
              # ERROR: Incorrect time
              time: '18:00 '

              # Integer | Null: bandwidth
              bandwidth:


    """)