File tree Expand file tree Collapse file tree 1 file changed +51
-0
lines changed
Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Original file line number Diff line number Diff line change 1+ """
2+ Tests for main_processor.HypernetsProcessor class
3+ """
4+
5+ import unittest
6+ from unittest .mock import patch
7+ from hypernets_processor .main_processor import HypernetsProcessor
8+ from hypernets_processor .test .test_functions import setup_test_context
9+
10+
11+ '''___Authorship___'''
12+ __author__ = ""
13+ __created__ = "16/10/2020"
14+ __email__ = ""
15+ __status__ = "Development"
16+
17+
18+ class TestHypernetsProcessor (unittest .TestCase ):
19+ # One way of testing is to set up the module to run the specific method you're interested in. You can then test
20+ # the output of that module.
21+ def test_run (self ):
22+
23+ context = setup_test_context ()
24+
25+ hp = HypernetsProcessor ()
26+ hp .context = context
27+
28+ hp .run ()
29+
30+ self .assertTrue (True )
31+
32+ # An issue with testing high level modules is that changes to the low level code change the output of the high
33+ # level modules too. This means you would have to update all your tests every time you make a change.
34+ # Really when you test a high level module you just want to check it calls the right low level modules with the
35+ # right input. This is where mocks come in.
36+ # In this example I'm mocking RhymerHypstar, so when you run the code it doesn't actually run RhymerHypstar.
37+ @patch ('hypernets_processor.main_processor.RhymerHypstar' )
38+ def test_run_mock (self , mock_RhymerHypstar ):
39+ context = setup_test_context ()
40+
41+ hp = HypernetsProcessor ()
42+ hp .context = context
43+
44+ hp .run ()
45+
46+ # Here you can check what RhymerHypstar was called with to see that that works correctly
47+ mock_RhymerHypstar .assert_called_once_with ()
48+
49+
50+ if __name__ == '__main__' :
51+ unittest .main ()
You can’t perform that action at this time.
0 commit comments