# Path: psiturk/psiturk_statuses.py
# NOT_ACCEPTED = 0
# ALLOCATED = 1
# STARTED = 2
# COMPLETED = 3
# SUBMITTED = 4
# CREDITED = 5
# QUITEARLY = 6
# BONUSED = 7


from builtins import range
from builtins import object
from unittest import mock
from unittest.mock import patch, PropertyMock
from botocore.stub import ANY
from importlib import reload
from psiturk import psiturk_statuses
from psiturk.psiturk_exceptions import *
        from psiturk.models import Hit
        from psiturk.psiturk_config import PsiturkConfig
        from psiturk.db import db_session
        from psiturk.models import Hit
        from psiturk.db import db_session
import pytest
import pickle
import os
import boto3
import datetime
import ciso8601
        # unreject all for a given hit across all studies
        prep_list_hits()
        number_to_be_unrejected = prep_operation_all_for_hit(
            'approve_assignment')
        results = (amt_services_wrapper.unreject_assignments_for_hit(
            'abc', all_studies=True)).data['results']
        assert len(results) == number_to_be_unrejected
        for result in results:
            assert result.status == 'success'

    def test_wrapper_bonus_assignment(self, create_dummy_assignment, amt_services_wrapper, stubber):


        # ## filters
        # with hit_id
        hit_id = '123'
        # amount = 0.01
        amount = 'auto'
        reason = 'yee'
        override_bonused_status = False

        def edit_assignment(assignment, new_config):
            for k, v in list(new_config.items()):
                setattr(assignment, k, v)
            db_session.add(assignment)
            db_session.commit()

        assignment_1 = create_dummy_assignment({'hitid': hit_id})
        assignment_2 = create_dummy_assignment({'hitid': hit_id})
        edit_assignment(assignment_1, {'status': psiturk_statuses.BONUSED})

# Path: psiturk/psiturk_statuses.py
# NOT_ACCEPTED = 0
# ALLOCATED = 1
# STARTED = 2
# COMPLETED = 3
# SUBMITTED = 4
# CREDITED = 5
# QUITEARLY = 6
# BONUSED = 7


# Path: tests/test_amt.py
from builtins import range
from builtins import object
from unittest import mock
from unittest.mock import patch, PropertyMock
from botocore.stub import ANY
from importlib import reload
from psiturk import psiturk_statuses
from psiturk.psiturk_exceptions import *
        from psiturk.models import Hit
        from psiturk.psiturk_config import PsiturkConfig
        from psiturk.db import db_session
        from psiturk.models import Hit
        from psiturk.db import db_session
import pytest
import pickle
import os
import boto3
import datetime
import ciso8601

        # unreject all for a given hit across all studies
        prep_list_hits()
        number_to_be_unrejected = prep_operation_all_for_hit(
            'approve_assignment')
        results = (amt_services_wrapper.unreject_assignments_for_hit(
            'abc', all_studies=True)).data['results']
        assert len(results) == number_to_be_unrejected
        for result in results:
            assert result.status == 'success'

    def test_wrapper_bonus_assignment(self, create_dummy_assignment, amt_services_wrapper, stubber):


        # ## filters
        # with hit_id
        hit_id = '123'
        # amount = 0.01
        amount = 'auto'
        reason = 'yee'
        override_bonused_status = False

        def edit_assignment(assignment, new_config):
            for k, v in list(new_config.items()):
                setattr(assignment, k, v)
            db_session.add(assignment)
            db_session.commit()

        assignment_1 = create_dummy_assignment({'hitid': hit_id})
        assignment_2 = create_dummy_assignment({'hitid': hit_id})
        edit_assignment(assignment_1, {'status': psiturk_statuses.BONUSED})

        edit_assignment(assignment_2, {'status': psiturk_statuses.BONUSED})