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

hande more strikethrough cases #145

Merged
merged 8 commits into from
Jun 30, 2021
Merged
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
3 changes: 1 addition & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ multi_line_output=5
[tool:pytest]
testpaths = tests src
norecursedirs = .env .github .vscode
show_capture = True
minversion = 3.5
console_output_style = count
addopts = --pylint --cov-branch --cov=conductor --cov-report term --cov-report xml:cov.xml --instafail --isort
addopts = --pylint --cov-branch --cov=conductor --cov-report term --cov-report xml:cov.xml --instafail --isort --show-capture all
filterwarnings =
ignore:Call to deprecated create function FieldDescriptor
ignore:Call to deprecated create function Descriptor
Expand Down
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
install_requires=[
'colorama==0.*',
'docopt==0.*',
'flask==1.*',
'psycopg2-binary==2.*',
'PyGithub==1.*',
'pygsheets==2.*',
Expand All @@ -44,19 +45,19 @@
extras_require={
'cloud-run': [
'flask==1.*',
'google-cloud-secret-manager==1.*',
'google-cloud-secret-manager==2.5.*',
'gunicorn==20.*',
],
'tests': [
'pylint-quotes==0.2.*',
'pylint==2.*',
'pytest-cov==2.*',
'pytest-instafail==0.4.*',
'pytest-isort==1.*',
'pytest-isort==2.*',
'pytest-mock==3.*',
'pytest-pylint==0.17.*',
'pytest-watch==4.*',
'pytest==5.*',
'pytest==6.*',
'yapf==0.*',
]
},
Expand Down
12 changes: 6 additions & 6 deletions src/conductor/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ def create_client_with_secret_manager(project, secret_name):
"""
client = secretmanager.SecretManagerServiceClient()
name = client.secret_version_path(project, secret_name, 'latest')
secrets = client.access_secret_version(name)
secrets = client.access_secret_version(request = {'name': name})

if secrets is None:
raise Exception('The project secret might not exist or is incorrect; Could not create client.')
Expand Down Expand Up @@ -488,18 +488,18 @@ def get_users_task_statuses(issue_body):
the number of completed tasks
"""
users = {}
expression = r'(?P<strikethrough>~?)- \[(?P<is_completed>[x| ]?)\] .* \(*?(?P<user>@..*?\b).*\)'
expression = r'\s- \[(?P<is_completed>[x| ]?)\] .* \(*?(?P<user>@..*?\b).*\)~?'
strike_expression = r'~.*~'

for match in re.finditer(expression, issue_body, re.MULTILINE):
user = match.group('user')
if match.group('strikethrough') or user == '@assigned':
if re.search(strike_expression, match.group()) or user == '@assigned':
continue
is_complete = match.group('is_completed').strip().lower() == 'x' or len(match.group('strikethrough')) > 0
is_complete = match.group('is_completed').strip().lower() == 'x'
users.setdefault(user, []).append(is_complete)

tasks = []
for user in users:
task_results = users[user]
for user, task_results in users.items():
tasks.append((user, len(task_results), task_results.count(True)))

return tasks
2 changes: 1 addition & 1 deletion src/conductor/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def schedule():

client = secretmanager.SecretManagerServiceClient()
name = client.secret_version_path(PROD_PROJECT, 'conductor-connections', 'latest')
secrets = client.access_secret_version(name)
secrets = client.access_secret_version(request = {'name': name})
secrets = json.loads(secrets.payload.data.decode('UTF-8'))
secrets['client_builder'] = lambda: GSheetChecker.create_client_with_secret_manager(PROD_PROJECT, 'stewardship-sa')

Expand Down
1 change: 1 addition & 0 deletions tests/data/tasks_issue_body_mock_strikethrough.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ When the champion from your team has completed the triage, check [x] the checkbo
- [ ] Dev Team Triage (@steveoh)
~- [ ] Cadastre Team Triage (@rkelson)~
-~ [ ] Cadastre Team Triage (@rkelson)~
- [ ] ~Cadastre Team Triage (@rkelson)~

# We are introducing data

Expand Down
2 changes: 1 addition & 1 deletion tests/test_conductor.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from conductor.checks import GSheetChecker, MetaTableChecker, TableChecker, UrlChecker
from conductor.connections_sample import SECRETS

REQUESTER = Requester('token', None, None, 'http://gis.utah.gov', 0, 'client-id', 'secret', '', 1, False, {})
REQUESTER = Requester('token', None, None, 'http://gis.utah.gov', 0, 'client-id', 'secret', '', 1, False)


def noop():
Expand Down
1 change: 0 additions & 1 deletion tests/test_task_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
A module that contains tests for the TaskChecker module.
"""

from collections import namedtuple
from pathlib import Path

from conductor.checks import TaskChecker, get_users_task_statuses
Expand Down