def create_not_plugin(name, can_parse_command_string):
     plugin = mock()
     plugin.canParseCommandString = mock(return_value = can_parse_command_string)
     plugin.updateSettings = mock()
     plugin.name = name
     plugin.processCommandString = mock(return_value = 'modified cmd string')
     return plugin
Example #2
0
 def create_not_plugin(name, can_parse_command_string):
     plugin = mock()
     plugin.canParseCommandString = mock(return_value=can_parse_command_string)
     plugin.updateSettings = mock()
     plugin.name = name
     plugin.processCommandString = mock(return_value='modified cmd string')
     return plugin
Example #3
0
 def create_not_plugin_manager():
     not_plugin_manager = mock()
     self.plugin1 = create_not_plugin('plugin1', True)
     self.plugin2 = create_not_plugin('plugin2', False)
     self.plugin3 = create_not_plugin('plugin3', False)
     self.plugin4 = create_not_plugin('plugin4', False)
     not_plugin_manager.getPlugins = mock(return_value={'plugin1': self.plugin1,
                                                          'plugin2': self.plugin2,
                                                          'plugin3': self.plugin3,
                                                          'plugin4': self.plugin4})
     return not_plugin_manager
 def create_not_plugin_manager():
     not_plugin_manager = mock()
     self.plugin1 = create_not_plugin('plugin1', True)
     self.plugin2 = create_not_plugin('plugin2', False)
     self.plugin3 = create_not_plugin('plugin3', False)
     self.plugin4 = create_not_plugin('plugin4', False)
     not_plugin_manager.getPlugins = mock(return_value = {'plugin1' : self.plugin1,
                                                          'plugin2' : self.plugin2,
                                                          'plugin3' : self.plugin3,
                                                          'plugin4' : self.plugin4})
     return not_plugin_manager
Example #5
0
def setup_module():
    global mock_request
    global response

    mock_request = patch.start()
    mock_request = mock_request()
    mock_request = mock_request.request
    mock_request.return_value = response = mock()
Example #6
0
def mock_request(cookies=None, args=None):
    request = mock()
    if cookies == None:
        cookies = {}
    request.cookies = cookies
    if args == None:
        args = {}
    request.args = args
    return request
Example #7
0
 def __init__(self):
     super(KialiUser, self).__init__()
     self.utils = mock()
     self.identifier = random.getrandbits(128)
     self.influxClient = self.utils.get_influxClient()
     self.min_wait = self.utils.get_minWait()
     self.max_wait = self.utils.get_maxWait()
     self.utils.create_database()
     locust.events.request_success += self.hook_request_success
     locust.events.request_failure += self.hook_request_fail
     locust.events.quitting += self.hook_locust_quit
Example #8
0
    def test_should_buy_not_remove_the_product_in_the_store_if_there_are_not_enough_items(
            self):
        # Creating the mock object
        store: Store = mock()

        # Stubbing
        when(store).are_there_enough_products("Bread", 15).thenReturn(False)

        # Execute
        purchase_order: PurchaseOrder = PurchaseOrder("Bread", 15)
        purchase_order.buy(store)

        # Verify
        verify(store, times=0).remove_products("Bread", 15)
Example #9
0
    def test_shouldBuyWorkIfThereAreProductsTheFirstTimeButNotTheSeconeOne(
            self):
        # Creating the mock object
        store: Store = mock()

        # Stubbing
        when(store).are_there_enough_products("Bread",
                                              15).thenReturn(True, False)

        # Execute
        purchase_order: PurchaseOrder = PurchaseOrder("Bread", 15)
        purchase_order.buy(store)
        purchase_order.buy(store)

        # Verify
        verify(store, times=2).are_there_enough_products("Bread", 15)
        verify(store, times=1).remove_products("Bread", 15)
Example #10
0
    def on_pubmsg(self, c, e):
        global chat_db
        self.log_message(e)
        print(e.source + ' - ' + e.arguments[0])

        #message = e.arguments[0]
        usr = e.tags[3]['value']
        cmd = e.arguments[0].lower().split(' ')[0][1:]
        cmdargs = e.arguments[0].split(' ')[1:]

        if e.tags[3]['value'] in ['Nightbot', 'jnzl']:
            msg = 'hi im ' + e.tags[3]['value'] + ' and ' + e.arguments[
                0].lower()
            mocked_msg = mock(msg)
            self.post_message(mocked_msg)

        elif e.arguments[0][:1] == '!':
            print('Received command: ' + cmd)
            self.do_user_command(e, cmd, cmdargs, usr)

        elif e.arguments[0][:1] == '#':
            if e.tags[7]['value'] == 1 or e.tags[13]['value'] == 'mod':
                print('Received Mod command: ' + cmd)
                self.do_mod_command(e, cmd, cmdargs, usr)
            else:
                print('Ignored Mod command from a user')
                self.post_message('/me #Locals Only, Bro. No Kooks!')
                sleep(2)
                self.post_message(
                    "Commands with '#' are for Mods, Have a siick vid instead - https://www.youtube.com/watch?v=PK28Kaj-X-4"
                )

        elif e.arguments[0].lower().split(' ')[0] in [
                'rephl3xwhut', 'kappa', 'kappapride', 'gachibass'
        ]:
            cmd = e.arguments[0].lower().split(' ')[0]
            print('Received "other" command: ' + cmd)
            self.do_user_command(e, cmd, cmdargs, usr)

        else:
            pass
Example #11
0
    def check_api_graph(self):
        utils = mock()
        additionalParams = {'duration': '1m'}
        global response_json, response_code, number_of_services

        response_code = None
        response_json = None
        number_of_services = None

        url = utils.get_graph_url(namespace="all",
                                  hostname=self.locust.host,
                                  params=additionalParams)

        try:
            with self.client.get(url=url, headers=utils.get_headers(), catch_response=True) \
                as response:
                response_json = json.loads(response.content)
                response_code = response.status_code
                number_of_services = self.count_valid_services(
                    response_json.get('elements').get('nodes'))
        except ValueError:
            response.failure("Something Wrong happened")
Example #12
0
 def unsupervised_layer(self, layer):
     from yadll.layers import AutoEncoder
     return AutoEncoder(incoming=layer, nb_units=25, hyperparameters=mock())
Example #13
0
 def __new__(cls):
     return mock.mock(spec=cls)
Example #14
0
from mock import mock,Mock
#https://stackoverflow.com/questions/16162015/mocking-python-function-based-on-input-arguments #very good examples


mock = MagicMock(side_effect=[4, 5, 6])
print mock()
print mock()
print mock()
mock = Mock(side_effect=Exception('Boom!'))
print mock()
Example #15
0
def setupWP(mock):
    m = mock()
    mock.reset_mock()
    return m
 def create_not_mappers_manager():
     not_mappers_manager = mock()
Example #17
0
def mock_render():
    return mock(side_effect=render)
Example #18
0
def mock_unicode_string(s):
    unicode_string = mock()
    unicode_string.encode = mock(return_value=s)
    return unicode_string
Example #19
0
 def create_not_mappers_manager():
     not_mappers_manager = mock()
def winning_door_is_chosen(context):
    context.rng = mock(return_value=0)
    context.play.place_car(rng=context.rng)
Example #21
0
def mock_response():
    response = mock()
    response.set_cookie = mock()
    return response
Example #22
0
 def named_layer(self):
     from yadll.layers import Layer
     return Layer(mock(), name='layer_name')
def player_picks_a_random_door(context):
    context.rng = mock(return_value=0)
    context.play.pick_random(rng=context.rng)
def car_is_placed_behind_door(context, door):
    context.rng = mock(return_value=door)
    context.play.pick_random(rng=context.rng)
Example #25
0
 def layer(self):
     from yadll.layers import Layer
     return Layer(mock())
Example #26
0
def mock_datetime(now=None):
    if not isinstance(now, datetime):
        now = datetime.now()
    dt = mock()
    dt.now = mock(return_value=now)
    return dt