Beispiel #1
0
class WorkspaceTestBase:
    def setUp(self):
        self.manager = WorkspaceManager(workspaces_dir=WORKSPACES_DIR)
        self.manager.delete_all_workspaces()

    def tearDown(self):
        self.manager.delete_all_workspaces()

    def assertIsWorkspaceDir(self, *path, expected=True):
        self.assertEqual(os.path.isdir(os.path.join(WORKSPACES_DIR, *path)), expected)

    def assertIsWorkspaceFile(self, *path, expected=True):
        self.assertEqual(os.path.isfile(os.path.join(WORKSPACES_DIR, *path)), expected)

    def assertWorkspaceFileExists(self, *path, expected=True):
        self.assertEqual(os.path.exists(os.path.join(WORKSPACES_DIR, *path)), expected)

    def assertRaisedException(self, expected_exception, expected_message, func, *args):
        try:
            func(*args)
        except expected_exception as e:
            self.assertEqual(e.message, expected_message)
            return
        self.fail("Exception expected but none thrown.")

    @staticmethod
    def createWorkspaceSubDir(*path):
        os.mkdir(os.path.join(WORKSPACES_DIR, *path))

    @staticmethod
    def createWorkspaceFile(*path):
        open(os.path.join(WORKSPACES_DIR, *path), 'a')
Beispiel #2
0
 def setUp(self):
     self.manager = WorkspaceManager(workspaces_dir=WORKSPACES_DIR)
     self.manager.delete_all_workspaces()