Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nesting Sites #124

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions pynsot/commands/cmd_sites.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
('id', 'ID'),
('name', 'Name'),
('description', 'Description'),
('parent', 'Parent'),
)


Expand Down Expand Up @@ -66,8 +67,14 @@ def cli(ctx):
help='The name of the Site.',
required=True,
)
@click.option(
'-p',
'--parent',
metavar='PARENT',
help='ID of parent site'
)
@click.pass_context
def add(ctx, description, name):
def add(ctx, description, name, parent):
"""
Add a new Site.

Expand Down Expand Up @@ -181,15 +188,21 @@ def remove(ctx, id):
metavar='NAME',
help='The name of the Site.',
)
@click.option(
'-p',
'--parent',
metavar='PARENT',
help='ID of parent site'
)
@click.pass_context
def update(ctx, description, id, name):
def update(ctx, description, id, name, parent):
"""
Update a Site.

When updating a Site you must provide the unique ID (-i/--id) and at least
one of the -n/--name or -d/--description arguments.
one of the -n/--name, -p/--parent or -d/--description arguments.
"""
if name is None and description is None:
if name is None and description is None and parent is None:
msg = 'You must supply at least one of -n/--name or -d/--description'
raise click.UsageError(msg)

Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def client(config):
@pytest.fixture
def site(client):
"""Returns a Site object."""
return client.sites.post({'name': 'Foo', 'description': 'Foo site.'})
return client.sites.post({'name': 'Foo', 'description': 'Foo site.', 'parent': ''})


@pytest.fixture
Expand Down