Esempio n. 1
0
    def test_init_creates_sources_operators_dicts(self, Config):
        attrs = {
            'sources.return_value': [
                ['test-twitter', Mock, {
                    'q': 'test'
                }],
                ['test-rss', Mock, {
                    'url': 'test'
                }],
            ],
            'operators.return_value': [
                ['test-threatkb', Mock, {
                    'url': 'test'
                }],
                ['test-csv', Mock, {
                    'filename': 'test'
                }],
            ],
        }
        Config.return_value.configure_mock(**attrs)

        Config.return_value.state_path.return_value = ":memory:"

        app = threatingestor.Ingestor('test')
        self.assertEqual(app.sources['test-twitter'].q, 'test')
        self.assertEqual(app.operators['test-csv'].filename, 'test')
        self.assertEqual(len(app.sources), 2)
        self.assertEqual(len(app.operators), 2)
Esempio n. 2
0
    def setUp(self, Config):
        mock_source_operator = Mock()
        mock_source_operator.return_value.run.return_value = (1,2)

        Config.return_value.sources.return_value = [
            ['test-twitter', mock_source_operator, {'q': 'test'}],
            ['test-rss', mock_source_operator, {'url': 'test'}],
        ]
        Config.return_value.operators.return_value = [
            ['test-threatkb', mock_source_operator, {'url': 'test'}],
            ['test-csv', mock_source_operator, {'filename': 'test'}],
        ]

        self.app = threatingestor.Ingestor('test')