Esempio n. 1
0
    async def test_advance_target(self, *args):
        with asynctest.patch.object(Service, 'get_by_id') as get_by_id_mock:
            with asynctest.patch.object(Service, 'update') as update_mock:
                mock_id = 'some-value'
                mock_db = MagicMock()
                mock_service = {
                    'targets': [],
                }
                get_by_id_mock.return_value = mock_service
                await Service.advance_target(mock_id, mock_db)
                update_mock.assert_not_awaited()

                mock_service = {
                    'targets': ['some-value', 'some-value'],
                    'cur_target_index': 0
                }
                get_by_id_mock.return_value = mock_service
                await Service.advance_target(mock_id, mock_db)
                update_mock.assert_called()
                expect(update_mock.call_args[0][0]).to(equal(mock_id))
                expect(update_mock.call_args[0][1]['cur_target_index']).to(
                    be_above(mock_service['cur_target_index']))
                expect(update_mock.call_args[0][2]).to(equal(mock_db))

                mock_service = {
                    'targets': ['some-value', 'some-value'],
                    'cur_target_index': 1
                }
                get_by_id_mock.return_value = mock_service
                await Service.advance_target(mock_id, mock_db)
                update_mock.assert_called()
                expect(update_mock.call_args[0][0]).to(equal(mock_id))
                expect(update_mock.call_args[0][1]['cur_target_index']).to(
                    be_below(mock_service['cur_target_index']))
                expect(update_mock.call_args[0][2]).to(equal(mock_db))
 def _match(self, load):
     expect(load).to(be_a(client.models.TrafficLoad))
     if (load.burst_size):
         expect(load.burst_size).to(be_above(0))
         expect(load.burst_size).to(be_below(65536))
     expect(load.rate).not_to(be_none)
     expect(load.rate.period).not_to(be_none)
     expect(load.rate.value).to(be_above(0))
     expect(load.units).not_to(be_empty)
     return True, ['is valid traffic load']
Esempio n. 3
0
 def test_lt_returns_false(self):
     expect(EmptyFake()).not_to(be_below(42))
Esempio n. 4
0
import datetime

import pytz
from expects import (be_above, be_below, be_false, be_true, equal, expect,
                     raise_error)
from mamba import (description, it)

from domain_events import Event


class DumbEvent(Event):
    def __init__(self, name, *args, **kwargs):
        super(DumbEvent, self).__init__(*args, **kwargs)
        self.name = name


with description('Event'):
    with it('has a type name'):
        domain_event = DumbEvent(name="Test Event")

        expect(domain_event.type_name).to(equal("specs/event_spec.DumbEvent"))
        expect(domain_event.type_name).to(equal(DumbEvent.type_name()))

    with it('has a occurred_on datetime'):
        before_event = datetime.datetime.now(tz=pytz.utc)
        domain_event = DumbEvent(name="Test Event")
        after_event = datetime.datetime.now(tz=pytz.utc)

        expect(domain_event.occurred_on).to(be_above(before_event))
        expect(domain_event.occurred_on).to(be_below(after_event))
Esempio n. 5
0
 def test_text_not_find_be_a_negative_number( self, chibi_file,
                                              no_text_in_the_file ):
     find = chibi_file.find( no_text_in_the_file )
     expect( find ).to( be_below( 0 ) )
            def _test_sut(items):
                result = get_positives(items)

                expect(result).not_to(contain(zero))
                expect(result).not_to(contain(be_below(zero)))
Esempio n. 7
0
    with it('Testing Kafka functionality'):
        proc_a = mp.Process(target=check_kafka_logs,
                            args=(self, kafka_mp_output))
        proc_b = mp.Process(target=generate_kafka_mock_request)
        proc_a.start()
        proc_b.start()
        proc_a.join()
        proc_b.join()
        result = kafka_mp_output.get()
        for i in result.split('\n'):
            d = json.loads(i)
            if d['request_path'] == "/productpage":
                expect(d['request_headers']['x-request-id']).to(
                    equal('MOCK_REQ_ID'))
                expect(d['request_headers']['user-agent']).to(
                    equal('MOCK_UserAgent'))
                expect(d['request_headers']['content-type']).to(
                    equal('MOCK_CONTENT_TYPE'))
                expect(d['request_headers']['x-b3-traceid']).to(
                    equal('aaaaaaaaaaaaaaaa'))
                expect(d['request_headers']['x-b3-parentspanid']).to(
                    equal('bbbbbbbbbbbbbbbb'))
                expect(d['request_headers']['host']).to(
                    equal(configuration.GATEWAY_URL))
                expect(d['request_size']).to(be_below(600))
                expect(d['response_duration']).to(be_below(6000))
                expect(d['response_code']).to(equal(200))
                expect(d['response_size']).to(be_below(6000))
                message = 'found'
        expect(message).to(equal('found'))