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 """)
def test_renders_new(): assert render_yaml(USER_CREATE_SCHEMA, [], []) == textwrap.dedent("""\ # Object: user_create user_create: # Array: UNIX groups # groups: """)
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: """)
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 """)
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 """)
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: """)