Add test sources for the tt* fields
This commit is contained in:
parent
49fa1cf8df
commit
098f97f4d9
|
@ -145,6 +145,7 @@ def populate_new(source_name, item):
|
|||
if 'id' not in item:
|
||||
raise Exception(f'Source "{source_name}" returned an item with no id')
|
||||
# source is auto-populated with the source name if missing
|
||||
# Note: this allows sources to create items in other cells!
|
||||
if 'source' not in item: item['source'] = source_name
|
||||
# active is forced to True for new items
|
||||
item['active'] = True
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
"""
|
||||
Generates a dummy item.
|
||||
"""
|
||||
# Standard library imports
|
||||
from datetime import datetime
|
||||
import random
|
||||
|
||||
def fetch_new(state):
|
||||
item = {
|
||||
'source': "dummy",
|
||||
'id': '{:x}'.format(random.getrandbits(16 * 4)),
|
||||
'title': str(datetime.now()),
|
||||
}
|
||||
return [item]
|
|
@ -1,17 +0,0 @@
|
|||
"""
|
||||
An example itemsource that produces an item with the current date.
|
||||
Fetch new items with `python inquisitor update --sources example`
|
||||
"""
|
||||
# Standard library imports
|
||||
from datetime import date
|
||||
import time
|
||||
|
||||
|
||||
def fetch_new(state):
|
||||
now = date.today()
|
||||
item = {
|
||||
'source': "example",
|
||||
'id': '{}-{}-{}'.format(now.year, now.month, now.day),
|
||||
'title': "Today is {}-{}-{}".format(now.year, now.month, now.day),
|
||||
}
|
||||
return [item]
|
|
@ -0,0 +1,17 @@
|
|||
"""
|
||||
Demonstrates the behavior of the time-to-die item field.
|
||||
On update, this source creates a new item with a ttd of 30 in the cell
|
||||
for the source ttddemoupd.
|
||||
"""
|
||||
# Standard library imports
|
||||
from datetime import datetime
|
||||
import random
|
||||
|
||||
def fetch_new(state):
|
||||
item = {
|
||||
'source': "ttddemoupd",
|
||||
'id': '{:x}'.format(random.getrandbits(16 * 4)),
|
||||
'title': f"This item was created at {datetime.now()}",
|
||||
'ttd': 30,
|
||||
}
|
||||
return [item]
|
|
@ -0,0 +1,12 @@
|
|||
"""
|
||||
Demonstrates the behavior of the time-to-die item field.
|
||||
This source does not generate items. It is solely for use with the
|
||||
ttddemogen source, which creats new items for it. This source can be
|
||||
updated to cause a ttd check on the item created by ttddemogen.
|
||||
"""
|
||||
# Standard library imports
|
||||
from datetime import datetime
|
||||
import random
|
||||
|
||||
def fetch_new(state):
|
||||
return []
|
|
@ -0,0 +1,17 @@
|
|||
"""
|
||||
Demonstrates the behavior of the time-to-live item field.
|
||||
On update, this source creates a new item with a ttl of 30 in the cell
|
||||
for the source ttldemoupd.
|
||||
"""
|
||||
# Standard library imports
|
||||
from datetime import datetime
|
||||
import random
|
||||
|
||||
def fetch_new(state):
|
||||
item = {
|
||||
'source': "ttldemoupd",
|
||||
'id': '{:x}'.format(random.getrandbits(16 * 4)),
|
||||
'title': f"This item was created at {datetime.now()}",
|
||||
'ttl': 30,
|
||||
}
|
||||
return [item]
|
|
@ -0,0 +1,13 @@
|
|||
"""
|
||||
Demonstrates the behavior of the time-to-live item field.
|
||||
This source does not generate items. It is solely for use with the
|
||||
ttldemogen source, which creats new items for it. This source can be
|
||||
updated to cause a removal check on inactive items created by
|
||||
ttldemogen.
|
||||
"""
|
||||
# Standard library imports
|
||||
from datetime import datetime
|
||||
import random
|
||||
|
||||
def fetch_new(state):
|
||||
return []
|
|
@ -0,0 +1,16 @@
|
|||
"""
|
||||
Demonstrates the behavior of the time-to-show item field.
|
||||
On update, this source returns a new item with a tts of 30 seconds.
|
||||
"""
|
||||
# Standard library imports
|
||||
from datetime import datetime
|
||||
import random
|
||||
|
||||
def fetch_new(state):
|
||||
item = {
|
||||
'source': "ttsdemo",
|
||||
'id': '{:x}'.format(random.getrandbits(16 * 4)),
|
||||
'title': f"This item was created at {datetime.now()}",
|
||||
'tts': 30,
|
||||
}
|
||||
return [item]
|
Loading…
Reference in New Issue