<commit_before>from djangosanetesting.cases import DatabaseTestCase

from bbmongostatus.status import MongoDb

from cthulhubot.assignment import Assignment
from cthulhubot.buildbot import get_buildmaster_config
from cthulhubot.models import BuildComputer, JobAssignment, Job
from cthulhubot.views import create_project

from unit_project.tests.helpers import MockJob
from mock import Mock

class TestSchedulers(DatabaseTestCase):
    def setUp(self):
        super(TestSchedulers, self).setUp()
        self.project_name = u"project"
        self.project = create_project(name=self.project_name, tracker_uri="http://example.com")
        self.buildmaster = self.project.buildmaster_set.all()[0]

        self.computer = BuildComputer.objects.create(hostname="localhost")

        job = Job.objects.create(slug='cthulhubot-debian-package-creation')
        job.auto_discovery()

        self.assignment = JobAssignment.objects.create(
            job = job,
            computer = self.computer,
            project = self.project
        )


    def test_single_post_hook_by_default(self):
        config = self.buildmaster.get_config()
        self.assert_equals(1, len(config['schedulers']))

    def test_single_post_hook_by_default_contains_all_builders(self):
        config = self.buildmaster.get_config()
        builders = [builder['name'] for builder in config['builders']]

        scheduler_builders = config['schedulers'][0].builderNames

        self.assert_equals(scheduler_builders, builders)

    def test_builders_generated(self):
        config = self.buildmaster.get_config()
        self.assert_equals(1, len(config['builders']))

    def test_status_fed_in_mongo(self):
        config = self.buildmaster.get_config()
        self.assert_true(MongoDb in [i.__class__ for i in config['status']])<commit_msg>When wofking with commands, they must be configured (fixed tests)<commit_after>from djangosanetesting.cases import DatabaseTestCase

from django.utils.simplejson import dumps
from bbmongostatus.status import MongoDb

from cthulhubot.assignment import Assignment
from cthulhubot.buildbot import get_buildmaster_config
from cthulhubot.models import BuildComputer, JobAssignment, Job, Command
from cthulhubot.views import create_project

from unit_project.tests.helpers import MockJob
from mock import Mock

class TestSchedulers(DatabaseTestCase):
    def setUp(self):
        super(TestSchedulers, self).setUp()
        self.project_name = u"project"
        self.project = create_project(name=self.project_name, tracker_uri="http://example.com")
        self.buildmaster = self.project.buildmaster_set.all()[0]

        self.computer = BuildComputer.objects.create(hostname="localhost")

        job = Job.objects.create(slug='cthulhubot-debian-package-creation')
        job.auto_discovery()
        self.assignment = JobAssignment.objects.create(
            job = job,
            computer = self.computer,
            project = self.project
        )

        self.assignment.config.create(
            command = Command.objects.get(slug='cthulhubot-debian-package-ftp-upload'),
            config = dumps({
                'ftp_user' : 'xxx',
                'ftp_password' : '<PASSWORD>',
                'ftp_directory' : '',
                'ftp_host' : ''
            })
        )


    def test_single_post_hook_by_default(self):
        config = self.buildmaster.get_config()
        self.assert_equals(1, len(config['schedulers']))

    def test_single_post_hook_by_default_contains_all_builders(self):
        config = self.buildmaster.get_config()
        builders = [builder['name'] for builder in config['builders']]

        scheduler_builders = config['schedulers'][0].builderNames

        self.assert_equals(scheduler_builders, builders)

    def test_builders_generated(self):
        config = self.buildmaster.get_config()
        self.assert_equals(1, len(config['builders']))

    def test_status_fed_in_mongo(self):
        config = self.buildmaster.get_config()
        self.assert_true(MongoDb in [i.__class__ for i in config['status']])
{'fraction_non_alphanumeric': 0.09782342871117633, 'fraction_numerical': 0.0019564685742235266, 'mean_word_length': 3.4216216216216218, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '5524444', 'n_tokens_mistral': 1225, 'n_tokens_neox': 1185, 'n_words': 218}