Пример #1
0
    def test_run(self):
        for mod in (agentstate, capture, ingest, schedule):
            mod.run = should_fail
            sys.argv = ['pyca', mod.__name__.split('.')[-1]]
            try:
                __main__.main()
                assert False
            except ShouldFailException:
                assert True

        # Test ui start
        ui.app.run = should_fail
        sys.argv = ['pyca', 'ui']
        try:
            __main__.main()
            assert False
        except ShouldFailException:
            assert True

        # Test run all
        for mod in (agentstate, capture, ingest, schedule):
            mod.run = lambda: True
        sys.argv = ['pyca', 'run']
        try:
            __main__.main()
        except:
            assert False

        for mod in (agentstate, capture, ingest, schedule):
            reload(mod)
Пример #2
0
    def test_run(self):
        for mod in (agentstate, capture, ingest, schedule):
            mod.run = should_fail
            sys.argv = ['pyca', mod.__name__.split('.')[-1]]
            try:
                __main__.main()
                assert False
            except ShouldFailException:
                assert True

        # Test ui start
        ui.app.run = should_fail
        sys.argv = ['pyca', 'ui']
        try:
            __main__.main()
            assert False
        except ShouldFailException:
            assert True

        # Test run all
        for mod in (agentstate, capture, ingest, schedule):
            mod.run = lambda: True
        sys.argv = ['pyca', 'run']
        try:
            __main__.main()
        except:
            assert False

        for mod in (agentstate, capture, ingest, schedule):
            reload(mod)
Пример #3
0
 def test_http_request_mocked_curl(self):
     config.config()['server']['insecure'] = True
     config.config()['server']['certificate'] = 'nowhere'
     utils.pycurl.Curl = CurlMock
     try:
         utils.http_request('http://127.0.0.1:8', [('x', 'y')])
     except Exception:
         self.fail()
     reload(utils.pycurl)
Пример #4
0
 def test_http_request_mocked_curl(self):
     config.config()['server']['insecure'] = True
     config.config()['server']['certificate'] = 'nowhere'
     utils.pycurl.Curl = CurlMock
     try:
         utils.http_request('http://127.0.0.1:8', [('x', 'y')])
         assert True
     except Exception:
         assert False
     reload(utils.pycurl)
Пример #5
0
 def tearDown(self):
     os.close(self.fd)
     os.remove(self.dbfile)
     shutil.rmtree(self.cadir)
     reload(capture)
     reload(config)
     reload(utils)
Пример #6
0
    def test_run(self):
        for mod in (agentstate, capture, ingest, schedule):
            mod.run = should_fail
            sys.argv = ['pyca', mod.__name__.split('.')[-1]]
            with self.assertRaises(ShouldFailException):
                __main__.main()

        # Test ui start
        ui.app.run = should_fail
        sys.argv = ['pyca', 'ui']
        with self.assertRaises(ShouldFailException):
            __main__.main()

        # Test run all
        for mod in (agentstate, capture, ingest, schedule):
            mod.run = lambda: True
        sys.argv = ['pyca', 'run']
        try:
            __main__.main()
        except Exception:
            self.fail()

        for mod in (agentstate, capture, ingest, schedule):
            reload(mod)
Пример #7
0
 def tearDown(self):
     os.close(self.fd)
     os.remove(self.dbfile)
     reload(utils)
     reload(schedule)
Пример #8
0
 def tearDown(self):
     os.close(self.fd)
     os.remove(self.dbfile)
     reload(utils)
     reload(config)
Пример #9
0
 def teardown(self):
     reload(sys)
Пример #10
0
 def tearDown(self):
     os.close(self.fd)
     os.remove(self.dbfile)
     shutil.rmtree(self.cadir)
     reload(ingest)
     reload(utils)
Пример #11
0
 def teardown(self):
     reload(sys)