Unpin webob and hacking to fix compatibility issues

The pinned versions of webob and hacking weren't functioning properly
with modern Python, so they are unpinned.

Unpinning hacking brought a number of extra rules into use, so this
commit also contains a number of code style fixes.

There was also an incompatibility in the test_setup.sh script, which
meant it doesn't work with MySQL 8.0 (which is in Ubuntu 20.04). This
is also fixed in this commit.

Change-Id: I0889bc35f8babfeec42f6f577d302bb5fbce1c95
This commit is contained in:
Adam Coldrick 2020-09-11 00:31:14 +01:00
parent 647bb9c660
commit 983bb8e2d7
47 changed files with 205 additions and 173 deletions

View File

@ -16,7 +16,7 @@ PyYAML>=3.1.0
requests>=1.1 requests>=1.1
six>=1.7.0 six>=1.7.0
SQLAlchemy SQLAlchemy
webob==1.7.4 webob
WSME>=0.6,<0.8 WSME>=0.6,<0.8
SQLAlchemy-FullText-Search>=0.2.3 SQLAlchemy-FullText-Search>=0.2.3
stevedore>=1.3.0 stevedore>=1.3.0

View File

@ -165,5 +165,6 @@ def start():
srv.serve_forever() srv.serve_forever()
if __name__ == '__main__': if __name__ == '__main__':
start() start()

View File

@ -298,5 +298,6 @@ class OpenIdConnectServer(WebApplicationServer):
request_validator, request_validator,
token_expires_in=access_token_ttl) token_expires_in=access_token_ttl)
validator = SkeletonValidator() validator = SkeletonValidator()
SERVER = OpenIdConnectServer(validator) SERVER = OpenIdConnectServer(validator)

View File

@ -66,9 +66,9 @@ class OpenIdClient(object):
message=e_msg.NO_CLIENT_ID) message=e_msg.NO_CLIENT_ID)
oauth_client_is_invalid = True oauth_client_is_invalid = True
for valid_oauth_client in CONF.oauth.valid_oauth_clients: for valid_oauth_client in CONF.oauth.valid_oauth_clients:
if ((valid_oauth_client == client_id) or if ((valid_oauth_client == client_id)
(valid_oauth_client.startswith('^') and or (valid_oauth_client.startswith('^')
re.match(valid_oauth_client, client_id))): and re.match(valid_oauth_client, client_id))):
oauth_client_is_invalid = False oauth_client_is_invalid = False
break break
if oauth_client_is_invalid: if oauth_client_is_invalid:

View File

@ -100,9 +100,9 @@ class CORSMiddleware(object):
# Does this request match one of our origin domains? # Does this request match one of our origin domains?
for allowed_origin in self.allowed_origins: for allowed_origin in self.allowed_origins:
if ((allowed_origin == origin) or if ((allowed_origin == origin)
(allowed_origin.startswith('^') and or (allowed_origin.startswith('^')
re.match(allowed_origin, origin))): and re.match(allowed_origin, origin))):
# Is this an OPTIONS request? # Is this an OPTIONS request?
if method == 'OPTIONS': if method == 'OPTIONS':

View File

@ -88,7 +88,7 @@ class SwiftStorageImpl(StorageBackend):
conn.object_store.create_container(CONF.swift.container) conn.object_store.create_container(CONF.swift.container)
conn.object_store.set_container_temp_url_key( conn.object_store.set_container_temp_url_key(
CONF.swift.container, CONF.swift.temp_url_key) CONF.swift.container, CONF.swift.temp_url_key)
container = conn.object_store.set_container_metadata( conn.object_store.set_container_metadata(
CONF.swift.container, read_ACL=".r:*") CONF.swift.container, read_ACL=".r:*")
def get_upload_url(self): def get_upload_url(self):

View File

@ -323,8 +323,8 @@ class StoriesController(rest.RestController):
""" """
# Reject private story types while ACL is not created. # Reject private story types while ACL is not created.
if (story.story_type_id and if (story.story_type_id
(story.story_type_id == 3 or story.story_type_id == 4)): and (story.story_type_id == 3 or story.story_type_id == 4)):
abort(400, _("Now you can't add story with type %s.") % abort(400, _("Now you can't add story with type %s.") %
story.story_type_id) story.story_type_id)
@ -393,8 +393,8 @@ class StoriesController(rest.RestController):
user_id = request.current_user_id user_id = request.current_user_id
# Reject private story types while ACL is not created. # Reject private story types while ACL is not created.
if (story.story_type_id and if (story.story_type_id
(story.story_type_id == 3 or story.story_type_id == 4)): and (story.story_type_id == 3 or story.story_type_id == 4)):
abort(400, _("Now you can't change story type to %s.") % abort(400, _("Now you can't change story type to %s.") %
story.story_type_id) story.story_type_id)

View File

@ -179,8 +179,8 @@ def task_is_valid_put(task, original_task):
abort(400, abort(400,
_("Milestones can only be associated with merged tasks")) _("Milestones can only be associated with merged tasks"))
if (original_task.status == 'merged' and if (original_task.status == 'merged'
task.status and task.status != 'merged'): and task.status and task.status != 'merged'):
abort(400, abort(400,
_("Milestones can only be associated with merged tasks")) _("Milestones can only be associated with merged tasks"))
elif 'milestone_id' in task.as_dict(omit_unset=True): elif 'milestone_id' in task.as_dict(omit_unset=True):
@ -201,48 +201,48 @@ def task_is_valid_put(task, original_task):
def post_timeline_events(original_task, updated_task): def post_timeline_events(original_task, updated_task):
# If both the assignee_id and the status were changed there will be # If both the assignee_id and the status were changed there will be
# two separate comments in the activity log. # two separate comments in the activity log.
author_id = request.current_user_id author_id = request.current_user_id
specific_change = False specific_change = False
if original_task.status != updated_task.status: if original_task.status != updated_task.status:
events_api.task_status_changed_event( events_api.task_status_changed_event(
story_id=original_task.story_id, story_id=original_task.story_id,
task_id=original_task.id, task_id=original_task.id,
task_title=original_task.title, task_title=original_task.title,
author_id=author_id, author_id=author_id,
old_status=original_task.status, old_status=original_task.status,
new_status=updated_task.status) new_status=updated_task.status)
specific_change = True specific_change = True
if original_task.priority != updated_task.priority: if original_task.priority != updated_task.priority:
events_api.task_priority_changed_event( events_api.task_priority_changed_event(
story_id=original_task.story_id, story_id=original_task.story_id,
task_id=original_task.id, task_id=original_task.id,
task_title=original_task.title, task_title=original_task.title,
author_id=author_id, author_id=author_id,
old_priority=original_task.priority, old_priority=original_task.priority,
new_priority=updated_task.priority) new_priority=updated_task.priority)
specific_change = True specific_change = True
if original_task.assignee_id != updated_task.assignee_id: if original_task.assignee_id != updated_task.assignee_id:
events_api.task_assignee_changed_event( events_api.task_assignee_changed_event(
story_id=original_task.story_id, story_id=original_task.story_id,
task_id=original_task.id, task_id=original_task.id,
task_title=original_task.title, task_title=original_task.title,
author_id=author_id, author_id=author_id,
old_assignee_id=original_task.assignee_id, old_assignee_id=original_task.assignee_id,
new_assignee_id=updated_task.assignee_id) new_assignee_id=updated_task.assignee_id)
specific_change = True specific_change = True
if not specific_change: if not specific_change:
events_api.task_details_changed_event( events_api.task_details_changed_event(
story_id=original_task.story_id, story_id=original_task.story_id,
task_id=original_task.id, task_id=original_task.id,
task_title=original_task.title, task_title=original_task.title,
author_id=author_id) author_id=author_id)
class TasksPrimaryController(rest.RestController): class TasksPrimaryController(rest.RestController):

View File

@ -142,6 +142,7 @@ class ProjectGroup(base.APIBase):
name="Infra", name="Infra",
title="Awesome projects") title="Awesome projects")
TaskStatuses = wtypes.Enum(wtypes.text, 'todo', 'inprogress', TaskStatuses = wtypes.Enum(wtypes.text, 'todo', 'inprogress',
'invalid', 'review', 'merged') 'invalid', 'review', 'merged')

View File

@ -199,9 +199,9 @@ def get_from_lane(worklist):
def get_card(board, item_type, item_id, archived=False): def get_card(board, item_type, item_id, archived=False):
for lane in board.lanes: for lane in board.lanes:
for card in lane.worklist.items: for card in lane.worklist.items:
if (card.item_type == item_type and if (card.item_type == item_type
card.item_id == item_id and and card.item_id == item_id
card.archived == archived): and card.archived == archived):
return card return card

View File

@ -308,9 +308,9 @@ def move_item(item_id, new_pos, new_list_id=None):
old_pos = modified_card.list_position old_pos = modified_card.list_position
# If the item hasn't actually moved, we don't need to move it. # If the item hasn't actually moved, we don't need to move it.
if (old_pos == new_pos and if (old_pos == new_pos
(new_list_id == modified_card.list_id or and (new_list_id == modified_card.list_id
new_list_id is None)): or new_list_id is None)):
return modified_card return modified_card
# "old_list" is the list the item is moving from, and "new_list" is # "old_list" is the list the item is moving from, and "new_list" is

View File

@ -19,16 +19,17 @@ Create Date: ${create_date}
""" """
# revision identifiers, used by Alembic.
revision = ${repr(up_revision)}
down_revision = ${repr(down_revision)}
from alembic import op from alembic import op
import sqlalchemy as sa import sqlalchemy as sa
${imports if imports else ""} ${imports if imports else ""}
# revision identifiers, used by Alembic.
revision = ${repr(up_revision)}
down_revision = ${repr(down_revision)}
def upgrade(active_plugins=None, options=None): def upgrade(active_plugins=None, options=None):
${upgrades if upgrades else "pass"} ${upgrades if upgrades else "pass"}

View File

@ -19,11 +19,6 @@ Create Date: 2013-12-10 00:35:55.327593
""" """
# revision identifiers, used by Alembic.
revision = '001'
down_revision = None
from alembic import op from alembic import op
from oslo_log import log from oslo_log import log
import sqlalchemy as sa import sqlalchemy as sa
@ -36,6 +31,10 @@ LOG = log.getLogger(__name__)
MYSQL_ENGINE = 'InnoDB' MYSQL_ENGINE = 'InnoDB'
MYSQL_CHARSET = 'utf8' MYSQL_CHARSET = 'utf8'
# revision identifiers, used by Alembic.
revision = '001'
down_revision = None
def _define_enums(): def _define_enums():
pref_type = sa.Enum('string', 'int', 'bool', 'float') pref_type = sa.Enum('string', 'int', 'bool', 'float')

View File

@ -19,10 +19,6 @@ Create Date: 2015-08-17 12:17:35.629353
""" """
# revision identifiers, used by Alembic.
revision = '049'
down_revision = '001'
from alembic import op from alembic import op
import sqlalchemy as sa import sqlalchemy as sa
@ -30,6 +26,11 @@ import sqlalchemy as sa
import storyboard import storyboard
# revision identifiers, used by Alembic.
revision = '049'
down_revision = '001'
def upgrade(active_plugins=None, options=None): def upgrade(active_plugins=None, options=None):
op.create_table('worklists', op.create_table('worklists',
sa.Column('id', sa.Integer(), nullable=False), sa.Column('id', sa.Integer(), nullable=False),

View File

@ -19,10 +19,6 @@ Create Date: 2015-10-09 10:25:47.338906
""" """
# revision identifiers, used by Alembic.
revision = '050'
down_revision = '049'
from alembic import op from alembic import op
import sqlalchemy as sa import sqlalchemy as sa
@ -34,6 +30,11 @@ from storyboard.db.api import worklists
from storyboard.db import models from storyboard.db import models
# revision identifiers, used by Alembic.
revision = '050'
down_revision = '049'
def upgrade(active_plugins=None, options=None): def upgrade(active_plugins=None, options=None):
op.create_table('board_permissions', op.create_table('board_permissions',
sa.Column('board_id', sa.Integer(), nullable=True), sa.Column('board_id', sa.Integer(), nullable=True),

View File

@ -20,10 +20,6 @@ Create Date: 2015-12-03 12:00:00
""" """
# revision identifiers, used by Alembic.
revision = '051'
down_revision = '050'
from alembic import op from alembic import op
import json import json
@ -32,6 +28,10 @@ from sqlalchemy.sql import column
from sqlalchemy.sql.expression import table from sqlalchemy.sql.expression import table
# revision identifiers, used by Alembic.
revision = '051'
down_revision = '050'
subs_events_table = table( subs_events_table = table(
'subscription_events', 'subscription_events',
sa.Column('id', sa.Integer(), nullable=False), sa.Column('id', sa.Integer(), nullable=False),

View File

@ -19,15 +19,16 @@ Create Date: 2016-02-08 15:58:59.451550
""" """
# revision identifiers, used by Alembic.
revision = '052'
down_revision = '051'
from alembic import op from alembic import op
import sqlalchemy as sa import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '052'
down_revision = '051'
def upgrade(active_plugins=None, options=None): def upgrade(active_plugins=None, options=None):
op.add_column('tasks', sa.Column('link', sa.UnicodeText(), nullable=True)) op.add_column('tasks', sa.Column('link', sa.UnicodeText(), nullable=True))

View File

@ -19,10 +19,6 @@ Create Date: 2016-02-04 11:27:55.607256
""" """
# revision identifiers, used by Alembic.
revision = '053'
down_revision = '052'
from alembic import op from alembic import op
import sqlalchemy as sa import sqlalchemy as sa
@ -30,6 +26,11 @@ import sqlalchemy as sa
from storyboard.db.decorators import UTCDateTime from storyboard.db.decorators import UTCDateTime
# revision identifiers, used by Alembic.
revision = '053'
down_revision = '052'
def upgrade(active_plugins=None, options=None): def upgrade(active_plugins=None, options=None):
op.create_table( op.create_table(
'due_dates', 'due_dates',

View File

@ -19,15 +19,15 @@ Create Date: 2016-02-25 19:15:29.464877
""" """
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic. # revision identifiers, used by Alembic.
revision = '054' revision = '054'
down_revision = '053' down_revision = '053'
from alembic import op
import sqlalchemy as sa
def upgrade(active_plugins=None, options=None): def upgrade(active_plugins=None, options=None):
op.add_column( op.add_column(
'worklist_items', sa.Column('archived', sa.Boolean(), nullable=True)) 'worklist_items', sa.Column('archived', sa.Boolean(), nullable=True))

View File

@ -19,15 +19,16 @@ Create Date: 2016-03-05 23:35:40.379333
""" """
# revision identifiers, used by Alembic.
revision = '055'
down_revision = '054'
from alembic import op from alembic import op
import sqlalchemy as sa import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '055'
down_revision = '054'
def upgrade(active_plugins=None, options=None): def upgrade(active_plugins=None, options=None):
op.add_column( op.add_column(
'comments', sa.Column('in_reply_to', sa.Integer(), nullable=True)) 'comments', sa.Column('in_reply_to', sa.Integer(), nullable=True))

View File

@ -19,10 +19,6 @@ Create Date: 2016-03-04 13:31:01.600372
""" """
# revision identifiers, used by Alembic.
revision = '056'
down_revision = '055'
from alembic import op from alembic import op
import sqlalchemy as sa import sqlalchemy as sa
@ -31,6 +27,11 @@ from sqlalchemy.dialects import mysql
import storyboard import storyboard
# revision identifiers, used by Alembic.
revision = '056'
down_revision = '055'
def upgrade(active_plugins=None, options=None): def upgrade(active_plugins=None, options=None):
op.create_table( op.create_table(
'worklist_filters', 'worklist_filters',

View File

@ -28,16 +28,17 @@ Create Date: 2016-04-27 15:45:51.646556
""" """
# revision identifiers, used by Alembic.
revision = '057'
down_revision = '056'
from alembic import op from alembic import op
import sqlalchemy as sa import sqlalchemy as sa
from sqlalchemy.dialects import mysql from sqlalchemy.dialects import mysql
# revision identifiers, used by Alembic.
revision = '057'
down_revision = '056'
def upgrade(active_plugins=None, options=None): def upgrade(active_plugins=None, options=None):
op.create_table( op.create_table(
'story_permissions', 'story_permissions',

View File

@ -19,14 +19,15 @@ Create Date: 2016-06-01 13:28:19.033906
""" """
# revision identifiers, used by Alembic.
revision = '058'
down_revision = '057'
from alembic import op from alembic import op
import sqlalchemy as sa import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '058'
down_revision = '057'
old_type_enum = sa.Enum('task', 'story', 'project', 'project_group') old_type_enum = sa.Enum('task', 'story', 'project', 'project_group')
new_type_enum = sa.Enum( new_type_enum = sa.Enum(
'task', 'story', 'project', 'project_group', 'worklist') 'task', 'story', 'project', 'project_group', 'worklist')

View File

@ -19,10 +19,6 @@ Create Date: 2016-06-21 14:00:20.515139
""" """
# revision identifiers, used by Alembic.
revision = '059'
down_revision = '058'
from alembic import op from alembic import op
import sqlalchemy as sa import sqlalchemy as sa
@ -31,6 +27,11 @@ from storyboard.db.decorators import UTCDateTime
from storyboard.db.models import MYSQL_MEDIUM_TEXT from storyboard.db.models import MYSQL_MEDIUM_TEXT
# revision identifiers, used by Alembic.
revision = '059'
down_revision = '058'
def upgrade(active_plugins=None, options=None): def upgrade(active_plugins=None, options=None):
op.create_table( op.create_table(
'comments_history', 'comments_history',

View File

@ -19,15 +19,16 @@ Create Date: 2016-07-14 15:05:12.369072
""" """
# revision identifiers, used by Alembic.
revision = '060'
down_revision = '059'
from alembic import op from alembic import op
import sqlalchemy as sa import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '060'
down_revision = '059'
def upgrade(active_plugins=None, options=None): def upgrade(active_plugins=None, options=None):
op.add_column( op.add_column(
'events', sa.Column('board_id', sa.Integer(), nullable=True)) 'events', sa.Column('board_id', sa.Integer(), nullable=True))

View File

@ -19,15 +19,16 @@ Create Date: 2017-03-17 10:28:24.567704
""" """
# revision identifiers, used by Alembic.
revision = '061'
down_revision = '060'
from alembic import op from alembic import op
import sqlalchemy as sa import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '061'
down_revision = '060'
def upgrade(active_plugins=None, options=None): def upgrade(active_plugins=None, options=None):
dialect = op.get_bind().engine.dialect dialect = op.get_bind().engine.dialect
if dialect.supports_alter: if dialect.supports_alter:

View File

@ -19,15 +19,16 @@ Create Date: 2018-03-23 14:34:55.656531
""" """
# revision identifiers, used by Alembic.
revision = '062'
down_revision = '061'
from alembic import op from alembic import op
import sqlalchemy as sa import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '062'
down_revision = '061'
def upgrade(active_plugins=None, options=None): def upgrade(active_plugins=None, options=None):
dialect = op.get_bind().engine.dialect dialect = op.get_bind().engine.dialect
if dialect.supports_alter: if dialect.supports_alter:

View File

@ -19,14 +19,15 @@ Create Date: 2018-06-25 17:13:43.992561
""" """
from alembic import op
# revision identifiers, used by Alembic. # revision identifiers, used by Alembic.
revision = '063' revision = '063'
down_revision = '062' down_revision = '062'
from alembic import op
def upgrade(active_plugins=None, options=None): def upgrade(active_plugins=None, options=None):
op.create_index('story_storytags_idx', op.create_index('story_storytags_idx',
'story_storytags', ['story_id']) 'story_storytags', ['story_id'])

View File

@ -19,15 +19,16 @@ Create Date: 2019-03-04 16:24:44.264120
""" """
# revision identifiers, used by Alembic.
revision = '064'
down_revision = '063'
from alembic import op from alembic import op
import sqlalchemy as sa import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '064'
down_revision = '063'
def upgrade(active_plugins=None, options=None): def upgrade(active_plugins=None, options=None):
op.add_column('teams', sa.Column('security', sa.Boolean(), nullable=True)) op.add_column('teams', sa.Column('security', sa.Boolean(), nullable=True))

View File

@ -19,15 +19,16 @@ Create Date: 2019-03-07 11:25:31.308033
""" """
# revision identifiers, used by Alembic.
revision = '065'
down_revision = '064'
from alembic import op from alembic import op
import sqlalchemy as sa import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '065'
down_revision = '064'
def upgrade(active_plugins=None, options=None): def upgrade(active_plugins=None, options=None):
op.create_table('project_teams', op.create_table('project_teams',
sa.Column('project_id', sa.Integer(), nullable=False), sa.Column('project_id', sa.Integer(), nullable=False),

View File

@ -19,15 +19,16 @@ Create Date: 2019-03-08 08:57:44.497977
""" """
# revision identifiers, used by Alembic.
revision = '066'
down_revision = '065'
from alembic import op from alembic import op
import sqlalchemy as sa import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '066'
down_revision = '065'
def upgrade(active_plugins=None, options=None): def upgrade(active_plugins=None, options=None):
op.add_column('stories', sa.Column('security', sa.Boolean())) op.add_column('stories', sa.Column('security', sa.Boolean()))

View File

@ -19,10 +19,6 @@ Create Date: 2019-01-27 16:07:04.427155
""" """
# revision identifiers, used by Alembic.
revision = '067'
down_revision = '066'
from alembic import op from alembic import op
from oslo_log import log from oslo_log import log
@ -30,6 +26,11 @@ import sqlalchemy as sa
import storyboard import storyboard
# revision identifiers, used by Alembic.
revision = '067'
down_revision = '066'
LOG = log.getLogger(__name__) LOG = log.getLogger(__name__)

View File

@ -58,6 +58,7 @@ def table_args():
'mysql_charset': "utf8mb4"} 'mysql_charset': "utf8mb4"}
return None return None
# # CUSTOM TYPES # # CUSTOM TYPES
# A mysql medium text type. # A mysql medium text type.
@ -664,6 +665,7 @@ class Board(FullText, ModelBuilder, Base):
_public_fields = ["id", "title", "description", "creator_id", _public_fields = ["id", "title", "description", "creator_id",
"project_id", "permission_id", "private", "archived"] "project_id", "permission_id", "private", "archived"]
board_permissions = Table( board_permissions = Table(
'board_permissions', Base.metadata, 'board_permissions', Base.metadata,
Column('board_id', Integer, ForeignKey('boards.id')), Column('board_id', Integer, ForeignKey('boards.id')),
@ -701,6 +703,7 @@ class DueDate(FullText, ModelBuilder, Base):
secondary='worklist_due_dates', secondary='worklist_due_dates',
backref='due_dates') backref='due_dates')
due_date_permissions = Table( due_date_permissions = Table(
'due_date_permissions', Base.metadata, 'due_date_permissions', Base.metadata,
Column('due_date_id', Integer, ForeignKey('due_dates.id')), Column('due_date_id', Integer, ForeignKey('due_dates.id')),

View File

@ -72,7 +72,7 @@ def main():
session.execute('ALTER TABLE stories AUTO_INCREMENT = %d;' session.execute('ALTER TABLE stories AUTO_INCREMENT = %d;'
% (auto_increment,)) % (auto_increment,))
if CONF.origin is 'launchpad': if CONF.origin == 'launchpad':
loader = LaunchpadLoader(CONF.from_project, CONF.to_project, loader = LaunchpadLoader(CONF.from_project, CONF.to_project,
set(CONF.only_tags), set(CONF.exclude_tags)) set(CONF.only_tags), set(CONF.exclude_tags))
loader.run() loader.run()

View File

@ -79,8 +79,8 @@ class LaunchpadLoader(object):
branch_name = url_parts[-1].lower() branch_name = url_parts[-1].lower()
project_name = url_parts[-2] project_name = url_parts[-2]
if (branch_name in releases and if (branch_name in releases
project_name == self.reader.project_name): and project_name == self.reader.project_name):
branches.append(branch_name) branches.append(branch_name)
elif branch_name == self.reader.project_name: elif branch_name == self.reader.project_name:
branches.append('master') branches.append('master')

View File

@ -140,8 +140,8 @@ class NotificationHook(hooks.PecanHook):
return None return None
def parse(self, s): def parse(self, s):
url_pattern = re.match("^(\/api)?\/v1\/([a-z_]+)\/?([0-9]+)?" url_pattern = re.match(r"^(/api)?/v1/([a-z_]+)/?([0-9]+)?"
"\/?([a-z]+)?\/?([0-9]+)?$", s) r"/?([a-z]+)?/?([0-9]+)?$", s)
if not url_pattern or url_pattern.groups()[1] == "openid": if not url_pattern or url_pattern.groups()[1] == "openid":
return None, None, None, None return None, None, None, None

View File

@ -400,7 +400,7 @@ class SubscriptionEmailWorker(EmailWorkerBase):
/{{resource_name}}/{{subresource_name}}/{{method}}.txt /{{resource_name}}/{{subresource_name}}/{{method}}.txt
/{{resource_name}}/{{subresource_name}}/{{method}}.html (optional) /{{resource_name}}/{{subresource_name}}/{{method}}.html (optional)
""" """
## TODO(krotscheck): Templates can also resolve by user language. # TODO(krotscheck): Templates can also resolve by user language.
if sub_resource_name: if sub_resource_name:
base_template = os.path.join(resource_name, sub_resource_name) base_template = os.path.join(resource_name, sub_resource_name)

View File

@ -107,8 +107,8 @@ class Subscription(WorkerTaskBase):
user = db_api.entity_get(models.User, user_id, session=session) user = db_api.entity_get(models.User, user_id, session=session)
send_notification = get_preference( send_notification = get_preference(
'receive_notifications_worklists', user) 'receive_notifications_worklists', user)
if (send_notification != 'true' and if (send_notification != 'true'
resource.get('worklist_id') is not None): and resource.get('worklist_id') is not None):
continue continue
if resource['event_type'] == 'user_comment': if resource['event_type'] == 'user_comment':

View File

@ -146,8 +146,8 @@ class TestStories(base.FunctionalTest):
story_types = [2, 1] story_types = [2, 1]
for story_type_id in story_types: for story_type_id in story_types:
response = self.put_json(self.resource + response = self.put_json(self.resource
('/%s' % created_story["id"]), + ('/%s' % created_story["id"]),
{'story_type_id': story_type_id}) {'story_type_id': story_type_id})
self.assertEqual(story_type_id, response.json['story_type_id']) self.assertEqual(story_type_id, response.json['story_type_id'])
@ -164,8 +164,8 @@ class TestStories(base.FunctionalTest):
self.assertEqual(story['private'], self.assertEqual(story['private'],
created_story['private']) created_story['private'])
response = self.put_json(self.resource + response = self.put_json(self.resource
('/%s' % created_story['id']), + ('/%s' % created_story['id']),
{'private': False}) {'private': False})
updated_story = response.json updated_story = response.json
self.assertFalse(updated_story['private']) self.assertFalse(updated_story['private'])

View File

@ -74,8 +74,9 @@ class TestSubscriptionsAsUser(base.FunctionalTest):
search_response_1 = self.get_json(self.resource) search_response_1 = self.get_json(self.resource)
self.assertEqual(1, len(search_response_1)) self.assertEqual(1, len(search_response_1))
response2 = self.delete(self.resource + '/' + response2 = self.delete(self.resource
six.text_type(subscription['id']), + '/'
+ six.text_type(subscription['id']),
expect_errors=True) expect_errors=True)
self.assertEqual(204, response2.status_code) self.assertEqual(204, response2.status_code)
@ -106,16 +107,16 @@ class TestSubscriptionsAsUser(base.FunctionalTest):
response = self.get_json(self.resource) response = self.get_json(self.resource)
self.assertEqual(1, len(response)) self.assertEqual(1, len(response))
response = self.get_json(self.resource + response = self.get_json(self.resource
'?target_type=project') + '?target_type=project')
self.assertEqual(1, len(response)) self.assertEqual(1, len(response))
response = self.get_json(self.resource + response = self.get_json(self.resource
'?target_type=project&target_id=1') + '?target_type=project&target_id=1')
self.assertEqual(1, len(response)) self.assertEqual(1, len(response))
response = self.get_json(self.resource + response = self.get_json(self.resource
'?target_type=story&target_id=1') + '?target_type=story&target_id=1')
self.assertEqual(0, len(response)) self.assertEqual(0, len(response))
def test_create_subscription_for_invalid_resource(self): def test_create_subscription_for_invalid_resource(self):
@ -216,8 +217,9 @@ class TestSubscriptionsAsSuperuser(base.FunctionalTest):
search_response_1 = self.get_json(self.resource + '?user_id=3') search_response_1 = self.get_json(self.resource + '?user_id=3')
self.assertEqual(2, len(search_response_1)) self.assertEqual(2, len(search_response_1))
response2 = self.delete(self.resource + '/' + response2 = self.delete(self.resource
six.text_type(subscription['id']), + '/'
+ six.text_type(subscription['id']),
expect_errors=True) expect_errors=True)
self.assertEqual(204, response2.status_code) self.assertEqual(204, response2.status_code)

View File

@ -56,8 +56,9 @@ class TestUserTokensAsUser(base.FunctionalTest):
self.assertEqual(response.json['access_token'], 'test_token') self.assertEqual(response.json['access_token'], 'test_token')
self.assertIsNotNone(response.json['id']) self.assertIsNotNone(response.json['id'])
read_response = self.get_json(self.resource + '/' + read_response = self.get_json(self.resource
six.text_type(response.json['id'])) + '/'
+ six.text_type(response.json['id']))
self.assertEqual(response.json['user_id'], self.assertEqual(response.json['user_id'],
read_response['user_id']) read_response['user_id'])
@ -124,8 +125,9 @@ class TestUserTokensAsUser(base.FunctionalTest):
new_record['expires_in'] = 3601 new_record['expires_in'] = 3601
updated = self.put_json(self.resource + '/' + updated = self.put_json(self.resource
six.text_type(response.json['id']), + '/'
+ six.text_type(response.json['id']),
new_record, expect_errors=True) new_record, expect_errors=True)
self.assertEqual(updated.json['expires_in'], 3601) self.assertEqual(updated.json['expires_in'], 3601)
@ -142,8 +144,9 @@ class TestUserTokensAsUser(base.FunctionalTest):
self.assertIsNotNone(response.json['access_token']) self.assertIsNotNone(response.json['access_token'])
self.assertIsNotNone(response.json['id']) self.assertIsNotNone(response.json['id'])
response = self.delete(self.resource + '/' + response = self.delete(self.resource
six.text_type(response.json['id']), + '/'
+ six.text_type(response.json['id']),
expect_errors=True) expect_errors=True)
self.assertEqual(204, response.status_code) self.assertEqual(204, response.status_code)

View File

@ -214,6 +214,7 @@ class DbTestCase(WorkingDirTestCase):
cls.db_name, err) cls.db_name, err)
db_api_base.cleanup() db_api_base.cleanup()
PATH_PREFIX = '/v1' PATH_PREFIX = '/v1'

View File

@ -70,6 +70,7 @@ class DummySMTP_SSL(DummySMTP):
def _get_socket(self, host, port, timeout): def _get_socket(self, host, port, timeout):
return None return None
# Monkeypatch our SMTP Instances. # Monkeypatch our SMTP Instances.
smtplib.SMTP = DummySMTP smtplib.SMTP = DummySMTP
smtplib.SMTP_SSL = DummySMTP_SSL smtplib.SMTP_SSL = DummySMTP_SSL

View File

@ -1,4 +1,4 @@
hacking>=1.0.0,<1.1.0 hacking>=1.0.0
coverage!=4.4,>=4.0 # Apache-2.0 coverage!=4.4,>=4.0 # Apache-2.0
fixtures>=3.0.0 # Apache-2.0/BSD fixtures>=3.0.0 # Apache-2.0/BSD

View File

@ -93,5 +93,6 @@ def start():
srv = simple_server.make_server('0.0.0.0', 8088, api_root) srv = simple_server.make_server('0.0.0.0', 8088, api_root)
srv.serve_forever() srv.serve_forever()
if __name__ == '__main__': if __name__ == '__main__':
start() start()

View File

@ -26,8 +26,8 @@ DB_PW=openstack_citest
sudo -H mysql -u root -p$DB_ROOT_PW -h localhost -e " sudo -H mysql -u root -p$DB_ROOT_PW -h localhost -e "
DELETE FROM mysql.user WHERE User=''; DELETE FROM mysql.user WHERE User='';
FLUSH PRIVILEGES; FLUSH PRIVILEGES;
GRANT ALL PRIVILEGES ON *.* CREATE USER '$DB_USER'@'%' IDENTIFIED BY '$DB_PW';
TO '$DB_USER'@'%' identified by '$DB_PW' WITH GRANT OPTION;" GRANT ALL PRIVILEGES ON *.* TO '$DB_USER'@'%' WITH GRANT OPTION;"
# Now create our database. # Now create our database.
mysql -u $DB_USER -p$DB_PW -h 127.0.0.1 -e " mysql -u $DB_USER -p$DB_PW -h 127.0.0.1 -e "

View File

@ -50,11 +50,12 @@ commands =
[flake8] [flake8]
# E125 and E128 are ignored on purpose, they are invalid pep8 # E125 and E128 are ignored on purpose, they are invalid pep8
# W503 is ignored on purpose, it is no longer valid pep8
# The following rules should either be addressed or determined to be # The following rules should either be addressed or determined to be
# skippable long term. # skippable long term.
# E265 is ignored to make switch to newer hacking easier # E265 is ignored to make switch to newer hacking easier
# H405 is ignored to make switch to newer hacking easier # H405 is ignored to make switch to newer hacking easier
ignore = E125,E128,E265,H405 ignore = E125,E128,E265,H405,W503
builtins = _ builtins = _
show-source = True show-source = True
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build