tests.py 832 B

12345678910111213141516171819202122232425
  1. from django.test import TestCase
  2. # Create your tests here.
  3. class CrawlActorTest(TestCase):
  4. def test_crawl_creation(self):
  5. seed = Seed.objects.create(uri='https://example.com')
  6. Event.dispatch('CRAWL_CREATE', {'seed_id': seed.id})
  7. crawl_actor = CrawlActor()
  8. output_events = list(crawl_actor.process_next_event())
  9. assert len(output_events) == 1
  10. assert output_events[0].get('name', 'unset') == 'FS_WRITE'
  11. assert output_events[0].get('path') == '/tmp/test_crawl/index.json'
  12. output_events = list(crawl_actor.process_next_event())
  13. assert len(output_events) == 1
  14. assert output_events[0].get('name', 'unset') == 'CRAWL_CREATED'
  15. assert Crawl.objects.filter(seed_id=seed.id).exists(), 'Crawl was not created'