def test_when_adding_new_category_the_correct_data_gets_stored( self, mock_addon, mock_keyboard, mock_xmlreader, mock_xmlwriter): # arrange mock_xmlreader.return_value = self._read_file_xml( self.TEST_ASSETS_DIR + "\\ms_categories.xml") expected = 'MyTestCategory' mock_keyboard.return_value = expected target = main.Main() target._get_settings() target._bootstrap_instances() # act target._command_add_new_category() args = mock_xmlwriter.call_args stored_xml_tree = args[0][0] actual = ET.tostring(stored_xml_tree, encoding='utf8', method='xml') print(actual) # assert self.assertTrue(mock_xmlwriter.called) self.assertIn(expected, actual)
def test_rendering_categories(self, mock_xmlreader, mock_addon): # arrange mock_xmlreader.return_value = self._read_file_xml(self.TEST_ASSETS_DIR + "\\ms_categories.xml") target = main.Main() target._get_settings() target._bootstrap_instances() target.base_url = '' target.addon_handle = 0 # act target._command_render_categories()
def test_when_running_the_plugin_no_errors_occur(self, mock_addon, mock_sys): # arrange mock_sys.args.return_value = ['contenttype', 'noarg'] main.__addon_version__ = '0.0.0' target = main.Main() # act target.run_plugin() # assert pass
def test_when_running_the_plugin_no_errors_occur(self, mock_addon, mock_xmlreader, mock_sys): # arrange mock_xmlreader.return_value = self._read_file_xml(self.TEST_ASSETS_DIR + "\\ms_categories.xml") mock_sys.args.return_value = ['contenttype', 'noarg'] main.__addon_version__ = '0.0.0' target = main.Main() # act target.run_plugin() # assert pass
def test_migrations(self): # arrange shutil.copy2(self.TEST_ASSETS_DIR + "\\ms_categories.xml", self.TEST_ASSETS_DIR + "\\categories.xml") main.__addon_version__ = '0.9.9-alpha' target = main.Main() main.CURRENT_ADDON_DIR = StandardFileName(self.ROOT_DIR) main.PLUGIN_DATA_DIR = StandardFileName(self.TEST_ASSETS_DIR) v_from = LooseVersion('0.0.0') # act target.execute_migrations(v_from)
def test_when_rendering_roms_it_will_return_a_proper_result(self, mock_xmlreader, mock_addon): # arrange mock_xmlreader.return_value = self._read_file_xml(self.TEST_ASSETS_DIR + "\\ms_categories.xml") target = main.Main() target._get_settings() target._bootstrap_instances() target.addon_handle = 0 launcherID = '2220af27d0937d78ce7bc8317f5e853a' # act target._command_render_roms(None, launcherID)
def test_when_rendering_roms_it_will_return_a_proper_result( self, mock_addon): # arrange target = main.Main() target.addon_handle = 0 launcherID = 'my-launcher' target.launchers = {} target.launchers[launcherID] = {} target.launchers[launcherID]['roms_base_noext'] = 'test' target.launchers[launcherID][ 'launcher_display_mode'] = LAUNCHER_DMODE_PCLONE # act target._cat_create_default() target._command_render_roms(None, launcherID)
def test_when_adding_new_category_the_correct_data_gets_stored( self, mock_addon, mock_writecatfile, mock_keyboard): # arrange expected = 'MyTestCategory' mock_keyboard.return_value = expected target = main.Main() # act target._cat_create_default() target._command_add_new_category() args = mock_writecatfile.call_args stored_categories = args[0][1] actual_category1 = stored_categories.items()[0][1] actual_category2 = stored_categories.items()[1][1] actuals = [actual_category1[u'm_name'], actual_category2[u'm_name']] print(stored_categories) # assert self.assertTrue(mock_writecatfile.called) self.assertIn(expected, actuals)
# it under the terms of the GNU General Public License as published by # the Free Software Foundation; version 2 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # --- Python standard library --- from __future__ import unicode_literals # --- Modules/packages in this plugin --- import resources.main as main # ------------------------------------------------------------------------------------------------- # Hacks and tests # ------------------------------------------------------------------------------------------------- # --- Test SHOW_ALL_CATEGORIES / SHOW_ALL_LAUNCHERS / SHOW_ALL_ROMS command --- # sys.argv[2] = '?com=SHOW_ALL_ROMS' # main.Main().run_plugin() # ------------------------------------------------------------------------------------------------- # main() # ------------------------------------------------------------------------------------------------- # Put the main bulk of the code in files inside /resources/, which is a package directory. # This way, the Python interpreter will precompile them into bytecode (files PYC/PYO) so # loading time is faster compared to loading PY files. # See http://www.network-theory.co.uk/docs/pytut/CompiledPythonfiles.html # main.Main().run_plugin()