@mock.patch('website.project.sanctions.TokenApprovableSanction.ask', mock.Mock())
    def setUp(self):
        super(TestApproveEmbargoTerminations, self).setUp()
        self.user = AuthUserFactory()

        self.node = NodeFactory(creator=self.user)
        NodeFactory(
            creator=self.user,
            parent=NodeFactory(creator=self.user, parent=self.node)
        )

        # requesting termination but less than 48 hours old
        with mock_archive(self.node, embargo=True, autoapprove=True) as registration:
            registration.request_embargo_termination(auth=Auth(self.user))
            self.registration1 = registration

        # requesting termination and older than 48 hours
        with mock_archive(self.node, embargo=True, autoapprove=True) as registration:
            old_time = datetime.now() - timedelta(days=5)
            approval = registration.request_embargo_termination(auth=Auth(self.user))
            EmbargoTerminationApproval._storage[0].store.update(
                {'_id': approval._id},
                {'$set': {'initiation_date': old_time}},
            )
            self.registration2 = registration

        # requesting termination and older than 48 hours, but approved
        with mock_archive(self.node, embargo=True, autoapprove=True) as registration:
            old_time = timedelta(days=5) - datetime.now()
            approval = registration.request_embargo_termination(auth=Auth(self.user))
            EmbargoTerminationApproval._storage[0].store.update(
                {'_id': approval._id},
                {'$set': {'initiation_date': old_time}},
            )
            approval.state = Sanction.APPROVED
            approval.save()
            self.registration3 = registration

        # embargoed but not requesting termination
        with mock_archive(self.node, embargo=True, autoapprove=True) as registration:
            self.registration4 = registration

        EmbargoTerminationApproval._clear_caches()
dataset/ETHPy150Open CenterForOpenScience/osf.io/scripts/tests/test_approve_embargo_terminations.py/TestApproveEmbargoTerminations.setUp/swapped operands of `-`