Esempio n. 1
0
 def test_setup(self):
     """ Test running gateway_manager with setup without error """
     g_m = gateway_manager.GatewayManager()
     g_m.node_flash = mock.Mock(return_value=0)
     try:
         g_m.setup()
     except StandardError:
         self.fail("Should not raise an exception during setup")
 def test_create_and_del_user_exp_files(self):
     """ Create files and clean them"""
     g_m = gateway_manager.GatewayManager()
     g_m._create_user_exp_folders('user', 123)
     g_m._create_user_exp_folders('user', 123)
     exp_files = g_m.create_user_exp_files('m3-1', 'user', 123)
     g_m.cleanup_user_exp_files(exp_files)
     g_m._destroy_user_exp_folders('user', 123)
     g_m._destroy_user_exp_folders('user', 123)
    def test__cleanup_user_exp_files_fail_cases(self):
        """ Trying cleaning up files in different state """

        g_m = gateway_manager.GatewayManager()
        exp_files = {
            'non_existent': "invalid_path_lala",
            'empty_file': "test_file",
            'non_empty_file': "test_file_2",
        }

        open("test_file", 'w').close()
        with open('test_file_2', 'w') as test_file:
            test_file.write('test\n')

        g_m.cleanup_user_exp_files(exp_files)

        # no exception
        self.assertFalse(os.path.exists("test_file"))
        self.assertTrue(os.path.exists("test_file_2"))
        os.unlink("test_file_2")
 def test__create_user_exp_files_fail(self):
     """ Create user_exp files fail """
     g_m = gateway_manager.GatewayManager()
     self.assertRaises(IOError, g_m.create_user_exp_files, 'm3-1', '_user_',
                       '-1')
    def test_exp_update_profile_error(self):
        """ Update profile with an invalid profile """

        g_m = gateway_manager.GatewayManager()
        self.assertEqual(1, g_m.exp_update_profile(profile_dict={}))
 def test_setup_fail_flash(self):
     """ Run setup with a flash fail error """
     g_m = gateway_manager.GatewayManager()
     g_m.node_flash = mock.Mock(return_value=1)
     with pytest.raises(RuntimeError):
         g_m.setup()
 def test_setup(self):
     """ Test running gateway_manager with setup without error """
     g_m = gateway_manager.GatewayManager()
     g_m.node_flash = mock.Mock(return_value=0)
     assert g_m.setup() == 0
 def test_setup_fail_flash(self):  # pylint:disable=no-self-use
     """ Run setup with a flash fail error """
     g_m = gateway_manager.GatewayManager()
     g_m.node_flash = mock.Mock(return_value=1)
     with pytest.raises(StandardError):
         g_m.setup()
Esempio n. 9
0
 def test_setup_fail_flash(self):
     """ Run setup with a flash fail error """
     g_m = gateway_manager.GatewayManager()
     g_m.node_flash = mock.Mock(return_value=1)
     self.assertRaises(StandardError, g_m.setup)