Пример #1
0
    def setUp(self):
        # The tests require a data file. We will download some data and put it
        # in a test directory. It needs to be writable by the user who initiates
        # the tests.

        self.original_datastore_path = settings.DATASTORE_PATH
        path = os.path.join(settings.TEST_DATASTORE_PATH, "analysissessions")
        test_datastore.setup_test_datastore_directory(path)

        # Download real data of stations 3201, 3202 and 3203 on 25 March 2011.
        # There are 52 coincidences.

        date = datetime.date(2011, 3, 25)

        file = test_datastore.get_datafile_path(date)

        if not os.path.exists(file):
            test_datastore.download_data_station(3201, date, get_blobs=True)
            test_datastore.download_data_station(3202, date, get_blobs=True)
            test_datastore.download_data_station(3203, date, get_blobs=True)

        self.assertTrue(os.path.exists(file))

        try:
            data = tables.open_file(file, "r")
        except Exception:
            self.assertTrue(False)

        self.assertEqual(
            len(data.root.hisparc.cluster_leiden.station_3201.events), 50547)
        self.assertEqual(
            len(data.root.hisparc.cluster_leiden.station_3202.events), 43176)
        self.assertEqual(
            len(data.root.hisparc.cluster_leiden.station_3203.events), 18268)
        data.close()

        super(LiveSessionTestCase, self).setUp()

        # Start Selenium

        self.driver = webdriver.Firefox()
Пример #2
0
    def setUp(self):
        # The tests require a data file. We will download some data and put it
        # in a test directory. It needs to be writable by the user who initiates
        # the tests.

        self.original_datastore_path = settings.DATASTORE_PATH
        path = os.path.join(settings.TEST_DATASTORE_PATH, "analysissessions")
        test_datastore.setup_test_datastore_directory(path)

        # Download real data of stations 3201, 3202 and 3203 on 25 March 2011.
        # There are 52 coincidences.

        date = datetime.date(2011, 3, 25)

        file = test_datastore.get_datafile_path(date)

        if not os.path.exists(file):
            test_datastore.download_data_station(3201, date, get_blobs=True)
            test_datastore.download_data_station(3202, date, get_blobs=True)
            test_datastore.download_data_station(3203, date, get_blobs=True)

        self.assertTrue(os.path.exists(file))

        try:
            data = tables.open_file(file, "r")
        except Exception:
            self.assertTrue(False)

        self.assertEqual(len(data.root.hisparc.cluster_leiden.station_3201.events), 50547)
        self.assertEqual(len(data.root.hisparc.cluster_leiden.station_3202.events), 43176)
        self.assertEqual(len(data.root.hisparc.cluster_leiden.station_3203.events), 18268)
        data.close()

        super(LiveSessionTestCase, self).setUp()

        # Start Selenium

        self.driver = webdriver.Firefox()
Пример #3
0
    def setUp(self):

        # make progressbar(list) do nothing (i.e., return list)
        self.progressbar_patcher = patch('progressbar.ProgressBar')
        self.progressbar_mock = self.progressbar_patcher.start()
        self.progressbar_mock.return_value.side_effect = lambda x: x

        # Setup test datastore

        # The tests require a data file. We will download some data and
        # put it in a test directory. It needs to be writable by the
        # user who initiates the tests.

        self.original_datastore_path = settings.DATASTORE_PATH
        self.original_esd_path = settings.ESD_PATH
        path = os.path.join(settings.TEST_DATASTORE_PATH, "histograms")
        test_datastore.setup_test_datastore_directory(path)

        # Download data

        # Download real data of station 501 and 502 on 7 July 2011
        # Here is data where we can fit the pulseheight MPV,
        # and we get two stations to find coincidences.

        date = DATE1
        file = test_datastore.get_datafile_path(date)

        if not os.path.exists(file):
            test_datastore.download_data_station(STATION1, date, get_blobs=True)
            test_datastore.download_data_station(STATION2, date, get_blobs=True)

        self.assertTrue(os.path.exists(file))

        try:
            data = tables.open_file(file, "r")
        except Exception:
            self.fail()

        self.assertEqual(data.root.hisparc.cluster_amsterdam.station_501.events.nrows, 63322)
        self.assertEqual(data.root.hisparc.cluster_amsterdam.station_501.weather.nrows, 26317)
        self.assertEqual(data.root.hisparc.cluster_amsterdam.station_502.events.nrows, 55967)

        data.close()

        # Download real data of station 501 on 16 May 2012, which also
        # include weather data and configuration update.

        date = DATE2
        file = test_datastore.get_datafile_path(date)

        if not os.path.exists(file):
            test_datastore.download_data_station(STATION1, date, get_blobs=True)

        self.assertTrue(os.path.exists(file))

        try:
            data = tables.open_file(file, "r")
        except Exception:
            self.fail()

        self.assertEqual(data.root.hisparc.cluster_amsterdam.station_501.events.nrows, 6843)
        self.assertEqual(data.root.hisparc.cluster_amsterdam.station_501.weather.nrows, 25918)
        self.assertEqual(data.root.hisparc.cluster_amsterdam.station_501.config.nrows, 1)

        data.close()

        # Download test data of station 99 on 4 November 2013.
        # This contains 2 events and a configuration from this test station.

        date = DATETEST
        file = test_datastore.get_datafile_path(date)

        if not os.path.exists(file):
            test_datastore.download_data_station(STATIONTEST, date, get_blobs=True)

        self.assertTrue(os.path.exists(file))

        try:
            data = tables.open_file(file, "r")
        except Exception:
            self.fail()

        self.assertEqual(data.root.hisparc.cluster_amsterdam.station_99.events.nrows, 2)
        self.assertEqual(data.root.hisparc.cluster_amsterdam.station_99.config.nrows, 1)

        data.close()

        # Reset last updated state

        # Reset generator state such that it will always update when new
        # files are found.

        state = GeneratorState.objects.get()
        state.update_last_run = datetime.datetime.fromtimestamp(0)
        state.check_last_run = datetime.datetime.fromtimestamp(0)
        state.save()

        super(BaseHistogramsTestCase, self).setUp()