diff options
Diffstat (limited to 'tests/managers')
| -rw-r--r-- | tests/managers/amt.py | 22 | ||||
| -rw-r--r-- | tests/managers/hit.py | 25 | ||||
| -rw-r--r-- | tests/managers/test_amt.py | 36 | ||||
| -rw-r--r-- | tests/managers/test_hit.py | 52 |
4 files changed, 88 insertions, 47 deletions
diff --git a/tests/managers/amt.py b/tests/managers/amt.py deleted file mode 100644 index a847582..0000000 --- a/tests/managers/amt.py +++ /dev/null @@ -1,22 +0,0 @@ -from jb.managers.amt import AMTManager - - -def test_create_hit_type(hit_type): - 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(hqm, htm, hm, hit_type_with_amt_id, question): - question = hqm.get_or_create(question) - - hit_type = hit_type_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) - assert hit.amt_hit_id is not None - assert hit.id is None - hm.create(hit) - assert hit.id is not None diff --git a/tests/managers/hit.py b/tests/managers/hit.py deleted file mode 100644 index cb2b35a..0000000 --- a/tests/managers/hit.py +++ /dev/null @@ -1,25 +0,0 @@ -from jb.models import Question - - -class TestHitQuestionManager: - - def test_base(self, question_record): - assert isinstance(question_record, Question) - assert question_record.id is None - - -class TestHitTypeManager: - - def test_create(self, htm, hit_type_with_amt_id): - assert hit_type_with_amt_id.id is None - htm.create(hit_type_with_amt_id) - assert hit_type_with_amt_id.id is not None - - res = htm.filter_active() - assert len(res) == 1 - - hit_type_with_amt_id.min_active = 0 - htm.set_min_active(hit_type_with_amt_id) - - res = htm.filter_active() - assert len(res) == 0 diff --git a/tests/managers/test_amt.py b/tests/managers/test_amt.py new file mode 100644 index 0000000..63d3737 --- /dev/null +++ b/tests/managers/test_amt.py @@ -0,0 +1,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 diff --git a/tests/managers/test_hit.py b/tests/managers/test_hit.py new file mode 100644 index 0000000..56a4f53 --- /dev/null +++ b/tests/managers/test_hit.py @@ -0,0 +1,52 @@ +from jb.models.hit import HitQuestion, HitType, Hit +from jb.managers.hit import HitTypeManager, HitManager + + +class TestHitQuestionManager: + + def test_base(self, question_record: HitQuestion): + assert isinstance(question_record, HitQuestion) + assert isinstance(question_record.id, int) + + +class TestHitTypeManager: + + def test_create(self, htm: HitTypeManager, hit_type_record_with_amt_id: HitType): + + _ = hit_type_record_with_amt_id + + assert isinstance(hit_type_record_with_amt_id.id, int) + assert isinstance(hit_type_record_with_amt_id.amt_hit_type_id, str) + + count1 = len(htm.filter_active()) + # assert count1 == 1 + + hit_type_record_with_amt_id.min_active = 0 + htm.set_min_active(hit_type=hit_type_record_with_amt_id) + + count2 = len(htm.filter_active()) + assert count2 == 0 + + +class TestHitManager: + + # def test_create + + # def update_status + + # def update_hit + + # def get_from_amt_id + + # get_from_amt_id_if_exists + + def test_get_active_count(self, hm: HitManager, hit_record: Hit): + + count = hm.get_active_count(hit_type_id=999_999_999) + assert isinstance(count, int) + assert count == 0 + + count = hm.get_active_count(hit_type_id=hit_record.hit_type_id) + assert count == 1 + + # filter_active_ids |
