Example #1
0
    def test_release_if_project_does_not_exist(self):
        """
        Verify create.release works properly if a project does not exist
        """
        with mock.patch(
                'recore.job.create.recore.mongo') as create.recore.mongo:
            create.recore.mongo.lookup_playbook = mock.MagicMock(
                return_value={})

            assert create.release(channel, 'test', 'replyto', {}, '000000000000000007654321') is None
Example #2
0
    def test_invalid_pbid(self):
        """
        We don't leave re-rest hanging if an invalid pbid is given
        """
        with mock.patch(
                'recore.job.create.recore.mongo') as create.recore.mongo:
            create.recore.mongo.lookup_playbook = mock.MagicMock(
                side_effect=bson.errors.InvalidId)

            assert create.release(channel, '6', 'replyto', {}, '000000000000000007654321') is None
            self.assertEqual(channel.basic_publish.call_args_list[0][1]['body'], '{"id": null}')
Example #3
0
    def test_release_with_good_data(self):
        """
        Verify create.release works when everything is perfect
        """
        with mock.patch(
                'recore.job.create.recore.mongo') as create.recore.mongo:
            create.recore.mongo.lookup_project = mock.MagicMock(
                return_value={"project": "test"})
            create.recore.mongo.initialize_state = mock.MagicMock(
                return_value=1234567890)

            assert create.release(channel, 'test', 'replyto', {}) == "1234567890"
            channel.basic_publish.assert_called_with(
                exchange='',
                routing_key='replyto',
                body='{"id": "1234567890"}')