Exemplo n.º 1
0
	def test_storing_backup(self):
		storage = RecipeStorage(TEST_DIRECTORY, backup=True)
		recipe = Recipe('A.md', MARKDOWN)
		storage.save(recipe)
		storage.save(recipe)		
		storage.save(recipe)
		self.assertEqual(2, len(os.listdir(TEST_DIRECTORY)))
Exemplo n.º 2
0
	def test_loading_recipe(self):
		storage = RecipeStorage(TEST_DIRECTORY);
		recipe = Recipe('MustikkaPiirakka.md', MARKDOWN)						
		storage.save(recipe)

		recipes = storage.list_titles()

		self.assertEqual(1, len(recipes),'There should be at least one recipe at the list')	
Exemplo n.º 3
0
	def test_deleting(self):
		storage = RecipeStorage(TEST_DIRECTORY)
		recipe = Recipe('A.md', MARKDOWN)
		storage.save(recipe)
		recipe = Recipe('B.md', MARKDOWN)
		storage.save(recipe)
		storage.delete('A.md')
		recipes = storage.list()
		self.assertNotIn('A.md',recipes)
Exemplo n.º 4
0
	def test_loading_recipe(self):
		storage = RecipeStorage(TEST_DIRECTORY);

		recipe = Recipe('MustikkaPiirakka.md', MARKDOWN)				
		
		storage.save(recipe)
		recipe = storage.load('MustikkaPiirakka.md');

		self.assertEqual(recipe.name, 'MustikkaPiirakka.md','Recipe name should be MustikkaPiirakka.md')
		self.assertIsNotNone(recipe.markdown, 'Recipe should have some markdown on it.')
Exemplo n.º 5
0
	def test_list_file_history(self):
		storage = RecipeStorage(TEST_DIRECTORY);
		recipe = Recipe('MustikkaPiirakka.md', MARKDOWN)
		storage.save(recipe)
		storage.backup_recipe(recipe)
		time.sleep(1)
		storage.backup_recipe(recipe)
		recipe=storage.load('MustikkaPiirakka.md')
		recipes=storage.history(recipe)
		self.assertEqual(len(recipes),2)
Exemplo n.º 6
0
	def test_listing(self):
		storage = RecipeStorage(TEST_DIRECTORY);

		storage.save(Recipe('MustikkaPiirakka.md', ''))
		storage.save(Recipe('Tortilla.md', ''))
		storage.save(Recipe('BologneseKastike.md', ''))
		storage.save(Recipe('Pannukakku.md', ''))

		recipe_names = storage.list()

		self.assertEqual(len(recipe_names), 4, 'There sould be four recipes stored to directory')

		#In alphabetically sorted order
		self.assertEqual(recipe_names[0], 'BologneseKastike.md')
		self.assertEqual(recipe_names[1], 'MustikkaPiirakka.md')
		self.assertEqual(recipe_names[2], 'Pannukakku.md')
		self.assertEqual(recipe_names[3], 'Tortilla.md')
Exemplo n.º 7
0
	def test_filtering(self):
		storage = RecipeStorage(TEST_DIRECTORY)
		recipe = Recipe('A.md', MARKDOWN)
		storage.save(recipe)
		recipe = Recipe('B.md', MARKDOWN)
		recipe = Recipe('B.MD', MARKDOWN)
		storage.save(recipe)
		recipe = Recipe('C.md', MARKDOWN)
		recipe = Recipe('C.txt', MARKDOWN)
		storage.save(recipe)
		recipe = Recipe('.gitignore', MARKDOWN)
		storage.save(recipe)
		recipes = storage.list()
		self.assertNotIn('.gitignore',recipes)
		self.assertNotIn('C.txt',recipes)
		self.assertIn('B.MD',recipes)
		self.assertIn('A.md',recipes)
Exemplo n.º 8
0
	def test_load_all(self):
		storage = RecipeStorage(TEST_DIRECTORY);

		storage.save(Recipe('MustikkaPiirakka.md', 'Mustikka\n'))
		storage.save(Recipe('Tortilla.md', 'Tortilla\n'))
		storage.save(Recipe('BologneseKastike.md', 'Bolognesekastike\n'))
		storage.save(Recipe('Pannukakku.md', 'Artillery'))
		storage.save(Recipe('Artillery.md', 'Pannukakku'))

		recipes = storage.load_all()

		self.assertEqual(len(recipes), 5, 'There sould be four recipes stored to directory')

		#In alphabetically sorted order, not by the file name but by the title
		self.assertEqual(recipes[0].name, 'Pannukakku.md')
		self.assertEqual(recipes[1].name, 'BologneseKastike.md')
		self.assertEqual(recipes[2].name, 'MustikkaPiirakka.md')
		self.assertEqual(recipes[3].name, 'Artillery.md')
		self.assertEqual(recipes[4].name, 'Tortilla.md')
Exemplo n.º 9
0
	def test_renaming(self):
		storage = RecipeStorage(TEST_DIRECTORY);
		storage.save(Recipe('MustikkaPiirakka.md', ''))
Exemplo n.º 10
0
	def test_saving_recipe(self):

		storage = RecipeStorage(TEST_DIRECTORY);

		recipe = Recipe('MustikkaPiirakka.md', MARKDOWN)				
		storage.save(recipe)