aboutsummaryrefslogtreecommitdiff
path: root/tests/managers/test_amt.py
blob: 63d3737a9ee8cca61e26f5f086789df0fc23db23 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from jb.managers.amt import AMTManager
from jb.models.hit import HitType, HitQuestion

from jb.managers.hit import HitQuestionManager, HitTypeManager, HitManager


class TestAMTManager:

    def test_create_hit_type(self, hit_type: HitType):
        assert hit_type.amt_hit_type_id is None
        AMTManager.create_hit_type(hit_type=hit_type)
        assert hit_type.amt_hit_type_id is not None

    def test_create_hit_with_hit_type(
        self,
        hqm: HitQuestionManager,
        htm: HitTypeManager,
        hm: HitManager,
        hit_type_record_with_amt_id: HitType,
        question_record: HitQuestion,
    ):

        hit_type = hit_type_record_with_amt_id
        hit_type = [
            x
            for x in htm.filter_active()
            if x.amt_hit_type_id == hit_type.amt_hit_type_id
        ][0]

        hit = AMTManager.create_hit_with_hit_type(
            hit_type=hit_type, question=question_record
        )
        assert hit.amt_hit_id is not None
        assert hit.id is None
        hm.create(hit)
        assert hit.id is not None