Skip to content

Commit

Permalink
chore: Remove populate and fix various dredd tests (#6506)
Browse files Browse the repository at this point in the history
  • Loading branch information
iamareebjamal authored Oct 5, 2019
1 parent f5a429f commit e35f8f1
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 112 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,4 @@ generated/

docker-compose.override.yml
celerybeat-schedule.*
.coverage
3 changes: 2 additions & 1 deletion app/factories/role.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

import app.factories.common as common
from app.models.role import db, Role
from app.models.user import ORGANIZER


class RoleFactory(factory.alchemy.SQLAlchemyModelFactory):
class Meta:
model = Role
sqlalchemy_session = db.session

name = common.string_
name = ORGANIZER
title_name = common.string_
24 changes: 12 additions & 12 deletions docs/api/blueprint/custom_system_roles.apib
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ Create a new custom system role using a name.

## Custom System Roles Details [/v1/custom-system-roles/{custom_system_role_id}]
+ Parameters
+ custom_system_role_id: 2 (integer) - ID of the custom system role in the form of an integer.
+ custom_system_role_id: 1 (integer) - ID of the custom system role in the form of an integer.

### Get Details [GET]
Get a single custom system role.
Expand All @@ -141,25 +141,25 @@ Get a single custom system role.
"version": "1.0"
},
"links": {
"self": "/v1/custom-system-roles/2"
"self": "/v1/custom-system-roles/1"
},
"data": {
"relationships": {
"panel-permissions": {
"links": {
"self": "/v1/custom-system-roles/2/relationships/panel-permissions",
"related": "/v1/custom-system-roles/2/panel-permissions"
"self": "/v1/custom-system-roles/1/relationships/panel-permissions",
"related": "/v1/custom-system-roles/1/panel-permissions"
}
}
},
"type": "custom-system-role",
"links": {
"self": "/v1/custom-system-roles/2"
"self": "/v1/custom-system-roles/1"
},
"attributes": {
"name": "Marketer"
},
"id": "2"
"id": "1"
}
}

Expand All @@ -183,7 +183,7 @@ Update a single custom system role.
"name": "Manager"
},
"type": "custom-system-role",
"id": "2"
"id": "1"
}
}
+ Response 200 (application/vnd.api+json)
Expand All @@ -193,25 +193,25 @@ Update a single custom system role.
"version": "1.0"
},
"links": {
"self": "/v1/custom-system-roles/2"
"self": "/v1/custom-system-roles/1"
},
"data": {
"relationships": {
"panel-permissions": {
"links": {
"self": "/v1/custom-system-roles/2/relationships/panel-permissions",
"related": "/v1/custom-system-roles/2/panel-permissions"
"self": "/v1/custom-system-roles/1/relationships/panel-permissions",
"related": "/v1/custom-system-roles/1/panel-permissions"
}
}
},
"type": "custom-system-role",
"links": {
"self": "/v1/custom-system-roles/2"
"self": "/v1/custom-system-roles/1"
},
"attributes": {
"name": "Manager"
},
"id": "2"
"id": "1"
}
}

Expand Down
30 changes: 15 additions & 15 deletions docs/api/blueprint/panel_permissions.apib
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,11 @@ Create a new panel permission using a name.

{
"links": {
"self": "/v1/panel-permissions/11"
"self": "/v1/panel-permissions/1"
},
"data": {
"links": {
"self": "/v1/panel-permissions/11"
"self": "/v1/panel-permissions/1"
},
"id": "11",
"attributes": {
Expand All @@ -261,8 +261,8 @@ Create a new panel permission using a name.
"relationships": {
"custom-system-roles": {
"links": {
"related": "/v1/panel-permissions/11/custom-system-roles",
"self": "/v1/panel-permissions/11/relationships/custom-system-roles"
"related": "/v1/panel-permissions/1/custom-system-roles",
"self": "/v1/panel-permissions/1/relationships/custom-system-roles"
}
}
},
Expand All @@ -275,7 +275,7 @@ Create a new panel permission using a name.

## Panel Permission Details [/v1/panel-permissions/{panel_permission_id}]
+ Parameters
+ panel_permission_id: 10 (integer) - ID of the panel permission in the form of an integer.
+ panel_permission_id: 1 (integer) - ID of the panel permission in the form of an integer.

### Get Details [GET]
Get a single panel permission.
Expand All @@ -292,11 +292,11 @@ Get a single panel permission.

{
"links": {
"self": "/v1/panel-permissions/10"
"self": "/v1/panel-permissions/1"
},
"data": {
"links": {
"self": "/v1/panel-permissions/10"
"self": "/v1/panel-permissions/1"
},
"id": "10",
"attributes": {
Expand All @@ -306,8 +306,8 @@ Get a single panel permission.
"relationships": {
"custom-system-roles": {
"links": {
"related": "/v1/panel-permissions/10/custom-system-roles",
"self": "/v1/panel-permissions/10/relationships/custom-system-roles"
"related": "/v1/panel-permissions/1/custom-system-roles",
"self": "/v1/panel-permissions/1/relationships/custom-system-roles"
}
}
},
Expand Down Expand Up @@ -340,30 +340,30 @@ Get a single panel permission.
"panel-name": "contents"
},
"type": "panel-permission",
"id": "10"
"id": "1"
}
}

+ Response 200 (application/vnd.api+json)

{
"links": {
"self": "/v1/panel-permissions/10"
"self": "/v1/panel-permissions/1"
},
"data": {
"links": {
"self": "/v1/panel-permissions/10"
"self": "/v1/panel-permissions/1"
},
"id": "10",
"id": "1",
"attributes": {
"can-access": true,
"panel-name": "contents"
},
"relationships": {
"custom-system-roles": {
"links": {
"related": "/v1/panel-permissions/10/custom-system-roles",
"self": "/v1/panel-permissions/10/relationships/custom-system-roles"
"related": "/v1/panel-permissions/1/custom-system-roles",
"self": "/v1/panel-permissions/1/relationships/custom-system-roles"
}
}
},
Expand Down
18 changes: 9 additions & 9 deletions docs/api/blueprint/user/user_permissions.apib
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ To create or modify any data of this data layer, you will need admin access. How
| `unverified-user` | allow for unverified user if set to true | boolean | - |
| `anonymous-user` | allow for ananymous user if set to true | boolean | **yes** |

## User permission Collection [/v1/user-permissions{?page%5bsize%5d,page%5bnumber%5d,sort,filter}]
## User Permission Collection [/v1/user-permissions{?page%5bsize%5d,page%5bnumber%5d,sort,filter}]
+ Parameters
+ page%5bsize%5d (optional, integer, `10`) - Maximum number of resources in a single paginated response.
+ page%5bnumber%5d (optional, integer, `2`) - Page number to fetched for the paginated response.
Expand Down Expand Up @@ -106,7 +106,7 @@ To create or modify any data of this data layer, you will need admin access. How
"anonymous-user": "false"
},
"type": "user-permission",
"id": "3",
"id": "1",
"links": {
"self": "/v1/user-permissions/3"
}
Expand All @@ -122,7 +122,7 @@ To create or modify any data of this data layer, you will need admin access. How

## User Permission Details [/v1/user-permissions/{id}]
+ Parameters
+ id: 3 (integer) - ID of the page in the form of an integer
+ id: 1 (integer) - ID of the page in the form of an integer

### Get User Permission Details [GET]
Get a single resource.
Expand All @@ -147,16 +147,16 @@ Get a single resource.
"anonymous-user": "false"
},
"type": "user-permission",
"id": "3",
"id": "1",
"links": {
"self": "/v1/user-permissions/3"
"self": "/v1/user-permissions/1"
}
},
"jsonapi": {
"version": "1.0"
},
"links": {
"self": "/v1/user-permissions/3"
"self": "/v1/user-permissions/1"
}
}

Expand All @@ -183,7 +183,7 @@ Update a single resource by `id`.
"anonymous-user": "false"
},
"type": "user-permission",
"id": "3"
"id": "1"
}
}

Expand All @@ -201,14 +201,14 @@ Update a single resource by `id`.
"type": "user-permission",
"id": "3",
"links": {
"self": "/v1/user-permissions/3"
"self": "/v1/user-permissions/1"
}
},
"jsonapi": {
"version": "1.0"
},
"links": {
"self": "/v1/user-permissions/3"
"self": "/v1/user-permissions/1"
}
}

Expand Down
4 changes: 2 additions & 2 deletions dredd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ timestamp: false
silent: false
path: []
hooks-worker-timeout: 11000
hooks-worker-connect-timeout: 5000
hooks-worker-connect-retry: 500
hooks-worker-connect-timeout: 10000
hooks-worker-connect-retry: 1000
hooks-worker-after-connect-wait: 100
hooks-worker-term-timeout: 5000
hooks-worker-term-retry: 500
Expand Down
2 changes: 0 additions & 2 deletions tests/all/integration/setup_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from app.models import db
from app.models.setting import Environment
from app.settings import set_settings
from populate_db import populate

_basedir = os.path.abspath(os.path.dirname(__file__))

Expand All @@ -22,7 +21,6 @@ def create_app():
celery.conf.update(app.config)
with app.test_request_context():
db.create_all()
populate()
set_settings(secret='super secret key', app_name='Open Event', app_environment=Environment.TESTING)

return app.test_client()
Expand Down
7 changes: 7 additions & 0 deletions tests/all/integration/test_migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from tests.all.integration.utils import OpenEventTestCase
from tests.all.integration.setup_database import Setup
from app.views.healthcheck import check_migrations
from populate_db import populate


class TestMigrations(OpenEventTestCase):
Expand All @@ -14,3 +15,9 @@ def test_migrations(self):
with app.test_request_context():
result = check_migrations().split(',')
self.assertEqual(result[0], 'success')

def test_populate(self):
"""Method to test populate command"""

with app.test_request_context():
populate()
Loading

0 comments on commit e35f8f1

Please sign in to comment.