Exemple #1
0
 def test_get_instrument_valid(self):
     """
     Test: The correct instrument object is returned
     When: get_instrument is called on a valid database connection
     """
     actual = access.get_instrument('GEM')
     self.assertIsNotNone(actual)
     self.assertEqual('GEM', actual.name)
Exemple #2
0
 def _find_run_in_database(self):
     """
     Find a ReductionRun record in the database
     This includes a timeout to wait for several seconds to ensure the database has received
     the record in question
     :return: The resulting record
     """
     instrument = db.get_instrument(self.instrument_name)
     return instrument.reduction_runs.filter(run_number=self.run_number)
Exemple #3
0
 def create_run_records(self, message: Message):
     """
     Create or get the necessary records to construct a ReductionRun. This
     must be done before looking up the run version to make sure the
     experiment record exists!
     """
     rb_number = self.normalise_rb_number(message.rb_number)
     experiment = db_access.get_experiment(rb_number)
     run_version = db_access.find_highest_run_version(experiment, run_number=message.run_number)
     instrument = db_access.get_instrument(str(message.instrument))
     software = db_access.get_software(message.software.get("name"), message.software.get("version"))
     return self.do_create_reduction_record(message, experiment, instrument, run_version, software)
def find_run_in_database(test):
    """
    Find a ReductionRun record in the database
    This includes a timeout to wait for several seconds to ensure the database has received
    the record in question
    :return: The resulting record
    """
    instrument = db.get_instrument(test.instrument_name)
    if isinstance(test.run_number, list):
        args = {"run_number__in": test.run_number}

    else:
        args = {"run_number": test.run_number}
    return instrument.reduction_runs.filter(**args)