def test_create_ws_descriptor(self, m_open, m_yaml, m_path): """ Tests the function that generates the workspace configuration file. Verify that a workspace can be created using the file generated by this function. """ # Create a new workspace ws = Workspace("workspace/root/dir", ws_name="workspace_name", log_level='log_level') # Patch file handling functions m_open.return_value = None m_open.write.return_value = None m_yaml.dump.return_value = None # Call function cfg_d = ws.write_ws_descriptor() # Assure that config file would be writen with the correct location configfile = os.path.join(ws.workspace_root, Workspace.__descriptor_name__) self.assertEqual(m_open.call_args, mock.call(configfile, 'w')) # Make sure the workspace root dir and # config file exist by patching os.path m_path.isdir.return_value = True m_path.isfile.return_value = True # Patch yaml.load to return the previously obtained configuration m_yaml.load.return_value = cfg_d # Call function new_ws = Workspace.__create_from_descriptor__(ws.workspace_root) # Assert returned workspace configuration is equal to the previous self.assertEqual(ws, new_ws)