Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This patch cleans up the code around the agent state patch a little bit, avoiding code duplication and unnecessary database requests. It also adds some tests for the agent state module. Signed-off-by: Lars Kiesow <lkiesow@uos.de>
- Loading branch information
Showing
4 changed files
with
87 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# -*- coding: utf-8 -*- | ||
''' | ||
pyCA tests for the agents state handling | ||
''' | ||
|
||
import os | ||
import os.path | ||
import tempfile | ||
import unittest | ||
|
||
from pyca import agentstate, config, db, utils | ||
|
||
|
||
class TestPycaAgentState(unittest.TestCase): | ||
|
||
def setUp(self): | ||
utils.http_request = lambda x, y=False: b'xxx' | ||
_, self.dbfile = tempfile.mkstemp() | ||
config.config()['agent']['database'] = 'sqlite:///' + self.dbfile | ||
config.config()['service-scheduler'] = [''] | ||
|
||
# Mock event | ||
db.init() | ||
|
||
def tearDown(self): | ||
os.remove(self.dbfile) | ||
|
||
def test_run(self): | ||
agentstate.terminate = True | ||
agentstate.run() | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters