Skip to content

Commit

Permalink
Merge pull request #6 from willianantunes/release/seed-db-qa
Browse files Browse the repository at this point in the history
New release to apply updated seed db on PRD
  • Loading branch information
willianantunes authored Jul 7, 2019
2 parents dbdef2f + 36c0b73 commit 857c4ef
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Django GraphQL Playground

[![Build status](https://dev.azure.com/willianantunes/python/_apis/build/status/Django%20GraphQL%20Playground)](https://dev.azure.com/willianantunes/python/_build/latest?definitionId=1)
![Azure DevOps coverage](https://img.shields.io/azure-devops/coverage/willianantunes/python/1.svg?label=Azure%20Pipelines%20Coverage)
[![Build status](https://vsrm.dev.azure.com/willianantunes/_apis/public/Release/badge/5674f3e0-ef67-4b72-9d1b-1baf81d589c7/1/6)](https://vsrm.dev.azure.com/willianantunes/_apis/public/Release/badge/5674f3e0-ef67-4b72-9d1b-1baf81d589c7/1/6)
[![Maintainability](https://api.codeclimate.com/v1/badges/90f0ed08e9d576f7c602/maintainability)](https://codeclimate.com/github/willianantunes/django-graphql-playground/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/90f0ed08e9d576f7c602/test_coverage)](https://codeclimate.com/github/willianantunes/django-graphql-playground/test_coverage)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from django.contrib.auth import get_user_model
from django.core.management import BaseCommand
from django.core.management import CommandError

from django_graphql_playground.apps.core.models import Category
from django_graphql_playground.apps.core.models import Ingredient

Expand Down Expand Up @@ -47,7 +45,7 @@ def handle(self, *args, **options):
self.stdout.write(log_output)
get_user_model().objects.create_superuser(self.admin_username, None, self.admin_password)
else:
raise CommandError(f"Super user {self.admin_username} already exists")
self.stdout.write(f"Super user already exists")

if not self.only_super_user:
if Category.objects.all().count() == 0:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from django.contrib.auth.models import User
from django.core.management import CommandError
from django.core.management import call_command

from django_graphql_playground.apps.core.models import Category
from django_graphql_playground.apps.core.models import Ingredient

Expand Down Expand Up @@ -66,14 +65,14 @@ def test_should_seed_db_with_custom_super_user_given_extra_options():


@pytest.mark.django_db
def test_should_throw_exception_if_super_user_exists():
def test_should_inform_if_super_user_exists():
out = StringIO()
custom_username = "xpto"
get_user_model().objects.create_superuser(custom_username, None, "fake-password")

with pytest.raises(CommandError) as e:
call_command("seed_db", "--create-super-user", f"-u {custom_username}")
call_command("seed_db", "--create-super-user", f"-u {custom_username}", stdout=out)

assert e.value.args[0] == "Super user xpto already exists"
assert out.getvalue() == "Super user already exists\nCreating categories\nCreating ingredients\n"


@pytest.mark.django_db
Expand Down

0 comments on commit 857c4ef

Please sign in to comment.