def test_remove_main(self):
        """Call main."""
        from unittest import mock
        from umbr_api.remove import main

        my_response = FakeResponse("data/templates/remove/case1")

        with mock.patch("requests.request") as mock_requests_post:
            mock_requests_post.return_value = my_response
            main(test_key=FAKE_KEY)
示例#2
0
    def test_add_main(self):
        """Call main."""
        from unittest import mock
        from umbr_api.add import main

        my_response = FakeResponse('data/templates/add/case1')

        with mock.patch('requests.request') as mock_requests_post:
            mock_requests_post.return_value = my_response
            main(test_key=FAKE_KEY)
示例#3
0
    def test_get_fail(self):
        """Call add to fail."""
        from unittest import mock
        import umbr_api

        my_response = FakeResponse('data/templates/get/case2')

        with mock.patch('requests.request') as mock_requests_post:
            mock_requests_post.return_value = my_response
            response = umbr_api.get_list(page=1, limit=201, key=FAKE_KEY)
        assert response.status_code == my_response.status_code
    def test_remove(self):
        """Call main."""
        from unittest import mock
        import umbr_api

        my_response = FakeResponse("data/templates/remove/case1")

        with mock.patch("requests.request") as mock_requests_post:
            mock_requests_post.return_value = my_response
            response = umbr_api.remove(record_id="29765170", key=FAKE_KEY)
        assert response.status_code == my_response.status_code
    def test_recent(self):
        """Call main."""
        from unittest import mock
        from umbr_api.reporting import recent

        my_response = FakeResponse("data/templates/reporting/case3")

        with mock.patch("requests.request") as mock_requests_post:
            mock_requests_post.return_value = my_response
            response = recent("cisco.com", filename="umbrella_example.json")
        assert response.status_code == my_response.status_code
    def test_remove_activity(self):
        """Call main."""
        from unittest import mock
        from umbr_api.reporting import activity

        my_response = FakeResponse("data/templates/reporting/case1")

        with mock.patch("requests.request") as mock_requests_post:
            mock_requests_post.return_value = my_response
            response = activity(filename="umbrella_example.json")
        assert response.status_code == my_response.status_code
示例#7
0
    def test_get(self):
        """Call main."""
        from unittest import mock
        import umbr_api

        my_response = FakeResponse("data/templates/get/case1")

        with mock.patch("requests.request") as mock_requests_post:
            mock_requests_post.return_value = my_response
            response = umbr_api.get_list(page=1, limit=10, key=FAKE_KEY)
        assert response.status_code == my_response.status_code
    def test_virtualappliances(self):
        """Call main."""
        from unittest import mock
        from umbr_api.management import virtualappliances

        my_response = FakeResponse("data/templates/management/case3")

        with mock.patch("requests.request") as mock_requests_post:
            mock_requests_post.return_value = my_response
            response = virtualappliances(filename="umbrella_example.json")
        assert response.status_code == my_response.status_code
示例#9
0
    def test_remove_fail(self):
        """Call add to fail."""
        from unittest import mock
        import umbr_api

        my_response = FakeResponse('data/templates/remove/case2')

        with mock.patch('requests.request') as mock_requests_post:
            mock_requests_post.return_value = my_response
            response = umbr_api.remove(record_id='www.example.com',
                                       key=FAKE_KEY)
        assert response.status_code == my_response.status_code
示例#10
0
    def test_add_fail(self):
        """Call add to fail."""
        from unittest import mock
        import umbr_api

        my_response = FakeResponse('data/templates/add/case2')

        with mock.patch('requests.request') as mock_requests_post:
            mock_requests_post.return_value = my_response
            response = umbr_api.add(domain='example.com', url='2example.com',
                                    key=FAKE_KEY,
                                    bypass=True)
        assert response.status_code == my_response.status_code
示例#11
0
    def test_add(self):
        """Call main."""
        from unittest import mock
        import umbr_api

        my_response = FakeResponse("data/templates/add/case1")

        with mock.patch("requests.request") as mock_requests_post:
            mock_requests_post.return_value = my_response
            response = umbr_api.add(
                domain="example.com",
                url="example.com",
                key=FAKE_KEY,
                bypass=False,
            )
        assert response.status_code == my_response.status_code
示例#12
0
    def test_umbrella_main_get(self):
        """Call main."""
        import argparse
        from unittest import mock
        from umbr_api.umbrella import main

        my_response = FakeResponse('data/templates/get/case1')

        args = argparse.Namespace(
            command='get',
            key=FAKE_KEY,
            max_records=2,
            verbose=2,
        )

        with mock.patch('requests.request') as mock_requests_post:
            mock_requests_post.return_value = my_response

            with self.assertRaises(SystemExit) as expected_exc:
                main(args)
        self.assertEqual(expected_exc.exception.code, 200)
示例#13
0
    def test_umbrella_main_get_exclude_non_exist(self):
        """Test with columns filtration."""
        import argparse
        from unittest import mock
        from umbr_api.umbrella import main

        my_response = FakeResponse("data/templates/get/case1")

        args = argparse.Namespace(
            command="get",
            key=FAKE_KEY,
            max_records=2,
            verbose=2,
            exclude="1234",
            format="simple",
        )

        with mock.patch("requests.request") as mock_requests_post:
            mock_requests_post.return_value = my_response

            with self.assertRaises(SystemExit) as expected_exc:
                main(args)
        self.assertEqual(expected_exc.exception.code, 200)