Esempio n. 1
0
 def test_load_from_path_invalid_invalid_storyboard(self):
     generate_temporary_project_folder(False, True)
     string = json.dumps(dict(a="Hello World!"))
     write_file(os.path.join(project_folder_path, "storyboard.json"),
                string)
     with self.assertRaises(InvalidStoryboard):
         Project.load_from_path(project_folder_path)
     remove_temporary_project_folder()
def generate_sample_project(path: str = None):
    if not path:
        path = (
            f"/tmp/sample_project_{str(datetime.now().timestamp()).replace('.', '_')}"
        )
        os.mkdir(path)
    return Project.generate_new_project(path)
Esempio n. 3
0
 def test_save_project(self):
     generate_temporary_project_folder()
     expected_storyboard = Storyboard(title="test storyboard",
                                      author="Bernhard Brueckenpfeiler",
                                      frames=[])
     project = Project.load_from_path(project_folder_path)
     project.storyboard = expected_storyboard
     project.save_project()
     storyboard = Storyboard.generate_from_file(
         os.path.join(project_folder_path, "storyboard.json"))
     self.assertEquals(storyboard, expected_storyboard)
     remove_temporary_project_folder()
Esempio n. 4
0
 def test_init(self):
     storyboard = Storyboard(title="test storyboard",
                             author="Bernhard Brueckenpfeiler",
                             frames=[])
     generate_temporary_project_folder(False, False)
     project = Project(path=project_folder_path, storyboard=storyboard)
     self.assertIsNotNone(project)
     self.assertEqual(project.path, project_folder_path)
     self.assertEqual(project.storyboard, storyboard)
     self.assertEqual(project.image_hashes, [])
     self.assertEqual(project.images_directory,
                      os.path.join(project_folder_path, "images"))
     self.assertEqual(project.output_directory,
                      os.path.join(project_folder_path, "output"))
     remove_temporary_project_folder()
Esempio n. 5
0
 def test_generate_image_hashes(self):
     generate_temporary_project_folder()
     storyboard = Storyboard(title="test storyboard",
                             author="Bernhard Brueckenpfeiler",
                             frames=[])
     project = Project(path=project_folder_path, storyboard=storyboard)
     expected_image_hashes = [
         dict(file_type=".png",
              hash="00087e7ffffe2c00",
              file_name="sample_image_2"),
         dict(file_type=".jpg",
              hash="7f3f1e0c003e381f",
              file_name="sample_image_1"),
     ]
     self.assertEquals(project.image_hashes, expected_image_hashes)
     remove_temporary_project_folder()
Esempio n. 6
0
def generate_project():
    return Project(path="", storyboard=generate_storyboard())
Esempio n. 7
0
 def save_project(self, project: Project = None):
     if not project:
         project = self.current_project
     if project:
         project.save_project()
Esempio n. 8
0
 def create_new_project(self, path):
     if not self.current_project:
         self.current_project = Project.generate_new_project(path)
         return self.current_project
Esempio n. 9
0
 def load_project(self, path):
     if not self.current_project:
         self.current_project = Project.load_from_path(path)
         return self.current_project
Esempio n. 10
0
 def test_load_from_path_valid_load_directory_path(self):
     generate_temporary_project_folder()
     project = Project.load_from_path(project_folder_path)
     self.assertIsNotNone(project)
     remove_temporary_project_folder()
Esempio n. 11
0
 def test_generate_new_project_invalid_directory_is_not_empty(self):
     generate_temporary_project_folder()
     with self.assertRaises(DirectoryIsNotEmpty):
         Project.generate_new_project(project_folder_path)
     remove_temporary_project_folder()
Esempio n. 12
0
 def test_generate_new_project_valid(self):
     generate_temporary_project_folder(False, False)
     project = Project.generate_new_project(project_folder_path)
     self.assertIsNotNone(project)
     remove_temporary_project_folder()
Esempio n. 13
0
 def test_load_from_path_invalid_storyboard_not_found(self):
     generate_temporary_project_folder(False, True)
     with self.assertRaises(StoryboardFileNotFound):
         Project.load_from_path(project_folder_path)
     remove_temporary_project_folder()
Esempio n. 14
0
 def test_load_from_path_invalid_path_not_found(self):
     with self.assertRaises(FileNotFoundError):
         Project.load_from_path(project_folder_path)
Esempio n. 15
0
 def test_load_from_path_valid_load_storyboard_file_path(self):
     generate_temporary_project_folder()
     project = Project.load_from_path(
         os.path.join(project_folder_path, "storyboard.json"))
     self.assertIsNotNone(project)
     remove_temporary_project_folder()