Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbailey committed Feb 4, 2019
1 parent 016c44e commit 5d34802
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tests/test_cpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from rail import CPI

class TestTree(unittest.TestCase):
class TestCPI(unittest.TestCase):
"""
Class to test a CPI.
"""
Expand Down
24 changes: 24 additions & 0 deletions tests/test_threat_sources.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""
Tests for the ThreatSource and ThreatSources classes
"""
import unittest

from rail import ThreatSources

class TestThreatSource(unittest.TestCase):
"""
Class to test a threat source
"""
def setUp(self):
self.threat_sources = ThreatSources()
self.threat_sources.new('test')

def test_threat_sources(self):
"""
Test threat sources
"""
self.assertEqual(self.threat_sources['test']['name'], 'test')


if __name__ == '__main__':
unittest.main()
11 changes: 7 additions & 4 deletions tests/test_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ def test_print(self):
mock_print.reset_mock()
self.assertEqual(self.tree.to_print(), None)
mock_print.assert_called()
mock_print.assert_has_calls([mock.call('/test tree'), mock.call('/test tree/test child')])
mock_print.assert_has_calls([
mock.call('/test tree'),
mock.call('/test tree/test child')
])

def test_to_latex(self):
"""
Expand All @@ -49,11 +52,11 @@ def test_to_latex(self):
self.assertEqual(self.tree.to_latex(), None)
mock_print.assert_called()
mock_print.assert_has_calls([
mock.call('child { node{test tree}'),
mock.call('child { node{test tree}'),
mock.call('child { node{test child}'),
mock.call('}'),
mock.call('}')]
)
mock.call('}')
])

def test_to_dict_list(self):
"""
Expand Down

0 comments on commit 5d34802

Please sign in to comment.