def test_init(self, init): cmd = "chromie init -n testy" argv = ParserHelper.get_argv(cmd) mocked_args = ParserHelper.parse_args(command="init", filepath=".", name="testy", overwrite=False) main(argv) init.assert_called_with(mocked_args)
def test_pack(self, package): cmd = "chromie pack ./testy" argv = ParserHelper.get_argv(cmd) mocked_args = ParserHelper.parse_args(command="pack", filepath="./testy", increment_version=None, version=None) main(argv) package.assert_called_with(mocked_args)
def test_init_prompts_for_overwrite( self, mocked_input, mocked_exists, mocked_make_extension_dir ): args = ParserHelper.get_mocked_args("chromie init -n testy") init(args) mocked_input.assert_called_with(Initialize.OVERWRIGHT_PROMPT) mocked_make_extension_dir.assert_called_once()
def test_init_makes_directory(self, mocked_exists, mocked_make_extension_dir): args = ParserHelper.get_mocked_args("chromie init -n testy -o") finder = ChromiePathFinder(args.filepath, args.name) init(args) mocked_make_extension_dir.assert_called_with(finder)
def test_mkfile(self): args = ParserHelper.get_mocked_args("chromie init -n testy -o") finder = ChromiePathFinder(args.filepath, args.name) path = os.path.join(finder.root, Path.IGNORE_FILE) m = mock_open() with patch("chromie.commands.init.open", m, create=True): _mkfile(path) m.assert_called_once_with(path, "w") handle = m() handle.write.assert_called_once_with("")
def test_make_extension_dir( self, mocked_makedirs, mocked_manifest_write, mocked_mkfile ): args = ParserHelper.get_mocked_args("chromie init -n testy -o") finder = ChromiePathFinder(args.filepath, args.name) make_extension_dir(finder) self.assertEqual(mocked_makedirs.call_count, 2) mocked_makedirs.assert_has_calls( [ call(os.path.join(finder.root, Path.STORE_DIR)), call(os.path.join(finder.root, Path.IMAGES_DIR)), ], ) mocked_mkfile.assert_called_with(os.path.join(finder.root, Path.IGNORE_FILE))
def call_package(argv): args = ParserHelper.get_mocked_args(argv) try: package(args) except: pass
def test_init_prompts_for_name(self, mocked_input, mocked_make_extension_dir): args = ParserHelper.get_mocked_args("chromie init") init(args) mocked_input.assert_called_with(Initialize.NAME_PROMPT) mocked_make_extension_dir.assert_called_once()
def test_init_required_arguments(self): args = ParserHelper.get_mocked_args("chromie init . -n testy") self.assertEqual(args.name, "testy") self.assertEqual(args.command, "init") self.assertEqual(args.filepath, ".")
def test_pack_args_increment_version(self): args = ParserHelper.get_mocked_args("chromie pack ./testy -i patch") self.assertEqual(args.increment_version, "patch")
def test_pack_args_specific_version(self): args = ParserHelper.get_mocked_args("chromie pack ./testy -v 0.0.8") self.assertEqual(args.version, "0.0.8")
def test_pack_required_arguments(self): args = ParserHelper.get_mocked_args("chromie pack ./testy") self.assertEqual(args.command, "pack") self.assertEqual(args.filepath, "./testy")
def test_init_name(self): args = ParserHelper.get_mocked_args("chromie init . -n testy") self.assertEqual(args.name, "testy")
def test_init_overwrite(self): args = ParserHelper.get_mocked_args("chromie init . -o") self.assertTrue(args.overwrite)