Skip to content

Commit

Permalink
Add time sleep to allow views to catch up
Browse files Browse the repository at this point in the history
  • Loading branch information
udgover committed Nov 13, 2024
1 parent 92094c0 commit aa40d26
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tests/schemas/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,32 +82,35 @@ def test_list_entities(self) -> None:
self.assertEqual(malware_entities[0], self.malware1)

def test_filter_entities(self):
time.sleep(3)
time.sleep(0.5) # wait for views to catch up
entities, total = Entity.filter({"name": "APT123"})
self.assertEqual(len(entities), 1)
self.assertEqual(total, 1)
self.assertEqual(entities[0], self.ta1)

def test_filter_entities_regex(self):
time.sleep(0.5) # wait for views to catch up
entities, total = Entity.filter({"name": "CVE", "title~": "Elite .xploit"})
self.assertEqual(len(entities), 1)
self.assertEqual(total, 1)
self.assertEqual(entities[0], self.vuln1)

def test_filter_entities_by_regex(self):
time.sleep(0.5) # wait for views to catch up
entities, total = Entity.filter({"name~": "APT[0-9]+"})
self.assertEqual(len(entities), 1)
self.assertEqual(total, 1)
self.assertEqual(entities[0], self.ta1)

def test_filter_entities_contain_lowercase(self):
time.sleep(0.5) # wait for views to catch up
entities, total = Entity.filter({"name": "apt"})
self.assertEqual(len(entities), 1)
self.assertEqual(total, 1)
self.assertEqual(entities[0], self.ta1)

def test_filter_entities_time(self):
time.sleep(1) # wait for views to catch up
time.sleep(0.5) # wait for views to catch up
entities, total = Entity.filter({"created": "2020-01-01"})
self.assertEqual(len(entities), 1)
self.assertEqual(total, 1)
Expand Down

0 comments on commit aa40d26

Please sign in to comment.