Skip to content

Commit

Permalink
update testing to use parameterised tests and exhaustively test all t…
Browse files Browse the repository at this point in the history
…he background status variations
  • Loading branch information
richard-jones committed Nov 14, 2024
1 parent 46a19b4 commit 5cf7bf0
Show file tree
Hide file tree
Showing 6 changed files with 314 additions and 551 deletions.
8 changes: 5 additions & 3 deletions doajtest/fixtures/background.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,14 @@ def cleanup(self):


def save_mock_bgjob(action=None, status=None, created_before_sec=0, is_save=True,
queue_id=None):
blocking=True, queue_id=None):
bgjob = BackgroundJob()

if action:
if not action:
from portality.tasks.journal_csv import JournalCSVBackgroundTask
bgjob.action = JournalCSVBackgroundTask.__action__
else:
bgjob.action = action

if status:
bgjob._set_with_struct("status", status)
Expand All @@ -69,6 +71,6 @@ def save_mock_bgjob(action=None, status=None, created_before_sec=0, is_save=True
bgjob.queue_id = queue_id

if is_save:
bgjob.save(blocking=True)
bgjob.save(blocking=blocking)

return bgjob
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
test_id,in_queue,oldest_queued,error_count,error_age,lrs_success_or_error,queued,errors,lrs
1,0,young,0,out_of_period,complete,stable,stable,stable
2,0,young,0,out_of_period,error,stable,stable,unstable
3,0,young,0,out_of_period,empty,stable,stable,unstable
4,0,young,1,in_period,complete,stable,unstable,stable
5,0,young,1,in_period,error,stable,unstable,unstable
6,0,young,1,out_of_period,complete,stable,stable,stable
7,0,young,1,out_of_period,error,stable,stable,unstable
8,1,old,0,out_of_period,complete,unstable,stable,stable
9,1,old,0,out_of_period,error,unstable,stable,unstable
10,1,old,0,out_of_period,empty,unstable,stable,unstable
11,1,old,1,in_period,complete,unstable,unstable,stable
12,1,old,1,in_period,error,unstable,unstable,unstable
13,1,old,1,out_of_period,complete,unstable,stable,stable
14,1,old,1,out_of_period,error,unstable,stable,unstable
15,1,young,0,out_of_period,complete,stable,stable,stable
16,1,young,0,out_of_period,error,stable,stable,unstable
17,1,young,0,out_of_period,empty,stable,stable,unstable
18,1,young,1,in_period,complete,stable,unstable,stable
19,1,young,1,in_period,error,stable,unstable,unstable
20,1,young,1,out_of_period,complete,stable,stable,stable
21,1,young,1,out_of_period,error,stable,stable,unstable
22,2,old,0,out_of_period,complete,unstable,stable,stable
23,2,old,0,out_of_period,error,unstable,stable,unstable
24,2,old,0,out_of_period,empty,unstable,stable,unstable
25,2,old,1,in_period,complete,unstable,unstable,stable
26,2,old,1,in_period,error,unstable,unstable,unstable
27,2,old,1,out_of_period,complete,unstable,stable,stable
28,2,old,1,out_of_period,error,unstable,stable,unstable
29,2,young,0,out_of_period,complete,unstable,stable,stable
30,2,young,0,out_of_period,error,unstable,stable,unstable
31,2,young,0,out_of_period,empty,unstable,stable,unstable
32,2,young,1,in_period,complete,unstable,unstable,stable
33,2,young,1,in_period,error,unstable,unstable,unstable
34,2,young,1,out_of_period,complete,unstable,stable,stable
35,2,young,1,out_of_period,error,unstable,stable,unstable
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@ field,test_id,in_queue,oldest_queued,error_count,error_age,lrs_success_or_error,
type,index,generated,generated,generated,generated,generated,conditional,conditional,conditional
default,,,,,,,stable,stable,stable
,,,,,,,,,
values,,0,in_period,0,in_period,success,stable,stable,stable
values,,1,out_of_period,1,out_of_period,error,unstable,unstable,unstable
values,,,,,,empty,,,
values,,0,old,0,in_period,complete,stable,stable,stable
values,,1,young,1,out_of_period,error,unstable,unstable,unstable
values,,2,,,,empty,,,
,,,,,,,,,
constraint event_in_queue,,0,out_of_period,,,,,,
constraint event_error_count,,,,0,out_of_period,,,,
constraint in_queue,,0,young,,,,,,
constraint error_count,,,,0,out_of_period,,,,
constraint error_count,,,,1,,!empty,,,
,,,,,,,,,
conditional queued,,1,in_period,,,,unstable,,
conditional queued,,2,,,,,unstable,,
conditional queued,,,old,,,,unstable,,
conditional errors,,,,1,in_period,,,unstable,
conditional lrs,,,,,,error,,,unstable
conditional lrs,,,,,,error,,,unstable
conditional lrs,,,,,,empty,,,unstable
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
{
"parameters": [
{
"name": "test_id",
"type": "index"
},
{
"name": "in_queue",
"type": "generated",
"values": {
"0": {
"constraints": {
"oldest_queued": {
"or": [
"young"
]
}
}
},
"1": {},
"2": {}
}
},
{
"name": "oldest_queued",
"type": "generated",
"values": {
"old": {},
"young": {}
}
},
{
"name": "error_count",
"type": "generated",
"values": {
"0": {
"constraints": {
"error_age": {
"or": [
"out_of_period"
]
}
}
},
"1": {
"constraints": {
"lrs_success_or_error": {
"nor": [
"empty"
]
}
}
}
}
},
{
"name": "error_age",
"type": "generated",
"values": {
"in_period": {},
"out_of_period": {}
}
},
{
"name": "lrs_success_or_error",
"type": "generated",
"values": {
"complete": {},
"error": {},
"empty": {}
}
},
{
"name": "queued",
"type": "conditional",
"default": "stable",
"values": {
"stable": {},
"unstable": {
"conditions": [
{
"in_queue": {
"or": [
"2"
]
}
},
{
"oldest_queued": {
"or": [
"old"
]
}
}
]
}
}
},
{
"name": "errors",
"type": "conditional",
"default": "stable",
"values": {
"stable": {},
"unstable": {
"conditions": [
{
"error_count": {
"or": [
"1"
]
},
"error_age": {
"or": [
"in_period"
]
}
}
]
}
}
},
{
"name": "lrs",
"type": "conditional",
"default": "stable",
"values": {
"stable": {},
"unstable": {
"conditions": [
{
"lrs_success_or_error": {
"or": [
"error"
]
}
},
{
"lrs_success_or_error": {
"or": [
"empty"
]
}
}
]
}
}
}
]
}
Loading

0 comments on commit 5cf7bf0

Please sign in to comment.