Skip to content

Commit

Permalink
Roles: db migration to create constraints (#7689)
Browse files Browse the repository at this point in the history
* Roles: db migration to create constraints

Fixes #2745

* lint

* do it correctly

* Fix a flakey test and its brethren

* One stinkin' line fix

* Update translations

* fix broken test, no need for a dyanmic value to exercise invalid key

* fix role_id hidden input

* fixup signature of get_user_role_in_project

* update translations

* lint...

Co-authored-by: Donald Stufft <donald@stufft.io>
Co-authored-by: Dustin Ingram <di@users.noreply.github.com>
  • Loading branch information
3 people authored Mar 30, 2020
1 parent 32f621a commit a511197
Show file tree
Hide file tree
Showing 12 changed files with 205 additions and 438 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ ifneq ($(PR), false)
endif

initdb:
docker-compose run --rm web psql -h db -d postgres -U postgres -c "SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname ='warehouse';"
docker-compose run --rm web psql -h db -d postgres -U postgres -c "DROP DATABASE IF EXISTS warehouse"
docker-compose run --rm web psql -h db -d postgres -U postgres -c "CREATE DATABASE warehouse ENCODING 'UTF8'"
xz -d -f -k dev/$(DB).sql.xz --stdout | docker-compose run --rm web psql -h db -d warehouse -U postgres -v ON_ERROR_STOP=1 -1 -f -
Expand Down
1 change: 1 addition & 0 deletions tests/common/db/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def _create(cls, *args, **kwargs):
r = super()._create(*args, **kwargs)
session = cls._meta.sqlalchemy_session
session.flush()
session.expire_all()
return r


Expand Down
4 changes: 2 additions & 2 deletions tests/unit/admin/views/test_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,13 +296,13 @@ def test_invalid_key_query(self, db_request):
reverse=True,
)
db_request.matchdict["project_name"] = project.normalized_name
db_request.GET["q"] = "user:{}".format(journals[3].submitted_by)
db_request.GET["q"] = "user:username"
result = views.journals_list(project, db_request)

assert result == {
"journals": journals[:25],
"project": project,
"query": "user:{}".format(journals[3].submitted_by),
"query": "user:username",
}

def test_basic_query(self, db_request):
Expand Down
16 changes: 0 additions & 16 deletions tests/unit/legacy/api/test_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,6 @@ def test_no_files_with_serial(self, db_request):
user = UserFactory.create()
je = JournalEntryFactory.create(name=project.name, submitted_by=user)

# Make sure that we get any changes made since the JournalEntry was
# saved.
db_request.db.refresh(project)

assert simple.simple_detail(project, db_request) == {
"project": project,
"files": [],
Expand All @@ -118,10 +114,6 @@ def test_with_files_no_serial(self, db_request):
user = UserFactory.create()
JournalEntryFactory.create(submitted_by=user)

# Make sure that we get any changes made since the JournalEntry was
# saved.
db_request.db.refresh(project)

assert simple.simple_detail(project, db_request) == {
"project": project,
"files": files,
Expand All @@ -143,10 +135,6 @@ def test_with_files_with_serial(self, db_request):
user = UserFactory.create()
je = JournalEntryFactory.create(name=project.name, submitted_by=user)

# Make sure that we get any changes made since the JournalEntry was
# saved.
db_request.db.refresh(project)

assert simple.simple_detail(project, db_request) == {
"project": project,
"files": files,
Expand Down Expand Up @@ -201,10 +189,6 @@ def test_with_files_with_version_multi_digit(self, db_request):
user = UserFactory.create()
je = JournalEntryFactory.create(name=project.name, submitted_by=user)

# Make sure that we get any changes made since the JournalEntry was
# saved.
db_request.db.refresh(project)

assert simple.simple_detail(project, db_request) == {
"project": project,
"files": files,
Expand Down
Loading

0 comments on commit a511197

Please sign in to comment.