def test_scan_folders(self):
        """
        Test ability to scan the Username / Experiment / Dataset folder structure.
        """
        # pylint: disable=no-self-use
        # pylint: disable=too-many-statements
        # pylint: disable=too-many-locals
        # pylint: disable=too-many-branches

        pathToTestConfig = os.path.join(
            os.path.dirname(os.path.realpath(__file__)),
            "testdata/testdataUserExpDataset.cfg")
        settingsModel = SettingsModel(pathToTestConfig)
        settingsModel.SetDataDirectory(
            os.path.join(os.path.dirname(os.path.realpath(__file__)),
                         "testdata", "testdataUserExpDataset"))
        sys.stderr.write("Waiting for fake MyTardis server to start...\n")
        attempts = 0
        while True:
            try:
                attempts += 1
                requests.get(settingsModel.GetMyTardisUrl() +
                             "/api/v1/?format=json",
                             timeout=1)
                break
            except requests.exceptions.ConnectionError, err:
                time.sleep(0.25)
                if attempts > 10:
                    raise Exception("Couldn't connect to %s: %s" %
                                    (settingsModel.GetMyTardisUrl(), str(err)))
Beispiel #2
0
 def setUp(self):
     """
     If we're creating a wx application in the test, it's
     safest to do it in setUp, because we know that setUp
     will only be called once, so only one app will be created.
     """
     self.app = wx.App()
     self.frame = wx.Frame(parent=None,
                           id=wx.ID_ANY,
                           title="Settings Dialog test")
     self.frame.Show()
     self.settingsModel = SettingsModel(configPath=None)
     self.settingsDialog = SettingsDialog(self.frame, self.settingsModel)
     self.settingsDialog.Show()
     self.tempConfig = tempfile.NamedTemporaryFile()
     self.tempFilePath = self.tempConfig.name
     self.tempConfig.close()
Beispiel #3
0
class SettingsDialogTester(unittest.TestCase):
    """
    Test ability to open settings dialog and save fields.

    References:
    http://wiki.wxpython.org/Unit%20Testing%20with%20wxPython
    http://wiki.wxpython.org/Unit%20Testing%20Quick%20Start%20Guide
    """
    def setUp(self):
        """
        If we're creating a wx application in the test, it's
        safest to do it in setUp, because we know that setUp
        will only be called once, so only one app will be created.
        """
        self.app = wx.App()
        self.frame = wx.Frame(parent=None,
                              id=wx.ID_ANY,
                              title="Settings Dialog test")
        self.frame.Show()
        self.settingsModel = SettingsModel(configPath=None)
        self.settingsDialog = SettingsDialog(self.frame, self.settingsModel)
        self.settingsDialog.Show()
        self.tempConfig = tempfile.NamedTemporaryFile()
        self.tempFilePath = self.tempConfig.name
        self.tempConfig.close()

    def tearDown(self):
        if os.path.exists(self.tempFilePath):
            os.remove(self.tempFilePath)
        self.settingsDialog.Hide()
        self.frame.Destroy()

    def test_settings_dialog(self):
        """
        Test ability to open settings dialog and save fields.
        """
        self.settingsModel.SaveFieldsFromDialog(self.settingsDialog,
                                                configPath=self.tempFilePath,
                                                saveToDisk=True)
Beispiel #4
0
 def setUp(self):
     self.app = wx.App()
     self.frame = wx.Frame(parent=None,
                           id=wx.ID_ANY,
                           title="Connectivity check test")
     self.settingsModel = SettingsModel(configPath=None)