Exemple #1
0
    def test_iso_time(self):
        element = et.fromstring("<foo><bar>2020-01-10T13:13:33Z</bar></foo>")
        dt = get_datetime_from_element(element, 'bar')

        self.assertIsNotNone(dt)
        self.assertIsInstance(dt, datetime.datetime)

        self.assertEqual(dt.year, 2020)
        self.assertEqual(dt.month, 1)
        self.assertEqual(dt.day, 10)

        self.assertEqual(dt.hour, 13)
        self.assertEqual(dt.minute, 13)
        self.assertEqual(dt.second, 33)
        self.assertEqual(str(dt.tzinfo), 'UTC')
Exemple #2
0
 def test_invalid_datetime(self):
     element = et.fromstring("<foo><bar>ipsum</bar></foo>")
     self.assertIsNone(get_datetime_from_element(element, 'bar'))
Exemple #3
0
    def test_empty_subelement(self):
        element = et.fromstring("<foo><bar></bar></foo>")
        self.assertFalse(get_datetime_from_element(element, 'bar'))

        element = et.fromstring("<foo><bar> </bar></foo>")
        self.assertFalse(get_datetime_from_element(element, 'bar'))
Exemple #4
0
 def resolve_start(root, _info):
     return get_datetime_from_element(root, 'start')
Exemple #5
0
 def resolve_open_time(root, _info):
     return get_datetime_from_element(root, 'open_time')
Exemple #6
0
 def resolve_trust_time(root, _info):
     trust = root.find('trust')
     return get_datetime_from_element(trust, 'time')
Exemple #7
0
 def resolve_update_time(root, _info):
     return get_datetime_from_element(root, 'update_time')
Exemple #8
0
 def resolve_scan_end(parent, _info):
     report = parent.find('report')
     return get_datetime_from_element(report, 'scan_end')
Exemple #9
0
 def resolve_modification_time(root, _info):
     return get_datetime_from_element(root.outer_report,
                                      'modification_time')
Exemple #10
0
 def resolve_scan_nvt_version(root, _info):
     return get_datetime_from_element(root, 'scan_nvt_version')
Exemple #11
0
 def resolve_timestamp(parent, _info):
     report = parent.find('report')
     return get_datetime_from_element(report, 'timestamp')
Exemple #12
0
 def resolve_last_seen(root, _info):
     return get_datetime_from_element(root, 'last_seen')
Exemple #13
0
 def resolve_expiration_time(root: XmlElement, _info):
     cert_info = root.find('certificate_info')
     return get_datetime_from_element(cert_info, 'expiration_time')
Exemple #14
0
 def resolve_closed_time(root, _info):
     return get_datetime_from_element(root, 'closed_time')
Exemple #15
0
 def resolve_activation_time(root, _info):
     return get_datetime_from_element(root, 'activation_time')
Exemple #16
0
 def resolve_timestamp(root, _info):
     return get_datetime_from_element(root.inner_report, 'timestamp')
Exemple #17
0
 def resolve_expiration_time(root, _info):
     return get_datetime_from_element(root, 'expiration_time')
Exemple #18
0
 def resolve_scan_end(root, _info):
     return get_datetime_from_element(root.inner_report, 'scan_end')
Exemple #19
0
 def resolve_date(root, _info):
     return get_datetime_from_element(root, 'date')
Exemple #20
0
 def test_none(self):
     self.assertIsNone(get_datetime_from_element(None, 'foo'))
Exemple #21
0
 def resolve_modification_time(root, _info):
     return get_datetime_from_element(root, 'creation_time')
Exemple #22
0
 def test_unkown_subelement(self):
     element = Element('foo')
     self.assertIsNone(get_datetime_from_element(element, 'bar'))
Exemple #23
0
 def resolve_end(root, _info):
     return get_datetime_from_element(root, 'end')
Exemple #24
0
 def resolve_newest(root, _info):
     return get_datetime_from_element(root, 'newest')