Repository: smicallef/spiderfoot
File: test/unit/modules/test_sfp_debounce.py (Python)

Code before:
        '__logstdout': False
    }

    def test_opts(self):
        module = sfp_debounce()
        self.assertEqual(len(module.opts), len(module.optdescs))

    def test_setup(self):
        """
        Test setup(self, sfc, userOpts=dict())
        """
        sf = SpiderFoot(self.default_options)

        module = sfp_debounce()
        module.setup(sf, dict())

    def test_watchedEvents_should_return_list(self):
        module = sfp_debounce()
        self.assertIsInstance(module.watchedEvents(), list)

    def test_producedEvents_should_return_list(self):
        module = sfp_debounce()
        self.assertIsInstance(module.producedEvents(), list)

    def test_handleEvent(self):
        """
        Test handleEvent(self, event)
        """
        sf = SpiderFoot(self.default_options)

        module = sfp_debounce()
        module.setup(sf, dict())

        target_value = 'example target value'
        target_type = 'EMAILADDR'
        target = SpiderFootTarget(target_value, target_type)
        module.setTarget(target)

        event_type = 'ROOT'
        event_data = 'example data'
        event_module = ''
        source_event = ''
        evt = SpiderFootEvent(event_type, event_data, event_module, source_event)

        result = module.handleEvent(evt)

        self.assertIsNone(result)


Review comment (bug):
```suggestion
    @unittest.skip("todo")
    def test_handleEvent(self):
```

The tests are failing due to the code pattern used in the unit test.

```
test/unit/modules/test_sfp_debounce.py:77: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

modules/sfp_debounce.py:99: in handleEvent

    data = self.queryEmailAddr(eventData)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <modules.sfp_debounce.sfp_debounce object at 0x7f6df8370700>

qry = 'example data'

    def queryEmailAddr(self, qry):

        res = self.sf.fetchUrl(

            f"https://disposable.debounce.io?email={qry}",

>           timeout=self.opts['_fetchtimeout'],

            useragent="SpiderFoot"

        )

E       KeyError: '_fetchtimeout'

modules/sfp_debounce.py:71: KeyError
```

The easiest way to fix this, for now, is to mark the test to be skipped.


Code after:
        '__logstdout': False
    }

    def test_opts(self):
        module = sfp_debounce()
        self.assertEqual(len(module.opts), len(module.optdescs))

    def test_setup(self):
        """
        Test setup(self, sfc, userOpts=dict())
        """
        sf = SpiderFoot(self.default_options)

        module = sfp_debounce()
        module.setup(sf, dict())

    def test_watchedEvents_should_return_list(self):
        module = sfp_debounce()
        self.assertIsInstance(module.watchedEvents(), list)

    def test_producedEvents_should_return_list(self):
        module = sfp_debounce()
        self.assertIsInstance(module.producedEvents(), list)

    @unittest.skip("todo")
    def test_handleEvent(self):
        """
        Test handleEvent(self, event)
        """
        sf = SpiderFoot(self.default_options)

        module = sfp_debounce()
        module.setup(sf, dict())

        target_value = 'example target value'
        target_type = 'EMAILADDR'
        target = SpiderFootTarget(target_value, target_type)
        module.setTarget(target)

        event_type = 'ROOT'
        event_data = 'example data'
        event_module = ''
        source_event = ''
        evt = SpiderFootEvent(event_type, event_data, event_module, source_event)

        result = module.handleEvent(evt)

        self.assertIsNone(result)