Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 5
0
 def tearDown(self):
     os.close(self.fd)
     os.remove(self.dbfile)
     shutil.rmtree(self.cadir)
     reload(capture)
     reload(config)
     reload(utils)
Ejemplo n.º 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)
Ejemplo n.º 7
0
 def tearDown(self):
     os.close(self.fd)
     os.remove(self.dbfile)
     reload(utils)
     reload(schedule)
Ejemplo n.º 8
0
 def tearDown(self):
     os.close(self.fd)
     os.remove(self.dbfile)
     reload(utils)
     reload(config)
Ejemplo n.º 9
0
 def teardown(self):
     reload(sys)
Ejemplo n.º 10
0
 def tearDown(self):
     os.close(self.fd)
     os.remove(self.dbfile)
     shutil.rmtree(self.cadir)
     reload(ingest)
     reload(utils)
Ejemplo n.º 11
0
 def teardown(self):
     reload(sys)