<commit_before># -*- coding: utf8 -*-
# This file is part of PyBossa.
#
# Copyright (C) 2013 SF Isle of Man Limited
#
# PyBossa is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# PyBossa is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with PyBossa.  If not, see <http://www.gnu.org/licenses/>.

from helper import sched
from base import Fixtures, redis_flushall, model
import json


class TestSched(sched.Helper):
    def setUp(self):
        super(TestSched, self).setUp()
        self.endpoints = ['app', 'task', 'taskrun']

    def tearDown(self):
        model.rebuild_db()
        redis_flushall()

    # Tests
    def test_incremental_tasks(self):
        """ Test incremental SCHED strategy - second TaskRun receives first gaven answer"""
        redis_flushall()
        Fixtures.create_2(sched='incremental')

        # Del previous TaskRuns
        self.del_task_runs()

        # Register
        self.register(fullname=self.user.fullname, username=self.user.username,
                      password=self.user.password)
        self.register(fullname="<NAME>", username="mariedoe", password="<PASSWORD>")
        self.signin()

        # Get the only task with no runs!
        res = self.app.get('api/app/1/newtask')
        data = json.loads(res.data)
        # Check that we received a clean Task<commit_msg>Refactor<commit_after># -*- coding: utf8 -*-
# This file is part of PyBossa.
#
# Copyright (C) 2013 SF Isle of Man Limited
#
# PyBossa is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# PyBossa is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with PyBossa.  If not, see <http://www.gnu.org/licenses/>.

from helper import sched
from default import with_context
import json


class TestSched(sched.Helper):
    def setUp(self):
        super(TestSched, self).setUp()
        self.endpoints = ['app', 'task', 'taskrun']

    # Tests
    @with_context
    def test_incremental_tasks(self):
        """ Test incremental SCHED strategy - second TaskRun receives first gaven answer"""
        self.create_2(sched='incremental')

        # Del previous TaskRuns
        self.del_task_runs()

        # Register
        self.register(fullname=self.user.fullname, username=self.user.username,
                      password=self.user.password)
        self.register(fullname="<NAME>", username="mariedoe", password="<PASSWORD>")
        self.signin()

        # Get the only task with no runs!
        res = self.app.get('api/app/1/newtask')
        data = json.loads(res.data)
        # Check that we received a clean Task
{'fraction_non_alphanumeric': 0.09211666185388391, 'fraction_numerical': 0.004620271440947156, 'mean_word_length': 3.0994082840236685, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4641669', 'n_tokens_mistral': 994, 'n_tokens_neox': 952, 'n_words': 367}