62 def test_get_global_tag(self):
64 global_tag = self.connection.global_tag(name=self.global_tag_name)
65 self.assertTrue(global_tag.name !=
None)
66 self.assertTrue(global_tag.tags() !=
None)
67 self.assertTrue(isinstance(global_tag, self.connection.models[
"globaltag"]))
69 def test_get_empty_global_tag(self):
70 empty_gt = self.connection.global_tag()
71 self.assertTrue(isinstance(empty_gt, self.connection.models[
"globaltag"]))
72 self.assertTrue(empty_gt.empty)
74 def test_all_global_tags_empty_gt(self):
75 empty_gt = self.connection.global_tag()
76 all_gts = empty_gt.all(amount=10)
77 self.assertTrue(all_gts !=
None)
78 self.assertTrue(len(all_gts.data()) != 0)
80 def test_all_method_parameters(self):
81 if self.connection.connection_data[
"host"].lower() ==
"frontier":
82 print(
"Cannot query for timestamps on frontier connection.")
84 empty_gt = self.connection.global_tag()
85 sample_time = datetime.datetime(year=2016, month=1, day=1)
86 now = datetime.datetime.now()
87 time_range =
Range(sample_time, now)
88 time_radius = Radius(sample_time, datetime.timedelta(weeks=4))
89 all_gts_in_interval = empty_gt.all(insertion_time=time_range).
data()
90 for gt
in all_gts_in_interval:
91 self.assertTrue(sample_time <= gt.insertion_time <= now)
93 def test_as_dicts_method_without_timestamps_conversion(self):
94 global_tag = self.connection.global_tag(name=self.global_tag_name)
95 dict_form = global_tag.as_dicts(convert_timestamps=
False)
96 self.assertTrue(isinstance(dict_form, dict))
97 self.assertTrue(dict_form[
"insertion_time"], datetime.datetime)
98 self.assertTrue(dict_form[
"snapshot_time"], datetime.datetime)
100 def test_as_dicts_method_with_timestamps_conversion(self):
101 global_tag = self.connection.global_tag(name=self.global_tag_name)
102 dict_form = global_tag.as_dicts(convert_timestamps=
True)
103 self.assertTrue(isinstance(dict_form, dict))
104 self.assertTrue(dict_form[
"insertion_time"], str)
105 self.assertTrue(dict_form[
"snapshot_time"], str)
109 self.assertTrue(
to_datetime(dict_form[
"insertion_time"]) == global_tag.insertion_time)
110 self.assertTrue(
to_datetime(dict_form[
"snapshot_time"]) == global_tag.snapshot_time)
112 def test_get_tag_maps_in_global_tag(self):
113 global_tag = self.connection.global_tag(name=self.global_tag_name)
116 global_tag_maps = global_tag.tags()
118 global_tag_maps_list = global_tag_maps.data()
119 self.assertTrue(isinstance(global_tag_maps_list, list))
120 self.assertTrue(len(global_tag_maps_list) != 0)
122 for gt_map
in global_tag_maps_list:
123 self.assertTrue(isinstance(gt_map, self.connection.models[
"globaltagmap"]))
125 def test_get_tag_maps_in_global_tag_with_parameters(self):
126 global_tag = self.connection.global_tag(name=self.global_tag_name)
128 global_tag_maps_specific_record = global_tag.tags(record=
"AlCaRecoTriggerBitsRcd")
132 gt_maps_spec_record_list = global_tag_maps_specific_record.data()
133 self.assertTrue(isinstance(gt_maps_spec_record_list, list))
136 self.assertTrue(len(gt_maps_spec_record_list) == 3)
138 def test_get_all_iovs_within_range(self):
139 global_tag = self.connection.global_tag(name=self.global_tag_name)
141 since_range = self.connection.range(200000, 300000)
142 iovs = global_tag.iovs(since=since_range)
144 iovs_list = iovs.data()
145 self.assertTrue(isinstance(iovs_list, list))
147 for iov
in iovs_list:
148 self.assertTrue(isinstance(iov, self.connection.models[
"iov"]))
149 self.assertTrue(200000 <= iov.since <= 300000)
151 def test_gt_diff(self):
152 gt1 = self.connection.global_tag(name=
"74X_dataRun1_v1")
153 gt2 = self.connection.global_tag(name=
"74X_dataRun1_v3")
154 difference_by_arithmetic = gt1 - gt2
155 difference_by_method = gt1.diff(gt2)
161 difference_arithmetic_list = difference_by_arithmetic.data()
162 difference_method_list = difference_by_method.data()
163 self.assertTrue(isinstance(difference_arithmetic_list, list))
164 self.assertTrue(isinstance(difference_method_list, list))
166 self.assertTrue(len(difference_arithmetic_list) == len(difference_method_list))
168 for n
in range(len(difference_arithmetic_list)):
169 self.assertTrue(difference_arithmetic_list[n][
"%s Tag" % gt1.name] != difference_arithmetic_list[n][
"%s Tag" % gt2.name])
170 self.assertTrue(difference_method_list[n][
"%s Tag" % gt1.name] != difference_method_list[n][
"%s Tag" % gt2.name])
std::string print(const Track &, edm::Verbosity=edm::Concise)
Track print utility.
PixelRecoRange< float > Range
def to_datetime(date_string)
char data[epos_bytes_allocation]
def global_tag_tests(querying_tests)