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

gold task #125

Merged
merged 1 commit into from
Nov 2, 2018
Merged

gold task #125

merged 1 commit into from
Nov 2, 2018

Conversation

dchhabda
Copy link

No description provided.

@coveralls
Copy link

coveralls commented Oct 23, 2018

Pull Request Test Coverage Report for Build 1045

  • 32 of 34 (94.12%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.03%) to 91.868%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pybossa/api/task.py 16 18 88.89%
Totals Coverage Status
Change from base Build 1043: 0.03%
Covered Lines: 12405
Relevant Lines: 13503

💛 - Coveralls

@@ -72,6 +76,13 @@ def _preprocess_post_data(self, data):
if invalid_fields:
raise BadRequest('Missing or incorrect required fields: {}'
.format(','.join(invalid_fields)))
if data.get('gold_answers', None):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can remove None

if data.get('gold_answers', None):
try:
gold_answers = data['gold_answers']
if type(gold_answers) is dict and json.dumps(gold_answers):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the purpose of json.dumps?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for json validity

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What cold go wrong? Isn't the data already parsed from json?

current_user.id in get_project_data(project_id)['owners_ids']):
return data
else:
tmp = copy.deepcopy(data)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why deepcopy?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so as to not update the actual object and pass to regular user an object w/o gold_ans in it

elif headers[idx].endswith('_gold'):
if 'gold_answers' not in task_data:
task_data['gold_answers'] = {}
task_data['gold_answers'][headers[idx].strip('_gold')] = cell
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.strip removes all the characters in the '_gold' string, so that's not what you want here, e.g. 'old_gold'.strip('_gold') == ''

@patch('pybossa.api.task.validate_required_fields')
def test_task_post_api_exceptions(self, inv_field, dup):
"""Get a list of tasks using a list of project_ids."""
[admin, subadminowner, subadmin, reguser] = UserFactory.create_batch(4)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need all these? Looks like only admin and subadminonwner are used

def validate_gold_answers(task):
try:
if task.gold_answers:
json.dumps(task.gold_answers)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needed?

@dchhabda
Copy link
Author

updated

@dchhabda dchhabda merged commit 79272d9 into master Nov 2, 2018
@dchhabda dchhabda deleted the 1287-gold-task branch November 6, 2018 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants