Exemplo n.º 1
0
 def test_main_nofile(self, mock):
     #setup
     myfile = 'nofile'
     mock.return_value = False
     #exercise
     with self.assertRaises(SystemExit):
         main(['./AnyMate.py', myfile])
Exemplo n.º 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)
Exemplo n.º 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])
Exemplo n.º 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])
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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()
Exemplo n.º 8
0
 def test_main_three_param(self):
     with self.assertRaises(SystemExit):
         main(["one", "two", "three"])
Exemplo n.º 9
0
 def test_main_fife_param(self):
     with self.assertRaises(SystemExit):
         main(["bad"] * 5)
Exemplo n.º 10
0
 def test_main_one_param(self):
     with self.assertRaises(SystemExit):
         main(["one"])
Exemplo n.º 11
0
 def test_main_listparam(self):
     with self.assertRaises(SystemExit):
         main([])
Exemplo n.º 12
0
 def test_main_intparam(self, mock):
     with self.assertRaises(SystemExit):
         main(88)
     mock.assert_called_once_with()
Exemplo n.º 13
0
 def test_main_help(self, mock):
     with self.assertRaises(SystemExit):
         main('')
     mock.assert_called_once_with()
Exemplo n.º 14
0
 def test_main_noparam(self):
     with self.assertRaises(TypeError):
         main()