Skip to content

Commit

Permalink
Increase test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
drew2a committed May 11, 2023
1 parent c9dab69 commit 989efb8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,15 @@ def query(_start, _end):
@db_session(serializable=True)
def process_queue(self) -> int:
processed = 0
added = 0
try:
while title := self.queue.get_nowait():
self.process_torrent_title(title.infohash, title.title)
added += self.process_torrent_title(title.infohash, title.title)
processed += 1
except queue.Empty:
pass
if processed:
self.logger.info(f'Processed {processed} titles from the queue')
self.logger.info(f'Processed: {processed} titles from the queue. Added {added} tags.')
return processed

def put_entity_to_the_queue(self, infohash: Optional[bytes] = None, title: Optional[str] = None):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,13 @@ def test_add_to_queue(tag_rules_processor: KnowledgeRulesProcessor):
assert title.title == 'title'


def test_add_empty_to_queue(tag_rules_processor: KnowledgeRulesProcessor):
"""Test that add_to_queue does not add the empty title to the queue"""
tag_rules_processor.put_entity_to_the_queue(b'infohash', None)

assert tag_rules_processor.queue.qsize() == 0


def test_process_queue(tag_rules_processor: KnowledgeRulesProcessor):
"""Test that process_queue processes the queue"""
tag_rules_processor.put_entity_to_the_queue(b'infohash', 'title')
Expand Down

0 comments on commit 989efb8

Please sign in to comment.