def test_activate_ok(self): '''This test case ensures an extension is activated correctly.''' extensions_folder = "tmp_modules" root_folder = instantiator.get_component_path_data(SettingsFacade().get_config().__class__)[1] extensions_path = "%s%s" % (root_folder, extensions_folder) if os.path.exists(extensions_path): shutil.rmtree(extensions_path) os.mkdir(extensions_path) argv = ["fantastico", "activate-extension", "--name", "dynamic_menu", "--comp-root", "tmp_modules"] main(argv) comp_path = "%s/dynamic_menu" % (extensions_path) self.assertTrue(os.path.exists(comp_path)) self.assertTrue(os.path.exists("%s/tests" % comp_path)) self.assertTrue(os.path.exists("%s/sql" % comp_path)) self.assertTrue(os.path.exists("%s/menu_controller.py" % comp_path)) self.assertTrue(os.path.exists("%s/menu_exceptions.py" % comp_path)) self.assertTrue(os.path.exists("%s/__init__.py" % comp_path)) self.assertFalse(os.path.exists("%s/models" % comp_path))
def _exec_command_help_scenario(self, argv, assert_action, cmd_name): '''This method defines a template for testing subcommands --help option. Once the subcommand is executed, the help string is captured and passed to assert action. .. code-block:: python class SampleSubcommandTest(CommandBaseIntegration): def test_sample_help(self): def assert_action(help_str): self.help_str.startswith("usage: %s" % SampleSubcommand.get_help()) self._exec_command_help_scenario(["fantastico", "sample"], "sample")''' if argv[-1] != "--help" or "-h": argv.append("--help") with self.assertRaises(SystemExit): main(argv) help_str = self._stdout.getvalue() assert_action(help_str) expected_doc_link = "See: %sfeatures/sdk/command_%s.html" % ( SettingsFacade().get("doc_base"), cmd_name.replace("-", "_")) self.assertGreater(help_str.find(expected_doc_link), -1)
def _exec_command_help_scenario(self, argv, assert_action, cmd_name): '''This method defines a template for testing subcommands --help option. Once the subcommand is executed, the help string is captured and passed to assert action. .. code-block:: python class SampleSubcommandTest(CommandBaseIntegration): def test_sample_help(self): def assert_action(help_str): self.help_str.startswith("usage: %s" % SampleSubcommand.get_help()) self._exec_command_help_scenario(["fantastico", "sample"], "sample")''' if argv[-1] != "--help" or "-h": argv.append("--help") with self.assertRaises(SystemExit): main(argv) help_str = self._stdout.getvalue() assert_action(help_str) expected_doc_link = "See: %sfeatures/sdk/command_%s.html" % (SettingsFacade().get("doc_base"), cmd_name.replace("-", "_")) self.assertGreater(help_str.find(expected_doc_link), -1)
def test_syncdb_mysql(self): '''This test case ensures syncdb works great for mysql database.''' argv = [ SdkCore.get_name(), "syncdb", "--comp-root", self._comp_root, "--db-command", "/usr/bin/mysql" ] main(argv)
def test_version_ok(self): '''This test case check version command integration into sdk.''' argv = [SdkCore.get_name(), "version"] main(argv) version = self._stdout.getvalue() self.assertTrue(version.startswith(fantastico.__version__))
def test_syncdb_mysql(self): '''This test case ensures syncdb works great for mysql database.''' argv = [SdkCore.get_name(), "syncdb", "--comp-root", self._comp_root, "--db-command", "/usr/bin/mysql"] main(argv)