Ejemplo n.º 1
0
    def setUp(self):
        self.session = patch(
            'tagopsdb.Session',
            **{'commit.return_value': None}
        ).start()

        self.tds_package = patch(
            'tds.model.Package.get',
            **{'return_value': PackageFactory()}
        ).start()

        self.tds_env = patch(
            'tds.model.Environment.get',
            **{'side_effect': Mock}
        ).start()

        app_config = DeployConfigFactory()
        self.deploy = tds.commands.DeployController(app_config)

        deploy_methods = [
            ('get_app_info', [AppTargetFactory(name='fake_apptype')]),
            ('perform_deployments', None),
            ('find_app_deployments', {}),
            ('determine_new_deployments', ({}, {})),
            ('validate_project', lambda **kw:
                dict(
                    project=ProjectFactory(name=kw['project']),
                    projects=[ProjectFactory(name=kw['project'])]
                ))
        ]

        for (key, return_value) in deploy_methods:
            for obj in [self.deploy]:
                self.patch_method(obj, key, return_value)
Ejemplo n.º 2
0
    def setUp(self):
        self.tds_project = patch(
            'tds.model.Project',
            **{'get.return_value': Mock(tds.model.Project)})
        self.tds_project.start()

        self.tds_pkg_loc = patch(
            'tagopsdb.PackageLocation',
            **{'get.return_value': Mock(tagopsdb.PackageLocation)})
        self.tds_pkg_loc.start()

        self.tds_pkg = patch('tagopsdb.Package',
                             **{'get.return_value': Mock(tagopsdb.Package)})
        self.tds_pkg.start()

        self.package = tds.commands.PackageController(DeployConfigFactory())

        package_methods = [
            ('_queue_rpm', True),
            ('wait_for_state_change', None),
        ]

        for (key, return_value) in package_methods:
            patcher = patch.object(self.package, key)
            ptch = patcher.start()
            ptch.return_value = return_value
Ejemplo n.º 3
0
    def setUp(self):
        config = DeployConfigFactory()

        mock.patch.object(
            tds.apps.main.TDS,
            '_load_config',
            return_value=config
        ).start()

        dbconfig = DatabaseTestConfigFactory()

        mock.patch.object(
            tds.apps.main.TDS,
            '_load_dbconfig',
            return_value=dbconfig
        ).start()
Ejemplo n.º 4
0
class TestValidationMonitor(DefaultTDPProvider):
    config = DeployConfigFactory()

    def __init__(self, *a, **k):
        val_time = self.config['notifications.validation_time']
        overdue = datetime.now() - timedelta(seconds=val_time + 1)
        not_overdue = datetime.now() - timedelta(seconds=val_time - 1)
        self.app_deps = [
            AppDeploymentFactory(needs_validation=True, realized=ts)
            for ts in [overdue, not_overdue]
        ]

        super(TestValidationMonitor, self).__init__(*a, **k)

    def test_get_deployments_requiring_validation(self):
        vmon = SH.ValidationMonitor(self.config, self.get_tdp())
        deps = vmon.get_deployments_requiring_validation()
        assert len(deps) == 1
Ejemplo n.º 5
0
    def test_notifications_sent(self, Notifications):
        notify = Notifications.return_value.notify
        notify.return_value = None

        params = dict(
            user_level='dev',
            env='dev',  # TODO: mock BaseDeploy.envs
            project=ProjectFactory(name='fake_project'),
            user='******',
            groups=['engteam'],
            apptypes=['fake_apptype'],
            subcommand_name='promote',  # TODO: mock BaseDeploy.dep_types
            command_name='deploy',
            version='badf00d',
            application=ApplicationFactory(),
            package=PackageFactory(version='whatever')
        )

        getattr(self.deploy, params.get('subcommand_name'))(**params)

        deployment = DeploymentFactory()
        Notifications.assert_called_with(DeployConfigFactory())

        notify.assert_called_with(deployment)
Ejemplo n.º 6
0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from mock import patch
import unittest

import tds.notifications.graphite as graphite

from tests.factories.utils.config import DeployConfigFactory
from tests.factories.model.deployment import DeploymentFactory

APP_CONFIG = DeployConfigFactory()


class TestGraphiteNotifier(unittest.TestCase):
    def setUp(self):
        self.graphite_config = APP_CONFIG['notifications']['graphite']
        self.notifier = graphite.GraphiteNotifier(APP_CONFIG,
                                                  self.graphite_config)

        raise NotImplementedError("needs to be converted to 'graphitesend'")
        self.graphite = patch('graphiteudp.GraphiteUDPClient').start()

    def tearDown(self):
        patch.stopall()

    def test_inactive_event(self):
Ejemplo n.º 7
0
 def setUp(self):
     self.app_config = DeployConfigFactory()
     self.config = self.app_config['notifications']