<commit_before>from twisted.trial import unittest
from twisted.internet.defer import inlineCallbacks
from twisted.python import log
import sys
log.startLogging(sys.stdout)

from globaleaks import db
from globaleaks.settings import transact
from globaleaks.models.receiver import Receiver
from globaleaks.models.node import Node
from globaleaks.tests import helpers
from globaleaks.transactors.asyncoperations import AsyncOperations
from globaleaks.models.context import Context
from globaleaks.transactors.crudoperations import CrudOperations

class TestEmail(helpers.TestHandler):
    @inlineCallbacks
    def setUp(self):
        yield db.createTables(create_node=True)
        yield self._setup_database()
        self.recipe = yield CrudOperations().new_submission({
                'wb_fields': {'city': 1, 'Sun': 2, 'dict2': 1, 'dict3': 1},
                'context_gus': self.ctx['context_gus'],
                'receivers': [self.rcv['receiver_gus']],
                'files': [],
                'finalize': True,
        })
        yield AsyncOperations().tip_creation()
        yield AsyncOperations().tip_notification()

    @transact
    def _setup_database(self):
        self.ctx = Context(self.store).new(helpers.dummyContext)
        self.rcv = Receiver(self.store).new(helpers.dummyReceiver)
        self.rcv['contexts'].append(self.ctx['context_gus'])
        self.ctx['receivers'].append(self.rcv['receiver_gus'])
        self.ctx['selectable_receiver'] = False

        self.rcv['notification_fields']['mail_address'] = '<EMAIL>'
        Receiver(self.store).update(self.rcv['receiver_gus'], self.rcv)
        Context(self.store).update(self.ctx['context_gus'], self.ctx)

        node = self.store.find(Node).one()
        node.notification_settings = {
                "server": "box549.bluehost.com",
                "port":25,
                "username":"<EMAIL>",
                "password":"<PASSWORD>",
                "ssl":False
        }


    def test_sendmail(self):
        print self.recipe





<commit_msg>fixed email test: maker check your mail ;)<commit_after>from twisted.trial import unittest
from twisted.internet.defer import inlineCallbacks
from twisted.python import log
import sys
log.startLogging(sys.stdout)

from globaleaks import db
from globaleaks.settings import transact
from globaleaks.models.receiver import Receiver
from globaleaks.models.node import Node
from globaleaks.tests import helpers
from globaleaks.transactors.asyncoperations import AsyncOperations
from globaleaks.models.context import Context
from globaleaks.transactors.crudoperations import CrudOperations

class TestEmail(helpers.TestHandler):
    @inlineCallbacks
    def setUp(self):
        yield db.createTables(create_node=True)
        yield self._setup_database()
        self.recipe = yield CrudOperations().new_submission({
                'wb_fields': {'city': 1, 'Sun': 2, 'dict2': 1, 'dict3': 1},
                'context_gus': self.ctx['context_gus'],
                'receivers': [self.rcv['receiver_gus']],
                'files': [],
                'finalize': True,
        })
        yield AsyncOperations().tip_creation()
        yield AsyncOperations().tip_notification()

    @transact
    def _setup_database(self):

        self.ctx = Context(self.store).new(helpers.dummyContext)
        self.rcv = Receiver(self.store).new(helpers.dummyReceiver)

        self.rcv['contexts'].append(self.ctx['context_gus'])
        self.rcv['notification_fields']['mail_address'] = '<EMAIL>'
        self.rcv['receiver_level'] = 1
        self.newrcv = Receiver(self.store).update(self.rcv['receiver_gus'], self.rcv)

        # Assign Receiver to the Context
        Receiver(self.store).receiver_align(self.rcv['receiver_gus'], [ self.ctx['context_gus'] ] )
        Context(self.store).full_context_align(self.rcv['receiver_gus'], [ self.ctx['context_gus']] )

        receiver_desc = Receiver(self.store).get_single(self.rcv['receiver_gus'])
        context_desc = Context(self.store).get_single(self.ctx['context_gus'])

        node = self.store.find(Node).one()
        node.notification_settings = {
                "server": "box549.bluehost.com",
                "port":25,
                "username":"<EMAIL>",
                "password":"<PASSWORD>",
                "ssl":False
        }


    def test_sendmail(self):
        print self.recipe






{'fraction_non_alphanumeric': 0.12289485662266728, 'fraction_numerical': 0.005234410559854347, 'mean_word_length': 3.028414298808433, 'pattern_counts': {'":': 10, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5941', 'n_tokens_mistral': 1335, 'n_tokens_neox': 1264, 'n_words': 236}