Beispiel #1
0
 def test_main_nofile(self, mock):
     #setup
     myfile = 'nofile'
     mock.return_value = False
     #exercise
     with self.assertRaises(SystemExit):
         main(['./AnyMate.py', myfile])
Beispiel #2
0
 def test_main_mockedfile(self, anymock, guimock, filemock):
     #setup
     myfile = 'nofile'
     filemock.return_value = True
     #exercise
     main(['./AnyMate.py', myfile])
     #validate
     anymock.assert_called_once_with(myfile)
Beispiel #3
0
 def test_main_four_wrong_file(self, mock):
     #setup
     myfile = 'nofile'
     conf = 'hello'
     anym = MagicMock()
     mock.return_value = anym
     #exercise
     with self.assertRaises(SystemExit):
         main(['./AnyMate.py', '--nogui', conf, myfile])
Beispiel #4
0
 def test_main_four_wrong_param(self, mock):
     #setup
     myfile = 'template.anymate'
     conf = 'hello'
     anym = MagicMock()
     mock.return_value = anym
     #exercise
     with self.assertRaises(SystemExit):
         main(['./AnyMate.py', 'BAM', conf, myfile])
Beispiel #5
0
 def test_main_two_real_param(self, mock, guimock):
     #setup
     myfile = 'template.anymate'
     mock.return_value = "Something"
     #exercise
     main(['./AnyMate.py', myfile])
     #validate
     mock.assert_called_once_with(myfile)
     # We expect the gui to be called with the return value of AnyMate()
     guimock.assert_called_once_with("Something", myfile)
Beispiel #6
0
 def test_main_four_real_param(self, mock):
     #setup
     myfile = 'template.anymate'
     conf = 'hello'
     anym = MagicMock()
     mock.return_value = anym
     #exercise
     main(['./AnyMate.py', '--nogui', conf, myfile])
     #validate
     mock.assert_called_once_with(myfile)
     anym.execute.assert_called_once_with(conf)
Beispiel #7
0
 def test_main_mainloop(self, anymock, guimock, filemock):
     #setup
     myfile = 'nofile'
     filemock.return_value = True
     #Anymate() returns an AnymateObject
     anymock.return_value = MagicMock(name='AnyMate')
     gui = MagicMock(name='AnyMateGui')
     guimock.return_value = gui
     #exercise
     main(['./AnyMate.py', myfile])
     #validate
     anymock.assert_called_once_with(myfile)
     gui.rootwin.mainloop.assert_called_once_with()
Beispiel #8
0
 def test_main_three_param(self):
     with self.assertRaises(SystemExit):
         main(["one", "two", "three"])
Beispiel #9
0
 def test_main_fife_param(self):
     with self.assertRaises(SystemExit):
         main(["bad"] * 5)
Beispiel #10
0
 def test_main_one_param(self):
     with self.assertRaises(SystemExit):
         main(["one"])
Beispiel #11
0
 def test_main_listparam(self):
     with self.assertRaises(SystemExit):
         main([])
Beispiel #12
0
 def test_main_intparam(self, mock):
     with self.assertRaises(SystemExit):
         main(88)
     mock.assert_called_once_with()
Beispiel #13
0
 def test_main_help(self, mock):
     with self.assertRaises(SystemExit):
         main('')
     mock.assert_called_once_with()
Beispiel #14
0
 def test_main_noparam(self):
     with self.assertRaises(TypeError):
         main()