예제 #1
0
	def test_draft_not_found(self):
		TestUtility.clear_sys_args()
		os.mkdir(Config.drafts_dir)
		os.mkdir(Config.posts_drafts_dir)
		with self.assertRaises(CommandArgumentError) as err:
			TestUtility.append_sys_args(['publish', 'A Draft Post To Publish'])
			Hyde.main()
		self.assertEqual(err.exception.msg, "No draft found with 'A-Draft-Post-To-Publish' in the title.")
		TestUtility.remove_directory(Config.drafts_dir)
		self.assertFalse(os.path.exists(Config.drafts_dir))
		TestUtility.clear_sys_args()
예제 #2
0
	def test_publish_draft_post(self):
		TestUtility.clear_sys_args()
		TestUtility.append_sys_args(['draft', 'post', 'A Draft Post To Publish'])
		Hyde.main()
		actual_title = TestUtility.build_jekyll_post_title('a-draft-post-to-publish') + '.md'
		actual_file = Config.posts_drafts_dir + actual_title
		self.assertTrue(os.path.exists(Config.posts_drafts_dir))
		self.assertTrue(os.path.isfile(actual_file))
		os.mkdir(Config.posts_dir)
		TestUtility.clear_sys_args()
		TestUtility.append_sys_args(['publish', 'A Draft Post To Publish'])
		Hyde.main()
		self.assertTrue(os.path.exists(Config.posts_dir))
		self.assertTrue(os.path.isfile(Config.posts_dir+actual_title))
		TestUtility.remove_directory(Config.posts_dir)
		TestUtility.remove_directory(Config.posts_drafts_dir)
		TestUtility.remove_directory(Config.drafts_dir)
		self.assertFalse(os.path.exists(Config.posts_dir))
		self.assertFalse(os.path.exists(Config.posts_drafts_dir))
		self.assertFalse(os.path.exists(Config.drafts_dir))
		TestUtility.clear_sys_args()
예제 #3
0
	def test_add_page_with_title(self):
		TestUtility.clear_sys_args()
		TestUtility.append_sys_args(['add', 'page', 'page title'])
		args = Hyde().process_args()
		self.assertEqual("page title", args.title)
		TestUtility.clear_sys_args()
예제 #4
0
	def test_draft_post_with_title(self):
		TestUtility.clear_sys_args()
		TestUtility.append_sys_args(['draft', 'post', 'draft post title'])
		args = Hyde().process_args()
		self.assertEqual("draft post title", args.title)
		TestUtility.clear_sys_args()
예제 #5
0
	def test_draft_page_no_title(self):
		TestUtility.clear_sys_args()
		TestUtility.append_sys_args(["draft", "page"])
		self.verify_system_exit(2)
		TestUtility.clear_sys_args()
예제 #6
0
	def test_add_post_no_title(self):
		TestUtility.clear_sys_args()
		TestUtility.append_sys_args(["add", "post"])
		self.verify_system_exit(2)
		TestUtility.clear_sys_args()
예제 #7
0
	def test_add_with_unknown_sub_command_with_title(self):
		TestUtility.clear_sys_args()
		TestUtility.append_sys_args(["add", "unknown", "cool title"])
		self.verify_system_exit(2)
		TestUtility.clear_sys_args()
예제 #8
0
	def test_add_no_args(self):
		TestUtility.clear_sys_args()
		TestUtility.append_sys_args(["add"])
		self.verify_system_exit(2)
		TestUtility.clear_sys_args()
예제 #9
0
	def test_unknown_sub_command_valid_args(self):
		TestUtility.clear_sys_args()
		TestUtility.append_sys_args(["unknown", "post", "cool title"])
		self.verify_system_exit(2)
		TestUtility.clear_sys_args()
예제 #10
0
	def test_unknown_sub_command_invalid_post_no_title(self):
		TestUtility.clear_sys_args()
		TestUtility.append_sys_args(["unknown", "port"])
		self.verify_system_exit(2)
예제 #11
0
	def test_unknown_sub_command_no_args(self):
		TestUtility.clear_sys_args()
		TestUtility.append_sys_args(["unknown"])
		self.verify_system_exit(2)
		TestUtility.clear_sys_args()
예제 #12
0
	def test_short_version_option(self):
		TestUtility.clear_sys_args()
		TestUtility.append_sys_args(['-v'])
		self.verify_system_exit(0)
		TestUtility.clear_sys_args()
예제 #13
0
	def test_draft_directory_not_found(self):
		with self.assertRaises(CommandArgumentError) as err:
			TestUtility.append_sys_args(['publish', 'A Draft Post To Publish'])
			Hyde.main()
		self.assertEqual(err.exception.msg, "The drafts directory _drafts/posts/ does not exist.")