Skip to content

Commit

Permalink
Fix Cookies tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
sdhutchins committed Jan 6, 2024
1 parent 54a72f8 commit 38f9b58
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions tests/test_cookies.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import unittest
from unittest.mock import patch, MagicMock
from OrthoEvol.Cookies import CookBook, Oven
from pathlib import Path
import os
Expand All @@ -8,22 +9,24 @@ class TestCookBook(unittest.TestCase):
def test_init(self):
cookbook = CookBook()
self.assertTrue(hasattr(cookbook, 'CookieJar'))
self.assertTrue(isinstance(cookbook.CookieJar, Path))
self.assertIsInstance(cookbook.CookieJar, Path)
# Test other attributes similarly

def test_new_recipes(self):
@patch('builtins.open', new_callable=MagicMock)
def test_new_recipes(self, mock_open):
mock_open.return_value.__enter__.return_value = MagicMock()
new_recipe_path = Path('path/to/new/recipe')
cookbook = CookBook(new_recipe='new_recipe_path')
self.assertEqual(cookbook.new_recipe, new_recipe_path)
self.assertTrue(hasattr(cookbook, 'new_recipe'))
self.assertEqual(getattr(cookbook, 'new_recipe'), new_recipe_path)

class TestOven(unittest.TestCase):

def setUp(self):
self.cookbook = CookBook()
self.oven = Oven(recipes=self.cookbook)
self.test_dir = Path('test_directory')
if not self.test_dir.exists():
os.makedirs(self.test_dir)
self.test_dir.mkdir(exist_ok=True)

def tearDown(self):
if self.test_dir.exists():
Expand All @@ -37,15 +40,17 @@ def test_bake_the_repo(self):
repo_name = 'test_repo'
self.oven.repo = repo_name
self.oven.bake_the_repo(cookie_jar=self.test_dir)
self.assertTrue((self.test_dir / repo_name).exists())
expected_dir = self.test_dir / repo_name
self.assertTrue(expected_dir.exists())

def test_bake_the_user(self):
user_name = 'test_user'
self.oven.user = user_name
self.oven.bake_the_user(cookie_jar=self.test_dir)
self.assertTrue((self.test_dir / user_name).exists())
expected_dir = self.test_dir / user_name
self.assertTrue(expected_dir.exists())

# Similar tests for other methods like bake_the_project, bake_the_db_repo, etc.
# Similar tests for other methods like bake_the_project, etc.

if __name__ == '__main__':
unittest.main()

0 comments on commit 38f9b58

Please sign in to comment.