ATLAS Offline Software
Namespaces | Classes | Functions | Variables
python.tests Namespace Reference

Namespaces

 PyTestsLib
 
 PyTHistTestsLib
 
 test_CA
 

Classes

class  test_McAodBuilder
 
class  test_McAodFilter
 
class  test_McAodValidation
 
class  xcode
 

Functions

def iov_ranges (iovs)
 
def create_database ()
 
def teardown_database ()
 
def test_database_creation ()
 
def test_database_creation_unicode ()
 
def test_database_retrieval ()
 
def create_defect_type (ddb, n)
 
def create_defect_type_unicode (ddb, n, desc)
 
def test_defect_creation ()
 
def test_virtual_defects_invert ()
 
def test_defect_insertion_retrieval ()
 
def test_defect_insertion_retrieval_unicode ()
 
def test_defect_failure_nonascii_name ()
 
def test_defect_mangle_bad_stored_unicode ()
 
def test_defect_empty_retrieval ()
 
def test_virtual_defect_creation ()
 
def test_defect_list_update_on_creation ()
 
def test_virtual_defect_list_update_on_creation ()
 
def test_virtual_defect_creation_unicode ()
 
def test_virtual_defect_failure_nonascii_name ()
 
def test_nonpresent ()
 
def test_many_sparse_channels ()
 
def test_virtual_defects ()
 
def test_virtual_defects_deep ()
 
def test_virtual_defects_stress ()
 
def test_virtual_defect_hiding ()
 
def test_update_virtual_defect ()
 
def test_tagging_unicode ()
 
def test_rename_defects ()
 
def iov_result_depends (iovs)
 
def test_ignore_defects ()
 
def test_query_with_primary_dependencies ()
 
def test_independent_tags ()
 
def test_query_with_primary_dependencies_with_ignore ()
 
def test_virtual_defect_consistency ()
 
def test_iov_tag_defects ()
 
def test_intersect ()
 
def test_normalize_defect_names ()
 
def test_reject_duplicate_names ()
 
def test_get_intolerable_defects ()
 
def test_list_empty_tag ()
 
def test_noncontiguous_defectid_creation ()
 
def test_return_types ()
 
def mungline (f)
 
def shortDescription (self)
 
def invariant (test_data_name)
 

Variables

 log
 
string TEST_DATABASE = "test_defects.db/COMP200"
 
 teardown_db = None
 
 g = list(globals().keys())
 
 _shortDescription
 
 shortDescription
 
string not_yet
 

Function Documentation

◆ create_database()

def python.tests.create_database ( )

Definition at line 25 of file DataQuality/DQDefects/python/tests/__init__.py.

25 def create_database():
26  ddb = DefectsDB(TEST_DATABASE, read_only=False, create=True)
27  global teardown_db
28  teardown_db = ddb
29 

◆ create_defect_type()

def python.tests.create_defect_type (   ddb,
  n 
)

Definition at line 65 of file DataQuality/DQDefects/python/tests/__init__.py.

65 def create_defect_type(ddb, n):
66  defect_name = "DQD_TEST_DEFECT_%i" % n
67  ddb.create_defect(defect_name, "A test defect (%i)" % n)
68  return defect_name
69 

◆ create_defect_type_unicode()

def python.tests.create_defect_type_unicode (   ddb,
  n,
  desc 
)

Definition at line 70 of file DataQuality/DQDefects/python/tests/__init__.py.

70 def create_defect_type_unicode(ddb, n, desc):
71  defect_name = "DQD_TEST_DEFECT_%i" % n
72  ddb.create_defect(defect_name, desc)
73  return defect_name
74 
75 @with_setup(create_database, teardown_database)

◆ invariant()

def python.tests.invariant (   test_data_name)

Definition at line 8 of file DataQuality/DQUtils/python/tests.py.

8 def invariant(test_data_name):
9  def wrapper(func):
10  testfile = "%s.%s" % (func.__name__, test_data_name)
11  @wraps(func)
12  def check_invariant(*args, **kwargs):
13  result = func(*args, **kwargs)
14  if "DQU_UPDATE_TEST_DATA" in environ:
15  with open(test_data_name, "wb") as fd:
16  dump(result, fd)
17  print("Wrote updated test data")
18  else:
19  test_data = loads(resource_string("testdata", testfile))
20  assert result == test_data, "Data considered 'invariant' has changed"
21  return check_invariant
22 
23  return wrapper

◆ iov_ranges()

def python.tests.iov_ranges (   iovs)

Definition at line 21 of file DataQuality/DQDefects/python/tests/__init__.py.

21 def iov_ranges(iovs):
22  return [(i.since, i.until) for i in iovs]
23 

◆ iov_result_depends()

def python.tests.iov_result_depends (   iovs)

Definition at line 628 of file DataQuality/DQDefects/python/tests/__init__.py.

628 def iov_result_depends(iovs):
629  caused_bad = set()
630  for iov in iovs:
631  if iov.user == "sys:virtual":
632  caused_bad |= set(iov.comment.split())
633  return caused_bad
634 
635 @with_setup(create_database, teardown_database)

◆ mungline()

def python.tests.mungline (   f)

Definition at line 1036 of file DataQuality/DQDefects/python/tests/__init__.py.

1036  def mungline (f):
1037  f.func_code = xcode(f)

◆ shortDescription()

def python.tests.shortDescription (   self)

Definition at line 1047 of file DataQuality/DQDefects/python/tests/__init__.py.

1047  def shortDescription (self):
1048  desc = self._shortDescription()
1049  if desc is None:
1050  desc = self.test.shortDescription()
1051  return desc

◆ teardown_database()

def python.tests.teardown_database ( )

Definition at line 30 of file DataQuality/DQDefects/python/tests/__init__.py.

30 def teardown_database():
31  # force garbage collection before database teardown so as not to create
32  # lots of .__afs* files.
33  global teardown_db
34  teardown_db._clear_connections()
35  teardown_db = None
36  from gc import collect
37  collect()
38 
39  connection_string = "/".join(TEST_DATABASE.split("/")[:-1])
40  if connection_string.endswith(".db"):
41  log.info("Deleting %s", connection_string)
42  unlink(connection_string)
43  return
44 
45  msg = "I don't know how to tear down %s" % TEST_DATABASE
46  log.fatal(msg)
47  raise NotImplementedError(msg)
48 
49 @with_setup(create_database, teardown_database)

◆ test_database_creation()

def python.tests.test_database_creation ( )

Definition at line 50 of file DataQuality/DQDefects/python/tests/__init__.py.

51  assert exists("test_defects.db")
52  log.info("Created database %s", TEST_DATABASE)
53 
54 @with_setup(create_database, teardown_database)

◆ test_database_creation_unicode()

def python.tests.test_database_creation_unicode ( )

Definition at line 55 of file DataQuality/DQDefects/python/tests/__init__.py.

56  assert exists("test_defects.db")
57  log.info("Created database %s", TEST_DATABASE)
58 
59 @with_setup(create_database, teardown_database)

◆ test_database_retrieval()

def python.tests.test_database_retrieval ( )

Definition at line 60 of file DataQuality/DQDefects/python/tests/__init__.py.

61  ddb = DefectsDB(TEST_DATABASE)
62  defects = ddb.retrieve()
63  assert len(defects) == 0, "Unexpected records on the database"
64 

◆ test_defect_creation()

def python.tests.test_defect_creation ( )

Definition at line 76 of file DataQuality/DQDefects/python/tests/__init__.py.

77  ddb = DefectsDB(TEST_DATABASE, read_only=False)
78  create_defect_type(ddb, 0)
79 
80  assert len(ddb.defect_ids) == 1
81 
82 
83 @with_setup(create_database, teardown_database)

◆ test_defect_empty_retrieval()

def python.tests.test_defect_empty_retrieval ( )

Definition at line 235 of file DataQuality/DQDefects/python/tests/__init__.py.

236  ddb = DefectsDB(TEST_DATABASE, read_only=False)
237  iovs = ddb.retrieve()
238  assert not iovs
239 
240  # Create two defects
241  create_defect_type(ddb, 0)
242  create_defect_type(ddb, 1)
243 
244  # Make a virtual defect whose result is the combination of the above
245  ddb.new_virtual_defect("DQD_TEST_VIRTUAL_DEFECT",
246  "Comment", "DQD_TEST_DEFECT_0 DQD_TEST_DEFECT_1")
247 
248  iovs = ddb.retrieve()
249  assert not iovs
250 
251 @with_setup(create_database, teardown_database)

◆ test_defect_failure_nonascii_name()

def python.tests.test_defect_failure_nonascii_name ( )
Check that we raise an error if the defect name is not ASCII

Definition at line 191 of file DataQuality/DQDefects/python/tests/__init__.py.

192  """
193  Check that we raise an error if the defect name is not ASCII
194  """
195  import ROOT
196  if ROOT.gROOT.GetVersionInt() < 62000:
197  # Passing str objects using multibyte encodings is broken
198  # with pyroot up to 6.18. Should be fixed in 6.20?
199  return
200  ddb = DefectsDB(TEST_DATABASE, read_only=False)
201 
202  ddb.create_defect(u"DQD_TÉST_DÉFÉCT_0", "Test")
203 
204 @with_setup(create_database, teardown_database)

◆ test_defect_insertion_retrieval()

def python.tests.test_defect_insertion_retrieval ( )

Definition at line 134 of file DataQuality/DQDefects/python/tests/__init__.py.

135  ddb = DefectsDB(TEST_DATABASE, read_only=False)
136 
137  TEST_ID = 0
138  TEST_DEFECT_NAME = "DQD_TEST_DEFECT_%i" % TEST_ID
139  TEST_COMMENT = "First test defect"
140  TEST_USER = "DQDefects.tests"
141  TEST_SINCE, TEST_UNTIL = 0, 100
142 
143  create_defect_type(ddb, TEST_ID)
144 
145  ddb.insert(TEST_DEFECT_NAME, TEST_SINCE, TEST_UNTIL, TEST_COMMENT, TEST_USER)
146 
147  iovs = ddb.retrieve()
148 
149  assert len(iovs) == 1
150  iov = iovs[0]
151  assert iov.since == TEST_SINCE
152  assert iov.until == TEST_UNTIL
153  assert iov.channel == TEST_DEFECT_NAME
154  assert iov.present
155  assert not iov.recoverable
156  assert iov.user == TEST_USER
157  assert iov.comment == TEST_COMMENT
158 
159 @with_setup(create_database, teardown_database)

◆ test_defect_insertion_retrieval_unicode()

def python.tests.test_defect_insertion_retrieval_unicode ( )

Definition at line 160 of file DataQuality/DQDefects/python/tests/__init__.py.

161  import ROOT
162  if ROOT.gROOT.GetVersionInt() < 62000:
163  # Passing str objects using multibyte encodings is broken
164  # with pyroot up to 6.18. Should be fixed in 6.20?
165  return
166  ddb = DefectsDB(TEST_DATABASE, read_only=False)
167 
168  TEST_ID = 0
169  TEST_DEFECT_NAME = "DQD_TEST_DEFECT_%i" % TEST_ID
170  TEST_COMMENT = u"First test defect with character: ±"
171  TEST_USER = u"DQDefécts.tests"
172  TEST_SINCE, TEST_UNTIL = 0, 100
173  TEST_DEFECT_DESCRIPTION = u"À test defect (%i)" % TEST_ID
174 
175  create_defect_type_unicode(ddb, TEST_ID, TEST_DEFECT_DESCRIPTION)
176 
177  ddb.insert(TEST_DEFECT_NAME, TEST_SINCE, TEST_UNTIL, TEST_COMMENT, TEST_USER)
178 
179  iovs = ddb.retrieve()
180 
181  assert len(iovs) == 1
182  iov = iovs[0]
183  assert iov.present
184  assert not iov.recoverable
185  assert iov.user == TEST_USER
186  assert iov.comment == TEST_COMMENT
187  assert ddb.all_defect_descriptions[TEST_DEFECT_NAME] == TEST_DEFECT_DESCRIPTION
188 
189 @raises(UnicodeEncodeError)
190 @with_setup(create_database, teardown_database)

◆ test_defect_list_update_on_creation()

def python.tests.test_defect_list_update_on_creation ( )
Check that the defect name list is updated when a defect is created

Definition at line 274 of file DataQuality/DQDefects/python/tests/__init__.py.

275  """
276  Check that the defect name list is updated when a defect is created
277  """
278  ddb = DefectsDB(TEST_DATABASE, read_only=False)
279  name = create_defect_type(ddb, 0)
280 
281  assert ddb.defect_names == set([name])
282 
283 @with_setup(create_database, teardown_database)

◆ test_defect_mangle_bad_stored_unicode()

def python.tests.test_defect_mangle_bad_stored_unicode ( )
Check that we recover if any of the string payloads are bad UTF-8

Definition at line 205 of file DataQuality/DQDefects/python/tests/__init__.py.

206  """
207  Check that we recover if any of the string payloads are bad UTF-8
208  """
209  import ROOT
210  if ROOT.gROOT.GetVersionInt() < 62000:
211  # Passing str objects using multibyte encodings is broken
212  # with pyroot up to 6.18. Should be fixed in 6.20?
213  return
214  ddb = DefectsDB(TEST_DATABASE, read_only=False)
215 
216  TEST_DEFECT_NAME = 'DQD_TEST_DEFECT_0'
217  TEST_SINCE, TEST_UNTIL = 0, 100
218 
219  ddb.create_defect(TEST_DEFECT_NAME, "Test")
220 
221  store = ddb.defects_folder.storeObject
222  p = ddb._defect_payload
223  p["present"] = True
224  p["recoverable"] = False
225  p["user"] = b'\x80abc'
226  p["comment"] = b'\x80abc'
227 
228  defect_id = ddb.defect_chan_as_id(TEST_DEFECT_NAME, True)
229 
230  store(TEST_SINCE, TEST_UNTIL, p, defect_id, ddb.defects_tag, False)
231  iovs = ddb.retrieve()
232  assert(iovs[0].user == '\\x80abc' and iovs[0].comment == '\\x80abc')
233 
234 @with_setup(create_database, teardown_database)

◆ test_get_intolerable_defects()

def python.tests.test_get_intolerable_defects ( )
Check that the intolerable defect listing function works

Definition at line 915 of file DataQuality/DQDefects/python/tests/__init__.py.

916  '''
917  Check that the intolerable defect listing function works
918  '''
919  ddb = DefectsDB(TEST_DATABASE, read_only=False)
920 
921  # Create some primary defects
922  create_defect_type(ddb, 0)
923  create_defect_type(ddb, 1)
924  create_defect_type(ddb, 2)
925  create_defect_type(ddb, 3)
926 
927  # Make some virtual defects
928  ddb.new_virtual_defect("DQD_TEST_Virtual_DEFECT", "Comment",
929  "DQD_TEST_DEFECT_0")
930  ddb.new_virtual_defect("PRIMARY", "Comment",
931  "DQD_TEST_DEFECT_0 DQD_TEST_DEFECT_1")
932  ddb.new_virtual_defect("PHYS_test", "Comment",
933  "DQD_TEST_DEFECT_0 DQD_TEST_DEFECT_1 DQD_TEST_DEFECT_2")
934  ddb.new_virtual_defect("TIGHT", "Comment",
935  "DQD_TEST_DEFECT_0 DQD_TEST_DEFECT_1 DQD_TEST_DEFECT_2 DQD_TEST_DEFECT_3")
936 
937  # old_primary_only should be True here, so PRIMARY gives the set of defects
938  assert sorted(ddb.get_intolerable_defects()) == ["DQD_TEST_DEFECT_0", "DQD_TEST_DEFECT_1"], "default params/old_primary_only check failed"
939  assert sorted(ddb.get_intolerable_defects(old_primary_only=False, exclude=['TIGHT'])) == ["DQD_TEST_DEFECT_0", "DQD_TEST_DEFECT_1", "DQD_TEST_DEFECT_2"], 'old_primary_only=False check failed'
940  assert sorted(ddb.get_intolerable_defects(old_primary_only=False)) == ["DQD_TEST_DEFECT_0", "DQD_TEST_DEFECT_1"], 'regex handling check failed'
941 
942 @with_setup(create_database, teardown_database)

◆ test_ignore_defects()

def python.tests.test_ignore_defects ( )

Definition at line 636 of file DataQuality/DQDefects/python/tests/__init__.py.

636 def test_ignore_defects():
637 
638  ddb = DefectsDB(TEST_DATABASE, read_only=False)
639 
640  # Create two defects
641  create_defect_type(ddb, 0)
642  create_defect_type(ddb, 1)
643  create_defect_type(ddb, 2)
644 
645  ddb.insert("DQD_TEST_DEFECT_0", 0, 100, "", "")
646  ddb.insert("DQD_TEST_DEFECT_1", 100, 200, "", "")
647  ddb.insert("DQD_TEST_DEFECT_2", 200, 300, "", "")
648 
649  ddb.new_virtual_defect("DQD_TEST_VIRTUAL_DEFECT", "",
650  "DQD_TEST_DEFECT_0 DQD_TEST_DEFECT_1 DQD_TEST_DEFECT_2")
651 
652  ignored_defects = set(["DQD_TEST_DEFECT_1"])
653 
654  iovs = ddb.retrieve()
655  assert iov_result_depends(iovs) & ignored_defects, "test is broken"
656 
657  iovs = ddb.retrieve(ignore=ignored_defects)
658  assert not iov_result_depends(iovs) & ignored_defects, "result depends on ignored defects"
659 
660 @with_setup(create_database, teardown_database)

◆ test_independent_tags()

def python.tests.test_independent_tags ( )

Definition at line 685 of file DataQuality/DQDefects/python/tests/__init__.py.

686 
687  ddb = DefectsDB(TEST_DATABASE, read_only=False)
688 
689  # Create two defects
690  create_defect_type(ddb, 0)
691  create_defect_type(ddb, 1)
692  create_defect_type(ddb, 2)
693 
694  ddb.insert("DQD_TEST_DEFECT_0", 0, 100, "", "")
695  ddb.insert("DQD_TEST_DEFECT_1", 100, 200, "", "")
696  ddb.insert("DQD_TEST_DEFECT_2", 200, 300, "", "")
697 
698  dtag1 = ddb.new_defects_tag("dqd-test", "New iov tag")
699 
700  ddb.insert("DQD_TEST_DEFECT_0", 0, 100, "", "", present=False)
701 
702  dtag2 = ddb.new_defects_tag("dqd-test-2", "New iov tag")
703 
704  # Make a virtual defect whose result is the combination of the above
705  ddb.new_virtual_defect("DQD_TEST_VIRTUAL_DEFECT", "",
706  "DQD_TEST_DEFECT_0 DQD_TEST_DEFECT_1")
707 
708  ltag1 = ddb.new_logics_tag()
709 
710  ddb.update_virtual_defect("DQD_TEST_VIRTUAL_DEFECT",
711  "DQD_TEST_DEFECT_0 DQD_TEST_DEFECT_2")
712 
713  ltag2 = ddb.new_logics_tag()
714 
715  assert ltag1 != ltag2, f'{ltag1} and {ltag2} should be different'
716 
717  iovs = DefectsDB(TEST_DATABASE, tag=("HEAD", ltag1)).retrieve(channels=["DQD_TEST_VIRTUAL_DEFECT"])
718  assert iov_ranges(iovs) == [(100, 200)], str(iov_ranges(iovs))
719 
720  iovs = DefectsDB(TEST_DATABASE, tag=("HEAD", ltag2)).retrieve(channels=["DQD_TEST_VIRTUAL_DEFECT"])
721  assert iov_ranges(iovs) == [(200, 300)], str(iov_ranges(iovs))
722 
723  iovs = DefectsDB(TEST_DATABASE, tag=(dtag1, ltag1)).retrieve(channels=["DQD_TEST_VIRTUAL_DEFECT"])
724  assert iov_ranges(iovs) == [(0, 100), (100, 200)], str(iov_ranges(iovs))
725 
726  iovs = DefectsDB(TEST_DATABASE, tag=(dtag2, ltag2)).retrieve(channels=["DQD_TEST_VIRTUAL_DEFECT"])
727  assert iov_ranges(iovs) == [(200, 300)], str(iov_ranges(iovs))
728 
729  htag = ddb.new_hierarchical_tag(dtag2, ltag2)
730 
731  iovs = DefectsDB(TEST_DATABASE, tag=(htag, htag)).retrieve(channels=["DQD_TEST_VIRTUAL_DEFECT"])
732  assert iov_ranges(iovs) == [(200, 300)], str(iov_ranges(iovs))
733 
734  iovs = DefectsDB(TEST_DATABASE, tag=htag).retrieve(channels=["DQD_TEST_VIRTUAL_DEFECT"])
735  assert iov_ranges(iovs) == [(200, 300)], str(iov_ranges(iovs))
736 
737 @with_setup(create_database, teardown_database)

◆ test_intersect()

def python.tests.test_intersect ( )

Definition at line 812 of file DataQuality/DQDefects/python/tests/__init__.py.

812 def test_intersect():
813 
814  ddb = DefectsDB(TEST_DATABASE, read_only=False)
815 
816  # Create two defects
817  create_defect_type(ddb, 0)
818  create_defect_type(ddb, 1)
819  create_defect_type(ddb, 2)
820 
821  ddb.insert("DQD_TEST_DEFECT_0", 0, 1000, "", "")
822  ddb.insert("DQD_TEST_DEFECT_0", 1000, 2000, "", "")
823 
824  iovs = ddb.retrieve(50, 100, intersect=True)
825  assert len(iovs) == 1
826  assert (iovs[0].since, iovs[0].until) == (50, 100)
827 
828  iovs = ddb.retrieve(999, 1001, intersect=True)
829  assert len(iovs) == 2
830  first, second = iovs
831  assert (first.since, first.until) == (999, 1000)
832  assert (second.since, second.until) == (1000, 1001)
833 
834 @with_setup(create_database, teardown_database)

◆ test_iov_tag_defects()

def python.tests.test_iov_tag_defects ( )

Definition at line 777 of file DataQuality/DQDefects/python/tests/__init__.py.

778  log.info('IOV Tags')
779  ddb = DefectsDB(TEST_DATABASE, read_only=False)
780 
781  # Create two defects
782  create_defect_type(ddb, 0)
783  create_defect_type(ddb, 1)
784  create_defect_type(ddb, 2)
785 
786  ddb.insert("DQD_TEST_DEFECT_0", 0, 100, "comment1", "user1", present=False)
787  ddb.insert("DQD_TEST_DEFECT_1", 100, 200, "", "")
788  ddb.insert("DQD_TEST_DEFECT_2", 200, 300, "comment2", "user2", recoverable=True)
789 
790  ddb.new_defects_tag("dqd-test", "New iov tag",
791  iovranges=[(0, 51),
792  ((0,210), (0,306))])
793  ddb2 = DefectsDB(TEST_DATABASE, tag=('DetStatusDEFECTS-dqd-test','HEAD'))
794  iovs = ddb2.retrieve(nonpresent=True)
795  assert len(iovs) == 2
796  assert ((iovs[0].channel, iovs[0].since, iovs[0].until,
797  iovs[0].present, iovs[0].recoverable, iovs[0].user,
798  iovs[0].comment)
799  ==
800  ('DQD_TEST_DEFECT_0', 0, 51,
801  False, False, 'user1',
802  'comment1'))
803  assert ((iovs[1].channel, iovs[1].since, iovs[1].until,
804  iovs[1].present, iovs[1].recoverable, iovs[1].user,
805  iovs[1].comment)
806  ==
807  ('DQD_TEST_DEFECT_2', 210, 300,
808  True, True, 'user2',
809  'comment2'))
810 
811 @with_setup(create_database, teardown_database)

◆ test_list_empty_tag()

def python.tests.test_list_empty_tag ( )
Checking that listing a tag works even if the tag is empty

Definition at line 943 of file DataQuality/DQDefects/python/tests/__init__.py.

943 def test_list_empty_tag():
944  """
945  Checking that listing a tag works even if the tag is empty
946  """
947  ddb = DefectsDB(TEST_DATABASE, read_only=False, tag="nominal")
948  ddb.virtual_defect_names
949 
950 @with_setup(create_database, teardown_database)

◆ test_many_sparse_channels()

def python.tests.test_many_sparse_channels ( )

Definition at line 353 of file DataQuality/DQDefects/python/tests/__init__.py.

354  "Testing many virtual channels with sparsely placed IoVs"
355  ddb = DefectsDB(TEST_DATABASE, read_only=False)
356  all_defects = []
357  for i in range(52):
358  all_defects.append(create_defect_type(ddb, i*2))
359 
360  with ddb.storage_buffer:
361  for i in all_defects:
362  ddb.insert(i, 0, 100, "Test", "DQDefects.tests")
363 
364  queried_defects = all_defects[:-1]
365  result = ddb.retrieve(channels=queried_defects)
366  queried_defects_set = set(queried_defects)
367  result_defects_set = set(i.channel for i in result)
368 
369  unwanted_defects_set = result_defects_set - queried_defects_set
370  assert not unwanted_defects_set, "Unwanted defects: %r" % unwanted_defects_set
371 
372  ddb.new_virtual_defect("DQD_TEST_VIRTUAL_DEFECT", "Comment",
373  " ".join(all_defects))
374 
375  result = ddb.retrieve(channels=["DQD_TEST_VIRTUAL_DEFECT"])
376  assert result.channels == set(["DQD_TEST_VIRTUAL_DEFECT"])
377  assert len(result) == 1
378  # This assumes evaluate_full == True
379  assert result[0].comment == " ".join(sorted(all_defects)), result[0].comment
380 
381  result = ddb.retrieve(channels=["DQD_TEST_VIRTUAL_DEFECT"],
382  evaluate_full=False)
383 
384  assert result.channels == set(["DQD_TEST_VIRTUAL_DEFECT"])
385  assert len(result) == 1
386 
387 @with_setup(create_database, teardown_database)

◆ test_noncontiguous_defectid_creation()

def python.tests.test_noncontiguous_defectid_creation ( )
Test that defects are inserted correctly into non-contiguous ranges

Definition at line 951 of file DataQuality/DQDefects/python/tests/__init__.py.

952  """
953  Test that defects are inserted correctly into non-contiguous ranges
954  """
955  ddb = DefectsDB(TEST_DATABASE, read_only=False)
956 
957  create_defect_type(ddb, 0)
958  ddb._create_defect_with_id(2, "TEST_DEFECT_DQD_2", "")
959  ddb.new_virtual_defect("DQD_TEST_VIRTUAL_DEFECT",
960  "Comment", "DQD_TEST_DEFECT_0 TEST_DEFECT_DQD_2")
961  ddb.new_virtual_defect("DQD_TEST_VIRTUAL_DEFECT_2",
962  "Comment", "DQD_TEST_DEFECT_0 TEST_DEFECT_DQD_2")
963  create_defect_type(ddb, 1)
964  create_defect_type(ddb, 3)
965  # assert primary and virtual defects are right
966  ids, names, m = ddb.get_channels()
967  assert m == {0: 'DQD_TEST_DEFECT_0', 1: 'DQD_TEST_DEFECT_1', 2: 'TEST_DEFECT_DQD_2', 3: 'DQD_TEST_DEFECT_3', 'DQD_TEST_DEFECT_3': 3, 'DQD_TEST_DEFECT_0': 0, 'DQD_TEST_DEFECT_1': 1, 'TEST_DEFECT_DQD_2': 2}, 'Primary defect problem'
968  ids, names, m = ddb.get_virtual_channels()
969  assert m == {2147483648: 'DQD_TEST_VIRTUAL_DEFECT', 2147483649: 'DQD_TEST_VIRTUAL_DEFECT_2', 'DQD_TEST_VIRTUAL_DEFECT': 2147483648, 'DQD_TEST_VIRTUAL_DEFECT_2': 2147483649}, 'Virtual defect problem'
970 
971 @with_setup(create_database, teardown_database)

◆ test_nonpresent()

def python.tests.test_nonpresent ( )

Definition at line 335 of file DataQuality/DQDefects/python/tests/__init__.py.

335 def test_nonpresent():
336  ddb = DefectsDB(TEST_DATABASE, read_only=False)
337 
338  create_defect_type(ddb, 0)
339 
340  ddb.insert("DQD_TEST_DEFECT_0", 0, 100, "Test", "DQDefects.tests")
341  ddb.insert("DQD_TEST_DEFECT_0", 0, 100, "Test", "DQDefects.tests", present=False)
342 
343  iovs = ddb.retrieve()
344 
345  assert len(iovs) == 0
346 
347  iovs = ddb.retrieve(nonpresent=True)
348 
349  assert len(iovs) == 1
350  assert not iovs[0].present
351 
352 @with_setup(create_database, teardown_database)

◆ test_normalize_defect_names()

def python.tests.test_normalize_defect_names ( )

Definition at line 835 of file DataQuality/DQDefects/python/tests/__init__.py.

836  ddb = DefectsDB(TEST_DATABASE, read_only=False)
837 
838  # Create two defects
839  create_defect_type(ddb, 0)
840  create_defect_type(ddb, 1)
841 
842  # Make a virtual defect whose result is the combination of the above
843  ddb.new_virtual_defect("DQD_TEST_Virtual_DEFECT", "Comment",
844  "DQD_TEST_DEFECT_0 DQD_TEST_DEFECT_1")
845 
846  assert ddb.normalize_defect_names('dQd_tEsT_DeFeCt_0')=='DQD_TEST_DEFECT_0'
847  assert ddb.normalize_defect_names(['dQd_tEsT_DeFeCt_0', 'DqD_TeSt_dEfEcT_1'])==['DQD_TEST_DEFECT_0', 'DQD_TEST_DEFECT_1']
848  assert ddb.normalize_defect_names('dqd_test_virtual_defect')=='DQD_TEST_Virtual_DEFECT'
849  try:
850  ddb.normalize_defect_names('does_not_exist')
851  wasthrown = False
852  except DefectUnknownError:
853  wasthrown = True
854  assert wasthrown, 'normalize_defect_names should throw when the defect does not exist'
855 
856 @with_setup(create_database, teardown_database)

◆ test_query_with_primary_dependencies()

def python.tests.test_query_with_primary_dependencies ( )

Definition at line 661 of file DataQuality/DQDefects/python/tests/__init__.py.

662 
663  ddb = DefectsDB(TEST_DATABASE, read_only=False)
664 
665  # Create two defects
666  defect_names = [create_defect_type(ddb, i) for i in range(3)]
667 
668  for i, defect in enumerate(defect_names):
669  ddb.insert(defect, i*100, (i+1)*100, "", "")
670 
671  ddb.new_virtual_defect("DQD_TEST_VDEFECT", "", " ".join(defect_names))
672 
673  iovs = ddb.retrieve(channels=["DQD_TEST_VDEFECT"])
674  assert iovs.channels == set(["DQD_TEST_VDEFECT"])
675  assert len(iovs) == len(defect_names)
676 
677  iovs = ddb.retrieve(channels=["DQD_TEST_VDEFECT"],
678  with_primary_dependencies=True)
679  assert iovs.channels == set(["DQD_TEST_VDEFECT"] + defect_names), (
680  "Check failed.")
681 
682  assert len(iovs) == len(defect_names)*2
683 
684 @with_setup(create_database, teardown_database)

◆ test_query_with_primary_dependencies_with_ignore()

def python.tests.test_query_with_primary_dependencies_with_ignore ( )
Checking with_primary_dependencies + ignore

Checks that the set of channels and iovs returned contains the correct 
number of channels and iovs when specifying both with_primary_dependencies 
and ignore to DQDefects.Retrieve

Definition at line 738 of file DataQuality/DQDefects/python/tests/__init__.py.

739  """
740  Checking with_primary_dependencies + ignore
741 
742  Checks that the set of channels and iovs returned contains the correct
743  number of channels and iovs when specifying both with_primary_dependencies
744  and ignore to DQDefects.Retrieve
745  """
746 
747  ddb = DefectsDB(TEST_DATABASE, read_only=False)
748 
749  # Create two defects
750  defect_names = [create_defect_type(ddb, i) for i in range(3)]
751 
752  for i, defect in enumerate(defect_names):
753  ddb.insert(defect, i*100, (i+1)*100, "", "")
754 
755  ignored = set(defect_names[:1])
756 
757  ddb.new_virtual_defect("DQD_TEST_VDEFECT", "", " ".join(defect_names))
758 
759  iovs = ddb.retrieve(channels=["DQD_TEST_VDEFECT"], ignore=ignored)
760  assert iovs.channels == set(["DQD_TEST_VDEFECT"])
761  assert len(iovs) == len(defect_names)-1
762 
763  iovs = ddb.retrieve(channels=["DQD_TEST_VDEFECT"], ignore=ignored,
764  with_primary_dependencies=True)
765  assert iovs.channels == set(["DQD_TEST_VDEFECT"] + defect_names) - ignored, (
766  "Check failed.")
767 
768  assert len(iovs) == len(defect_names[1:])*2
769 

◆ test_reject_duplicate_names()

def python.tests.test_reject_duplicate_names ( )

Definition at line 857 of file DataQuality/DQDefects/python/tests/__init__.py.

858  ddb = DefectsDB(TEST_DATABASE, read_only=False)
859 
860  ddb.create_defect('A_TEST_DEFECT', 'A test defect')
861 
862  wasthrown = False
863  try:
864  ddb.create_defect('A_TEST_DEFECT', 'A test defect 2')
865  except DefectExistsError:
866  wasthrown = True
867  assert wasthrown, 'Creation of duplicate defects should throw'
868 
869  wasthrown = False
870  try:
871  ddb.create_defect('A_test_defect', 'A test defect 2')
872  except DefectExistsError:
873  wasthrown = True
874  assert wasthrown, 'Creation of duplicate defects should throw, even with different case'
875 
876  wasthrown = False
877  try:
878  ddb.create_defect('A_test_defect_2', 'A test defect 2')
879  ddb.rename_defect('A_test_defect_2', 'A_TEST_DEFECT')
880  except DefectExistsError:
881  wasthrown = True
882  assert wasthrown, 'Rename of defect to existing defect name should throw'
883 
884  ddb.new_virtual_defect('TEST_VIRTUAL_DEFECT', 'Comment', 'A_TEST_DEFECT')
885  wasthrown = False
886  try:
887  ddb.new_virtual_defect('Test_Virtual_Defect', 'Comment', 'A_TEST_DEFECT')
888  except DefectExistsError:
889  wasthrown = True
890  assert wasthrown, 'Creation of duplicate virtual defects should throw'
891 
892  ddb.new_virtual_defect('Test_Virtual_Defect_2', 'Comment', 'A_TEST_DEFECT')
893  wasthrown = False
894  try:
895  ddb.rename_defect('Test_Virtual_Defect_2', 'TEST_VIRTUAL_DEFECT')
896  except DefectExistsError:
897  wasthrown = True
898  assert wasthrown, 'Rename of virtual defect to existing virtual defect name should throw'
899 
900  wasthrown = False
901  try:
902  ddb.rename_defect('Test_Virtual_Defect_2', 'A_TEST_DEFECT')
903  except DefectExistsError:
904  wasthrown = True
905  assert wasthrown, 'Rename of virtual defect to existing defect name should throw'
906 
907  wasthrown = False
908  try:
909  ddb.rename_defect('A_TEST_DEFECT', 'TEST_VIRTUAL_DEFECT')
910  except DefectExistsError:
911  wasthrown = True
912  assert wasthrown, 'Rename of defect to existing virtual defect name should throw'
913 
914 @with_setup(create_database, teardown_database)

◆ test_rename_defects()

def python.tests.test_rename_defects ( )

Definition at line 572 of file DataQuality/DQDefects/python/tests/__init__.py.

572 def test_rename_defects():
573 
574  ddb = DefectsDB(TEST_DATABASE, read_only=False)
575 
576  # Create two defects
577  create_defect_type(ddb, 0)
578  create_defect_type(ddb, 1)
579 
580  ddb.insert("DQD_TEST_DEFECT_0", 0, 100, "", "")
581  ddb.insert("DQD_TEST_DEFECT_1", 100, 200, "", "")
582 
583  defects_tag = ddb.new_defects_tag("dqd-test", "New iov tag")
584 
585  # Make a virtual defect whose result is the combination of the above
586  ddb.new_virtual_defect("DQD_TEST_VIRTUAL_DEFECT", "",
587  "DQD_TEST_DEFECT_0 DQD_TEST_DEFECT_1")
588  ddb.new_virtual_defect("DQD_TEST_VIRTUAL_DEFECT_2", "",
589  "DQD_TEST_VIRTUAL_DEFECT")
590  # Make ones with inversion logic
591  ddb.new_virtual_defect("DQD_TEST_VIRTUAL_DEFECT_3", "",
592  "DQD_TEST_DEFECT_0 !DQD_TEST_DEFECT_1")
593  ddb.new_virtual_defect("DQD_TEST_VIRTUAL_DEFECT_4", "",
594  "!DQD_TEST_VIRTUAL_DEFECT")
595 
596  original_tag = ddb.new_logics_tag()
597  original_htag = ddb.new_hierarchical_tag(defects_tag, original_tag)
598 
599  # The following is no longer considered an error condition
600 
606 
607  # first rename a primary defect
608  ddb.rename_defect("DQD_TEST_DEFECT_0", "DQD_TEST_DEFECT_3")
609  assert ddb.virtual_defect_logics['DQD_TEST_VIRTUAL_DEFECT'].clauses == ['DQD_TEST_DEFECT_3', 'DQD_TEST_DEFECT_1'], ddb.virtual_defect_logics['DQD_TEST_VIRTUAL_DEFECT'].clauses
610  assert ddb.virtual_defect_logics['DQD_TEST_VIRTUAL_DEFECT_3'].clauses == ['DQD_TEST_DEFECT_3', '!DQD_TEST_DEFECT_1'], ddb.virtual_defect_logics['DQD_TEST_VIRTUAL_DEFECT_3'].clauses
611 
612  # also valid in other tags?
613  ddb2 = DefectsDB(TEST_DATABASE, tag=original_htag)
614  assert ddb2.virtual_defect_logics['DQD_TEST_VIRTUAL_DEFECT'].clauses == ['DQD_TEST_DEFECT_3', 'DQD_TEST_DEFECT_1'], ddb2.virtual_defect_logics['DQD_TEST_VIRTUAL_DEFECT'].clauses
615 
616  # Now try to rename a virtual defect
617  ddb.rename_defect("DQD_TEST_VIRTUAL_DEFECT", "DQD_TEST_VIRTUAL_DEFECT_A")
618 
619  assert ddb.virtual_defect_logics['DQD_TEST_VIRTUAL_DEFECT_2'].clauses == ['DQD_TEST_VIRTUAL_DEFECT_A'], ddb.virtual_defect_logics['DQD_TEST_VIRTUAL_DEFECT_2'].clauses
620  assert ddb.virtual_defect_logics['DQD_TEST_VIRTUAL_DEFECT_4'].clauses == ['!DQD_TEST_VIRTUAL_DEFECT_A'], ddb.virtual_defect_logics['DQD_TEST_VIRTUAL_DEFECT_4'].clauses
621 
622  # also valid in other tags?
623  ddb2 = DefectsDB(TEST_DATABASE, tag=original_htag)
624  assert ddb2.virtual_defect_logics['DQD_TEST_VIRTUAL_DEFECT_2'].clauses == ['DQD_TEST_VIRTUAL_DEFECT_A'], ddb2.virtual_defect_logics['DQD_TEST_VIRTUAL_DEFECT_2'].clauses
625 
626  ddb._virtual_defect_consistency_check()
627 

◆ test_return_types()

def python.tests.test_return_types ( )
Test that return types are appropriate

Definition at line 972 of file DataQuality/DQDefects/python/tests/__init__.py.

972 def test_return_types():
973  """
974  Test that return types are appropriate
975  """
976  ddb = DefectsDB(TEST_DATABASE, read_only=False)
977 
978  # Create a defect
979  create_defect_type(ddb, 0)
980  did = ddb.new_virtual_defect("DQD_TEST_VIRTUAL_DEFECT",
981  "Comment", "DQD_TEST_DEFECT_0")
982  assert type(did) == int
983 
984  ddb.insert("DQD_TEST_DEFECT_0", 0, 100, "", "")
985 
986  dtag = ddb.new_defects_tag("dqd-test", "New iov tag")
987  assert type(dtag) == str, f'{type(dtag)} instead of str'
988  ltag = ddb.new_logics_tag()
989  assert type(ltag) == str
990  htag = ddb.new_hierarchical_tag(dtag, ltag)
991  assert type(htag) == str
992 
993  assert type(ddb.defects_tags) == list, f'{type(ddb.defects_tags)} instead of list'
994  assert type(ddb.defects_tags[0]) == str, f'{type(ddb.defects_tags[0])} instead of str'
995  assert type(ddb.logics_tags) == list, f'{type(ddb.logics_tags)} instead of list'
996  assert type(ddb.logics_tags[0]) == str, f'{type(ddb.logics_tags[0])} instead of str'
997  assert type(ddb.tags) == list, f'{type(ddb.tags)} instead of list'
998  assert type(ddb.tags[0]) == str, f'{type(ddb.tags[0])} instead of str'
999 
1000  ids, names, _ = ddb.get_channels()
1001  ids = set(ids); names = set(names) # Duplicate so we don't stomp on the underlying data
1002  assert type(ids.pop()) == int
1003  assert type(names.pop()) == str
1004  ids, names, _ = ddb.get_virtual_channels()
1005  ids = set(ids); names = set(names)
1006  assert type(ids.pop()) == int
1007  assert type(names.pop()) == str
1008 
1009  iov = ddb.retrieve()
1010  assert type(iov[0].channel) == str
1011  assert type(iov[0].comment) == str
1012  assert type(iov[0].user) == str
1013  assert type(iov[0].present) == bool
1014  assert type(iov[0].recoverable) == bool
1015 
1016  assert type(ddb.all_defect_descriptions["DQD_TEST_DEFECT_0"]) == str, str(ddb.all_defect_descriptions)
1017  assert type(ddb.all_defect_descriptions["DQD_TEST_VIRTUAL_DEFECT"]) == str, str(ddb.all_defect_descriptions)
1018 
1019  ddb2 = DefectsDB(TEST_DATABASE, read_only=False, tag=htag)
1020  assert type(ddb2.defects_tag) == str
1021  assert type(ddb2.logics_tag) == str
1022  assert type(ddb2.tag.defects) == str
1023  assert type(ddb2.tag.logic) == str
1024 
1025 
1026 # nose 1.6.3 is missing a few fixes that were in nose 1.3.7...

◆ test_tagging_unicode()

def python.tests.test_tagging_unicode ( )

Definition at line 543 of file DataQuality/DQDefects/python/tests/__init__.py.

544 
545  ddb = DefectsDB(TEST_DATABASE, read_only=False)
546 
547  # Create two defects
548  create_defect_type(ddb, 0)
549  create_defect_type(ddb, 1)
550 
551  ddb.insert(u"DQD_TEST_DEFECT_0", 0, 100, u"", u"")
552  ddb.insert(u"DQD_TEST_DEFECT_1", 100, 200, u"", u"")
553 
554  defects_tag = ddb.new_defects_tag("dqd-test", u"New iov tag")
555 
556  # Make a virtual defect whose result is the combination of the above
557  ddb.new_virtual_defect(u"DQD_TEST_VIRTUAL_DEFECT", u"",
558  u"DQD_TEST_DEFECT_0 DQD_TEST_DEFECT_1")
559 
560  original_tag = ddb.new_logics_tag()
561  original_htag = ddb.new_hierarchical_tag(defects_tag, original_tag)
562 
563  what = {"channels": [u"DQD_TEST_VIRTUAL_DEFECT"]}
564 
565  orig_iovs = DefectsDB((TEST_DATABASE), tag=original_htag).retrieve(**what)
566 
567  assert len(orig_iovs) == 2
568  assert (orig_iovs[0].since, orig_iovs[0].until) == ( 0, 100)
569  assert (orig_iovs[1].since, orig_iovs[1].until) == (100, 200)
570 
571 @with_setup(create_database, teardown_database)

◆ test_update_virtual_defect()

def python.tests.test_update_virtual_defect ( )

Definition at line 496 of file DataQuality/DQDefects/python/tests/__init__.py.

497 
498  ddb = DefectsDB(TEST_DATABASE, read_only=False)
499 
500  # Create two defects
501  create_defect_type(ddb, 0)
502  create_defect_type(ddb, 1)
503  create_defect_type(ddb, 2)
504 
505  ddb.insert("DQD_TEST_DEFECT_0", 0, 100, "", "")
506  ddb.insert("DQD_TEST_DEFECT_1", 100, 200, "", "")
507  ddb.insert("DQD_TEST_DEFECT_2", 200, 300, "", "")
508 
509  defects_tag = ddb.new_defects_tag("dqd-test", "New iov tag")
510 
511  # Make a virtual defect whose result is the combination of the above
512  ddb.new_virtual_defect("DQD_TEST_VIRTUAL_DEFECT", "",
513  "DQD_TEST_DEFECT_0 DQD_TEST_DEFECT_1")
514 
515  original_tag = ddb.new_logics_tag()
516  original_htag = ddb.new_hierarchical_tag(defects_tag, original_tag)
517 
518  ddb.update_virtual_defect("DQD_TEST_VIRTUAL_DEFECT",
519  "DQD_TEST_DEFECT_0 DQD_TEST_DEFECT_2")
520 
521  new_tag = ddb.new_logics_tag()
522  new_htag = ddb.new_hierarchical_tag(defects_tag, new_tag)
523 
524  what = {"channels": ["DQD_TEST_VIRTUAL_DEFECT"]}
525 
526  orig_iovs = DefectsDB(TEST_DATABASE, tag=original_htag).retrieve(**what)
527  new_iovs = DefectsDB(TEST_DATABASE, tag=new_htag).retrieve(**what)
528  head_iovs = DefectsDB(TEST_DATABASE).retrieve(**what)
529 
530  assert head_iovs == new_iovs
531  assert head_iovs != orig_iovs
532 
533  assert len(head_iovs) == 2
534  assert (head_iovs[0].since, head_iovs[0].until) == ( 0, 100)
535  assert (head_iovs[1].since, head_iovs[1].until) == (200, 300)
536 
537  from DQUtils.db import Databases
538  db3 = Databases.get_instance(TEST_DATABASE, read_only=True)
539  pfs = db3.getFolderSet('/GLOBAL/DETSTATUS')
540  assert pfs.tagDescription(new_htag) != '', 'Hierarchical tag description not created'
541 
542 @with_setup(create_database, teardown_database)

◆ test_virtual_defect_consistency()

def python.tests.test_virtual_defect_consistency ( )
Checking that virtual flags don't depend on non-existent flags

Definition at line 770 of file DataQuality/DQDefects/python/tests/__init__.py.

771  """
772  Checking that virtual flags don't depend on non-existent flags
773  """
774  DefectsDB()._virtual_defect_consistency_check()
775 
776 @with_setup(create_database, teardown_database)

◆ test_virtual_defect_creation()

def python.tests.test_virtual_defect_creation ( )

Definition at line 252 of file DataQuality/DQDefects/python/tests/__init__.py.

253 
254  ddb = DefectsDB(TEST_DATABASE, read_only=False)
255 
256  # Create two defects
257  create_defect_type(ddb, 0)
258  create_defect_type(ddb, 1)
259 
260  # Make a virtual defect whose result is the combination of the above
261  ddb.new_virtual_defect("DQD_TEST_VIRTUAL_DEFECT",
262  "Comment", "DQD_TEST_DEFECT_0 DQD_TEST_DEFECT_1")
263 
264  # First test ensures internals are correct
265  assert len(ddb.virtual_defect_ids) == 1
266  assert "DQD_TEST_VIRTUAL_DEFECT" in ddb.virtual_defect_names
267 
268  # Second test to ensure database is in correct state
269  ddb = DefectsDB(TEST_DATABASE)
270  assert len(ddb.virtual_defect_ids) == 1
271  assert "DQD_TEST_VIRTUAL_DEFECT" in ddb.virtual_defect_names
272 
273 @with_setup(create_database, teardown_database)

◆ test_virtual_defect_creation_unicode()

def python.tests.test_virtual_defect_creation_unicode ( )

Definition at line 296 of file DataQuality/DQDefects/python/tests/__init__.py.

297 
298  ddb = DefectsDB(TEST_DATABASE, read_only=False)
299 
300  # Create two defects
301  create_defect_type(ddb, 0)
302  create_defect_type(ddb, 1)
303 
304  # Make a virtual defect whose result is the combination of the above
305  ddb.new_virtual_defect(u"DQD_TEST_VIRTUAL_DEFECT",
306  u"Comment", u"DQD_TEST_DEFECT_0 DQD_TEST_DEFECT_1")
307 
308  # First test ensures internals are correct
309  assert len(ddb.virtual_defect_ids) == 1
310  assert "DQD_TEST_VIRTUAL_DEFECT" in ddb.virtual_defect_names
311 
312  # Second test to ensure database is in correct state
313  ddb = DefectsDB(TEST_DATABASE)
314  assert len(ddb.virtual_defect_ids) == 1
315  assert "DQD_TEST_VIRTUAL_DEFECT" in ddb.virtual_defect_names
316 
317 @raises(UnicodeEncodeError)
318 @with_setup(create_database, teardown_database)

◆ test_virtual_defect_failure_nonascii_name()

def python.tests.test_virtual_defect_failure_nonascii_name ( )
Check that we raise an error if the virtual defect name is not ASCII

Definition at line 319 of file DataQuality/DQDefects/python/tests/__init__.py.

320  """
321  Check that we raise an error if the virtual defect name is not ASCII
322  """
323  import ROOT
324  if ROOT.gROOT.GetVersionInt() < 62000:
325  # Passing str objects using multibyte encodings is broken
326  # with pyroot up to 6.18. Should be fixed in 6.20?
327  return
328  ddb = DefectsDB(TEST_DATABASE, read_only=False)
329 
330  ddb.create_defect(u"DQD_TEST_DEFECT_0", "Test")
331  ddb.new_virtual_defect(u"DQD_TÉST_VIRTUAL_DÉFÉCT",
332  u"Comment", u"DQD_TEST_DEFECT_0")
333 
334 @with_setup(create_database, teardown_database)

◆ test_virtual_defect_hiding()

def python.tests.test_virtual_defect_hiding ( )

Definition at line 476 of file DataQuality/DQDefects/python/tests/__init__.py.

477  ddb = DefectsDB(TEST_DATABASE, read_only=False)
478 
479  # Create two defects
480  create_defect_type(ddb, 0)
481  create_defect_type(ddb, 1)
482 
483  # Make a virtual defect whose result is the combination of the above
484  ddb.new_virtual_defect("DQD_TEST_VIRTUAL_DEFECT", "Comment",
485  "DQD_TEST_DEFECT_0 DQD_TEST_DEFECT_1")
486 
487  new_tag = ddb.new_logics_tag()
488 
489  ddb.new_virtual_defect("DQD_TEST_VIRTUAL_DEFECT_2", "Comment",
490  "DQD_TEST_DEFECT_0 DQD_TEST_DEFECT_1")
491 
492  ddb2 = DefectsDB(TEST_DATABASE, tag=('HEAD', new_tag), read_only=True)
493  assert ddb2.virtual_defect_names == set(['DQD_TEST_VIRTUAL_DEFECT']), 'Only one virtual defect should be in this tag'
494 
495 @with_setup(create_database, teardown_database)

◆ test_virtual_defect_list_update_on_creation()

def python.tests.test_virtual_defect_list_update_on_creation ( )
Check that the virtual defect name list is updated when a defect is created

Definition at line 284 of file DataQuality/DQDefects/python/tests/__init__.py.

285  """
286  Check that the virtual defect name list is updated when a defect is created
287  """
288  ddb = DefectsDB(TEST_DATABASE, read_only=False)
289  name = create_defect_type(ddb, 0)
290  ddb.new_virtual_defect("DQD_TEST_VIRTUAL_DEFECT",
291  "Comment", name)
292 
293  assert ddb.virtual_defect_names == set(["DQD_TEST_VIRTUAL_DEFECT"])
294 
295 @with_setup(create_database, teardown_database)

◆ test_virtual_defects()

def python.tests.test_virtual_defects ( )

Definition at line 388 of file DataQuality/DQDefects/python/tests/__init__.py.

389  "Testing virtual defect basics"
390  ddb = DefectsDB(TEST_DATABASE, read_only=False)
391 
392  # Create two defects
393  create_defect_type(ddb, 0)
394  create_defect_type(ddb, 1)
395 
396  # Make a virtual defect whose result is the combination of the above
397  ddb.new_virtual_defect("DQD_TEST_VIRTUAL_DEFECT", "Comment",
398  "DQD_TEST_DEFECT_0 DQD_TEST_DEFECT_1")
399 
400  # Insert an iov into each
401  ddb.insert("DQD_TEST_DEFECT_0", 0, 100, "Test", "DQDefects.tests")
402  ddb.insert("DQD_TEST_DEFECT_1", 150, 200, "Test", "DQDefects.tests")
403 
404  # See what the result of the virtual defect is
405  iovs = ddb.retrieve(channels=["DQD_TEST_VIRTUAL_DEFECT"])
406 
407  # Tests against the value
408  assert len(iovs) == 2
409  first, second = iovs
410  assert (first.since, first.until) == (0, 100)
411  assert (second.since, second.until) == (150, 200)
412  assert first.channel == second.channel == "DQD_TEST_VIRTUAL_DEFECT"
413  del first, second, iovs
414 
415  # Now unset the present bit, and test again that the relevant preiod is fixed
416  ddb.insert("DQD_TEST_DEFECT_1", 150, 200, "Test", "DQDefects.tests", present=False)
417 
418  iovs = ddb.retrieve(channels=["DQD_TEST_VIRTUAL_DEFECT"])
419 
420  assert len(iovs) == 1
421  first = iovs[0]
422  assert (first.since, first.until) == (0, 100)
423  assert first.channel == "DQD_TEST_VIRTUAL_DEFECT"
424 
425  # Now extend the defect and see if we get a contiguous result
426  ddb.insert("DQD_TEST_DEFECT_0", 100, 150, "Test", "DQDefects.tests")
427  iovs = ddb.retrieve(channels=["DQD_TEST_VIRTUAL_DEFECT"])
428 
429  assert len(iovs) == 1
430  first = iovs[0]
431  assert (first.since, first.until) == (0, 150)
432  assert first.channel == "DQD_TEST_VIRTUAL_DEFECT"
433 
434 @with_setup(create_database, teardown_database)

◆ test_virtual_defects_deep()

def python.tests.test_virtual_defects_deep ( )

Definition at line 435 of file DataQuality/DQDefects/python/tests/__init__.py.

436  ddb = DefectsDB(TEST_DATABASE, read_only=False)
437 
438  # Create two defects
439  create_defect_type(ddb, 0)
440  create_defect_type(ddb, 1)
441 
442  # Insert an iov into each
443  ddb.insert("DQD_TEST_DEFECT_0", 0, 100, "Test", "DQDefects.tests")
444  ddb.insert("DQD_TEST_DEFECT_1", 150, 200, "Test", "DQDefects.tests")
445 
446  # Make a virtual defect whose result is the combination of the above
447  ddb.new_virtual_defect("DQD_TEST_VIRTUAL_DEFECT_0", "", "DQD_TEST_DEFECT_0")
448  ddb.new_virtual_defect("DQD_TEST_VIRTUAL_DEFECT_1", "", "DQD_TEST_DEFECT_1")
449 
450  ddb = DefectsDB(TEST_DATABASE)
451 
452  ddb.retrieve()
453 
454 @with_setup(create_database, teardown_database)

◆ test_virtual_defects_invert()

def python.tests.test_virtual_defects_invert ( )

Definition at line 84 of file DataQuality/DQDefects/python/tests/__init__.py.

85  "Testing virtual defects involving inversion"
86  ddb = DefectsDB(TEST_DATABASE, read_only=False)
87 
88  # Create two defects
89  create_defect_type(ddb, 0)
90  create_defect_type(ddb, 1)
91  create_defect_type(ddb, 2)
92 
93  # Make a virtual defect whose result is the combination of the above
94  ddb.new_virtual_defect("DQD_TEST_VIRTUAL_DEFECT", "Comment",
95  "DQD_TEST_DEFECT_0 DQD_TEST_DEFECT_1 !DQD_TEST_DEFECT_2")
96 
97  # Insert an iov into each
98  ddb.insert("DQD_TEST_DEFECT_0", 0, 100, "Test", "DQDefects.tests")
99  ddb.insert("DQD_TEST_DEFECT_1", 150, 200, "Test", "DQDefects.tests")
100  ddb.insert("DQD_TEST_DEFECT_2", 50, 125, "Test", "DQDefects.tests")
101 
102  # See what the result of the virtual defect is
103  iovs = ddb.retrieve(channels=["DQD_TEST_VIRTUAL_DEFECT"])
104 
105  # Tests against the value
106  assert len(iovs) == 4, list(iovs)
107  first, second, third, fourth = iovs
108  assert (first.since, first.until) == (0, 50), first
109  assert (second.since, second.until) == (50, 100), second
110  assert (third.since, third.until) == (125, 150), third
111  assert (fourth.since, fourth.until) == (150, 200), fourth
112  assert first.channel == second.channel == third.channel == fourth.channel == "DQD_TEST_VIRTUAL_DEFECT", (first.channel, second.channel, third.channel, fourth.channel)
113  del first, second, third, fourth, iovs
114 
115  # Test evaluate_full=False
116  iovs = ddb.retrieve(channels=["DQD_TEST_VIRTUAL_DEFECT"], evaluate_full=False)
117  assert len(iovs) == 2, list(iovs)
118 
119  # Now unset the present bit
120  ddb.insert("DQD_TEST_DEFECT_2", 50, 150, "Test", "DQDefects.tests", present=False)
121  iovs = ddb.retrieve(channels=["DQD_TEST_VIRTUAL_DEFECT"])
122 
123  # here we are sensitive to details of python ordering ...
124  assert len(iovs) == 3, list(iovs)
125  first, second, third = iovs
126  assert (first.since, first.until) == (0, 100), first
127  assert (second.since, second.until) == (100, 150), second
128  assert (third.since, third.until) == (150, 200), third
129  assert first.channel == second.channel == third.channel == "DQD_TEST_VIRTUAL_DEFECT", (first.channel, second.channel, third.channel)
130  del first, second, third, iovs
131 
132 
133 @with_setup(create_database, teardown_database)

◆ test_virtual_defects_stress()

def python.tests.test_virtual_defects_stress ( )

Definition at line 455 of file DataQuality/DQDefects/python/tests/__init__.py.

456  ddb = DefectsDB(TEST_DATABASE, read_only=False)
457 
458  STRESS_COUNT = 20
459 
460  for i in range(STRESS_COUNT):
461  create_defect_type(ddb, i)
462 
463  with ddb.storage_buffer:
464  for i in range(STRESS_COUNT):
465  ddb.insert("DQD_TEST_DEFECT_%i" % i, i, i+1, "Test", "DQDefects.tests")
466 
467  ALL_DEFECTS = " ".join("DQD_TEST_DEFECT_%i" % i for i in range(STRESS_COUNT))
468  ddb.new_virtual_defect("DQD_TEST_VIRTUAL_DEFECT", "", ALL_DEFECTS)
469 
470  iovs = ddb.retrieve(channels=["DQD_TEST_VIRTUAL_DEFECT"])
471 
472  assert len(iovs) == STRESS_COUNT - 1
473  assert (iovs[0].since, iovs[-1].until) == (1, STRESS_COUNT)
474 
475 @with_setup(create_database, teardown_database)

Variable Documentation

◆ _shortDescription

python.tests._shortDescription
private

◆ g

python.tests.g = list(globals().keys())

◆ log

python.tests.log

◆ not_yet

string python.tests.not_yet

◆ shortDescription

python.tests.shortDescription

◆ teardown_db

python.tests.teardown_db = None

◆ TEST_DATABASE

string python.tests.TEST_DATABASE = "test_defects.db/COMP200"
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
DerivationFramework::TriggerMatchingUtils::sorted
std::vector< typename R::value_type > sorted(const R &r, PROJ proj={})
Helper function to create a sorted vector from an unsorted range.
python.tests.test_reject_duplicate_names
def test_reject_duplicate_names()
Definition: DataQuality/DQDefects/python/tests/__init__.py:857
SGTest::store
TestStore store
Definition: TestStore.cxx:23
python.tests.test_database_retrieval
def test_database_retrieval()
Definition: DataQuality/DQDefects/python/tests/__init__.py:60
python.tests.test_return_types
def test_return_types()
Definition: DataQuality/DQDefects/python/tests/__init__.py:972
python.tests.test_virtual_defect_failure_nonascii_name
def test_virtual_defect_failure_nonascii_name()
Definition: DataQuality/DQDefects/python/tests/__init__.py:319
python.tests.mungline
def mungline(f)
Definition: DataQuality/DQDefects/python/tests/__init__.py:1036
python.tests.test_normalize_defect_names
def test_normalize_defect_names()
Definition: DataQuality/DQDefects/python/tests/__init__.py:835
python.tests.test_defect_empty_retrieval
def test_defect_empty_retrieval()
Definition: DataQuality/DQDefects/python/tests/__init__.py:235
python.tests.test_ignore_defects
def test_ignore_defects()
Definition: DataQuality/DQDefects/python/tests/__init__.py:636
python.tests.create_database
def create_database()
Definition: DataQuality/DQDefects/python/tests/__init__.py:25
python.tests.teardown_database
def teardown_database()
Definition: DataQuality/DQDefects/python/tests/__init__.py:30
python.tests.test_tagging_unicode
def test_tagging_unicode()
Definition: DataQuality/DQDefects/python/tests/__init__.py:543
python.tests.invariant
def invariant(test_data_name)
Definition: DataQuality/DQUtils/python/tests.py:8
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
python.tests.test_many_sparse_channels
def test_many_sparse_channels()
Definition: DataQuality/DQDefects/python/tests/__init__.py:353
python.tests.test_database_creation
def test_database_creation()
Definition: DataQuality/DQDefects/python/tests/__init__.py:50
run_Egamma1_LArStrip_Fex.dump
dump
Definition: run_Egamma1_LArStrip_Fex.py:87
python.tests.test_virtual_defect_consistency
def test_virtual_defect_consistency()
Definition: DataQuality/DQDefects/python/tests/__init__.py:770
python.tests.test_nonpresent
def test_nonpresent()
Definition: DataQuality/DQDefects/python/tests/__init__.py:335
python.tests.test_rename_defects
def test_rename_defects()
Definition: DataQuality/DQDefects/python/tests/__init__.py:572
python.tests.iov_result_depends
def iov_result_depends(iovs)
Definition: DataQuality/DQDefects/python/tests/__init__.py:628
python.tests.test_defect_creation
def test_defect_creation()
Definition: DataQuality/DQDefects/python/tests/__init__.py:76
python.tests.test_query_with_primary_dependencies_with_ignore
def test_query_with_primary_dependencies_with_ignore()
Definition: DataQuality/DQDefects/python/tests/__init__.py:738
python.tests.shortDescription
def shortDescription(self)
Definition: DataQuality/DQDefects/python/tests/__init__.py:1047
python.tests.test_defect_mangle_bad_stored_unicode
def test_defect_mangle_bad_stored_unicode()
Definition: DataQuality/DQDefects/python/tests/__init__.py:205
python.tests.test_noncontiguous_defectid_creation
def test_noncontiguous_defectid_creation()
Definition: DataQuality/DQDefects/python/tests/__init__.py:951
python.tests.create_defect_type_unicode
def create_defect_type_unicode(ddb, n, desc)
Definition: DataQuality/DQDefects/python/tests/__init__.py:70
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:194
python.tests.test_list_empty_tag
def test_list_empty_tag()
Definition: DataQuality/DQDefects/python/tests/__init__.py:943
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
python.tests.test_virtual_defect_creation
def test_virtual_defect_creation()
Definition: DataQuality/DQDefects/python/tests/__init__.py:252
CxxUtils::set
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
Definition: bitmask.h:232
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:26
python.tests.test_defect_insertion_retrieval
def test_defect_insertion_retrieval()
Definition: DataQuality/DQDefects/python/tests/__init__.py:134
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
python.tests.test_defect_failure_nonascii_name
def test_defect_failure_nonascii_name()
Definition: DataQuality/DQDefects/python/tests/__init__.py:191
python.tests.test_virtual_defects_invert
def test_virtual_defects_invert()
Definition: DataQuality/DQDefects/python/tests/__init__.py:84
python.tests.test_query_with_primary_dependencies
def test_query_with_primary_dependencies()
Definition: DataQuality/DQDefects/python/tests/__init__.py:661
python.tests.test_virtual_defects_stress
def test_virtual_defects_stress()
Definition: DataQuality/DQDefects/python/tests/__init__.py:455
python.tests.test_virtual_defect_creation_unicode
def test_virtual_defect_creation_unicode()
Definition: DataQuality/DQDefects/python/tests/__init__.py:296
python.tests.test_virtual_defect_hiding
def test_virtual_defect_hiding()
Definition: DataQuality/DQDefects/python/tests/__init__.py:476
Trk::open
@ open
Definition: BinningType.h:40
python.tests.test_get_intolerable_defects
def test_get_intolerable_defects()
Definition: DataQuality/DQDefects/python/tests/__init__.py:915
python.tests.test_defect_list_update_on_creation
def test_defect_list_update_on_creation()
Definition: DataQuality/DQDefects/python/tests/__init__.py:274
python.tests.test_defect_insertion_retrieval_unicode
def test_defect_insertion_retrieval_unicode()
Definition: DataQuality/DQDefects/python/tests/__init__.py:160
python.tests.test_intersect
def test_intersect()
Definition: DataQuality/DQDefects/python/tests/__init__.py:812
Trig::FeatureAccessImpl::collect
void collect(const HLT::TriggerElement *te, std::vector< Trig::Feature< T > > &data, const std::string &label, unsigned int condition, const std::string &teName, const HLT::TrigNavStructure *navstructure)
actual feature acceess implementation It has (thanks to the ClassTraits) functionality to flatten con...
Definition: FeatureCollectAthena.h:299
python.tests.test_update_virtual_defect
def test_update_virtual_defect()
Definition: DataQuality/DQDefects/python/tests/__init__.py:496
python.tests.create_defect_type
def create_defect_type(ddb, n)
Definition: DataQuality/DQDefects/python/tests/__init__.py:65
python.tests.test_independent_tags
def test_independent_tags()
Definition: DataQuality/DQDefects/python/tests/__init__.py:685
str
Definition: BTagTrackIpAccessor.cxx:11
python.tests.test_iov_tag_defects
def test_iov_tag_defects()
Definition: DataQuality/DQDefects/python/tests/__init__.py:777
python.tests.test_virtual_defects
def test_virtual_defects()
Definition: DataQuality/DQDefects/python/tests/__init__.py:388
python.dummyaccess.exists
def exists(filename)
Definition: dummyaccess.py:9
python.tests.iov_ranges
def iov_ranges(iovs)
Definition: DataQuality/DQDefects/python/tests/__init__.py:21
python.tests.test_virtual_defects_deep
def test_virtual_defects_deep()
Definition: DataQuality/DQDefects/python/tests/__init__.py:435
python.tests.test_database_creation_unicode
def test_database_creation_unicode()
Definition: DataQuality/DQDefects/python/tests/__init__.py:55
python.tests.test_virtual_defect_list_update_on_creation
def test_virtual_defect_list_update_on_creation()
Definition: DataQuality/DQDefects/python/tests/__init__.py:284