Skip to content

Commit

Permalink
Conflicts resolved with rel-v7r0
Browse files Browse the repository at this point in the history
  • Loading branch information
atsareg committed Apr 21, 2021
2 parents 06c6aef + 1664d0c commit 95dc4b2
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 75 deletions.
133 changes: 58 additions & 75 deletions Core/Utilities/test/Test_Mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,83 +3,66 @@
Test cases for DIRAC.Core.Utilities.DAG module.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

#pylint: disable=protected-access,invalid-name,missing-docstring

import unittest

# sut
from DIRAC.Core.Utilities.Mail import Mail
from DIRAC.Core.Utilities.Mail import Mail

__RCSID__ = "$Id $"

########################################################################
class MailTestCase(unittest.TestCase):
""" Test case for DIRAC.Core.Utilities.Mail module
"""
pass

class MailEQ(MailTestCase):


def test_createEmail(self):
""" test _create
"""
m = Mail()
res = m._create('address@dirac.org')
self.assertFalse(res['OK'])

m._subject = 'subject'
m._fromAddress = 'from@dirac.org'
m._mailAddress = 'address@dirac.org'
m._message = 'This is a message'
res = m._create('address@dirac.org')
self.assertTrue(res['OK'])
self.assertEqual(res['Value'].__dict__['_headers'],
[('Content-Type', 'multipart/mixed'),
('MIME-Version', '1.0'),
('Subject', 'subject'),
('From', 'from@dirac.org'),
('To', 'address@dirac.org')])

def test_compareEmails(self):
""" test comparing of Email objects (also for insertion in sets)
"""
m1 = Mail()
m2 = Mail()
self.assertEqual(m1, m2)

m1 = Mail()
m1._subject = 'subject'
m1._fromAddress = 'from@dirac.org'
m1._mailAddress = 'address@dirac.org'
m1._message = 'This is a message'
m2 = Mail()
m2._subject = 'subject'
m2._fromAddress = 'from@dirac.org'
m2._mailAddress = 'address@dirac.org'
m2._message = 'This is a message'
self.assertEqual(m1, m2)
m3 = Mail()
m3._subject = 'subject'
m3._fromAddress = 'from@dirac.org'
m3._mailAddress = 'address@dirac.org'
m3._message = 'This is a message a bit different'
self.assertNotEqual(m1, m3)

s = set()
s.add(m1)
s.add(m2)
self.assertTrue(len(s) == 1)
s.add(m2)
self.assertTrue(len(s) == 1)
s.add(m3)
self.assertTrue(len(s) == 2)
s.add(m3)
self.assertTrue(len(s) == 2)


if __name__ == '__main__':
suite = unittest.defaultTestLoader.loadTestsFromTestCase(MailTestCase)
suite.addTest( unittest.defaultTestLoader.loadTestsFromTestCase(MailEQ))
testResult = unittest.TextTestRunner( verbosity = 2 ).run( suite )
def test_createEmail():
m = Mail()
res = m._create('address@dirac.org')
assert not res['OK']

m._subject = 'subject'
m._fromAddress = 'from@dirac.org'
m._mailAddress = 'address@dirac.org'
m._message = 'This is a message'
res = m._create('address@dirac.org')
assert res['OK']
assert res['Value'].__dict__['_headers'] == [
('Content-Type', 'multipart/mixed'),
('MIME-Version', '1.0'),
('Subject', 'subject'),
('From', 'from@dirac.org'),
('To', 'address@dirac.org')
]


def test_compareEmails(monkeypatch):
# The hostname on GitHub actions can change randomly so mock it
monkeypatch.setattr("socket.getfqdn", lambda: "localhost.example")

m1 = Mail()
m2 = Mail()
assert m1 == m2, (m1.__dict__, m2.__dict__)

m1 = Mail()
m1._subject = 'subject'
m1._fromAddress = 'from@dirac.org'
m1._mailAddress = 'address@dirac.org'
m1._message = 'This is a message'
m2 = Mail()
m2._subject = 'subject'
m2._fromAddress = 'from@dirac.org'
m2._mailAddress = 'address@dirac.org'
m2._message = 'This is a message'
assert m1 == m2
m3 = Mail()
m3._subject = 'subject'
m3._fromAddress = 'from@dirac.org'
m3._mailAddress = 'address@dirac.org'
m3._message = 'This is a message a bit different'
assert m1 != m3

s = {m1, m2}
assert len(s) == 1
s.add(m2)
assert len(s) == 1
s.add(m3)
assert len(s) == 2
s.add(m3)
assert len(s) == 2
4 changes: 4 additions & 0 deletions TransformationSystem/Agent/DataRecoveryAgent.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,10 @@ def treatTransformation(self, transID, transInfoDict):
self.tClient, self.fcClient, self.jobMon)
jobs, nDone, nFailed = tInfo.getJobs(statusList=self.jobStatus)

if not jobs:
self.log.notice('Skipping. No jobs for transformation', str(transID))
return

if self.jobCache[transID][0] == nDone and self.jobCache[transID][1] == nFailed:
self.log.notice('Skipping transformation %s because nothing changed' % transID)
return
Expand Down
8 changes: 8 additions & 0 deletions release.notes
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[v7r1p38]

FIX: fixes from v7r0p55

*WMS
FIX: (#5108) delete the local output sandbox tarfile in case it's still there
FIX: (#5106) SiteDirector - use | operand for the union of tests
Expand Down Expand Up @@ -625,6 +627,12 @@ FIX: (#4551) align ProxyDB test to current changes
NEW: (#4289) Document how to run integration tests in docker
NEW: (#4551) add DNProperties description to Registry/Users subsection

[v7r0p55]

*TS
FIX: (#5109) DataRecoveryAgent: immediately skip transformations without jobs, prevents
exception later on

[v7r0p54]

*Core
Expand Down

0 comments on commit 95dc4b2

Please sign in to comment.