Exemplo n.º 1
0
    def test_application_info(self):

        app_info = {
            'text_key': u'a value',
            'byte_key': b'bytes',
            'int_key': 7,
            'list_key': [42,]
        }

        class IA(Interface):

            field = Attribute("A field")
            field.setTaggedValue(jsonschema.TAG_APPLICATION_INFO, app_info)

        schema = TranslateTestSchema(IA, context=u' TEST').make_schema()

        assert_that(schema, has_key("field"))
        field = schema['field']
        assert_that(field, has_key("application_info"))
        # The dict itself was copied
        assert_that(field['application_info'], is_not(same_instance(app_info)))
        # as were its contents
        assert_that(field['application_info'], has_entry('list_key', is_([42])))
        assert_that(field['application_info'],
                    has_entry('list_key', is_not(same_instance(app_info['list_key']))))

        # Text strings were translated
        assert_that(field['application_info'], has_entry('text_key', u'a value TEST'))

        # Byte strings were not (is that even legel in json?)
        assert_that(field['application_info'], has_entry('byte_key', b'bytes'))
Exemplo n.º 2
0
    def test_connection_port_not_in_hba_port_set(self):
        ports = self.hba_port_set()
        c_port = VNXConnectionPort(sp='a', port_id=4, cli=t_cli())
        assert_that(ports, is_not(has_item(c_port)))

        c_port = VNXConnectionPort(sp='a', port_id=9, cli=t_cli())
        assert_that(ports, is_not(has_item(c_port)))
Exemplo n.º 3
0
    def assert_func_key_row_created(self, destination_row):
        assert_that(destination_row, is_not(none()))

        row = (self.session.query(FuncKeySchema)
               .filter(FuncKeySchema.id == destination_row.func_key_id)
               .first())
        assert_that(row, is_not(none()))
Exemplo n.º 4
0
def step(context):
    prs = context.prs
    assert_that(prs, is_not(None))
    slidemasters = prs.slidemasters
    assert_that(slidemasters, is_not(None))
    assert_that(len(slidemasters), is_(1))
    slidelayouts = slidemasters[0].slidelayouts
    assert_that(slidelayouts, is_not(None))
    assert_that(len(slidelayouts), is_(11))
    def test_encrypted(self):
        with SessionContext(self.graph):
            with transaction():
                encryptable = self.encryptable_store.create(
                    Encryptable(
                        key="private",
                        value="value",
                    ),
                )

            assert_that(
                encryptable,
                has_properties(
                    key=is_(equal_to("private")),
                    value=is_(none()),
                    encrypted_id=is_not(none()),
                ),
            )
            assert_that(
                encryptable._members(),
                is_(equal_to(dict(
                    created_at=encryptable.created_at,
                    encrypted_id=encryptable.encrypted_id,
                    id=encryptable.id,
                    key=encryptable.key,
                    updated_at=encryptable.updated_at,
                ))),
            )
            assert_that(
                self.encryptable_store.count(), is_(equal_to(1)),
            )
            assert_that(
                self.encrypted_store.count(), is_(equal_to(1)),
            )

            # NB: ORM events will not trigger if we can reuse the object from the session cache
            self.encryptable_store.expunge(encryptable)

            encryptable = self.encryptable_store.retrieve(encryptable.id)
            assert_that(
                encryptable,
                has_properties(
                    key=is_(equal_to("private")),
                    value=is_(equal_to("value")),
                    encrypted_id=is_not(none()),
                ),
            )

            with transaction():
                self.encryptable_store.delete(encryptable.id)

            assert_that(
                self.encryptable_store.count(), is_(equal_to(0)),
            )
            assert_that(
                self.encrypted_store.count(), is_(equal_to(0)),
            )
Exemplo n.º 6
0
def step_then_receive_prs_based_on_def_tmpl(context):
    prs = context.prs
    assert_that(prs, is_not(None))
    slidemasters = prs.slidemasters
    assert_that(slidemasters, is_not(None))
    assert_that(len(slidemasters), is_(1))
    slidelayouts = slidemasters[0].slidelayouts
    assert_that(slidelayouts, is_not(None))
    assert_that(len(slidelayouts), is_(11))
Exemplo n.º 7
0
    def test_given_row_with_option_set_to_null_then_option_not_returned(self):
        row = self.add_usersip(language=None,
                               allow=None,
                               setvar='')

        sip = dao.get(row.id)
        assert_that(sip.options, is_not(has_item(has_item("language"))))
        assert_that(sip.options, is_not(has_item(has_item("allow"))))
        assert_that(sip.options, is_not(has_item(has_item("setvar"))))
Exemplo n.º 8
0
def test_long_connection_loadbalancing():
    """
    Title: Balances traffic correctly when topology changes during a long running connection.

    Scenario:
    When: A VM sends TCP packets to a VIP's IP address / port, long running connections.
    And:  We have 3 backends of equal weight.
    Then: When pool member disabled during connection, non-sticky connections should still succeed
          When other devices are disabled during connection, non-sticky connections should break
    """
    sender = BM.get_iface_for_port('bridge-000-003', 1)
    pool_member_1 = VTM.find_pool_member(backend_ip_port(1))
    pool_member_2 = VTM.find_pool_member(backend_ip_port(2))
    pool_member_3 = VTM.find_pool_member(backend_ip_port(3))
    # Disable all but one backend
    pool_member_2.disable()
    pool_member_3.disable()


    # Should point to the only enabled backend 10.0.2.1
    result = make_request_to(sender, STICKY_VIP, timeout=20, src_port=12345)
    assert_that(result, equal_to('10.0.2.1'))
    result = make_request_to(sender, NON_STICKY_VIP, timeout=20, src_port=12345)
    assert_that(result, equal_to('10.0.2.1'))

    # Disable the one remaining backend (STICKY) and enable another one (NON_STICKY)
    pool_member_1.disable()
    pool_member_2.enable()
    pool_member_2.enable()

    # Connections from the same src ip / port will be counted as the same ongoing connection
    # Sticky traffic fails - connection dropped. It should reroute to an enabled backend?
    result = make_request_to(sender, STICKY_VIP, timeout=20, src_port=12345)
    # Is that right? Shouldn't midonet change to another backend?
    assert_that(result, equal_to(''))
    #assert_request_fails_to(sender, STICKY_VIP, timeout=20, src_port=12345)
    # Non sticky traffic succeeds - connection allowed to continue
    result = make_request_to(sender, NON_STICKY_VIP, timeout=20, src_port=12345)
    # It's not the disabled backend
    assert_that(result, is_not(equal_to('10.0.2.1')))
    # But some backend answers
    assert_that(result, is_not(equal_to('')))

    # Re-enable the sticky backend
    pool_member_1.enable()

    assert_request_succeeds_to(sender, STICKY_VIP, timeout=20, src_port=12345)
    assert_request_succeeds_to(sender, NON_STICKY_VIP, timeout=20, src_port=12345)

    # When disabling the loadbalancer, both sticky and non sticky fail
    action_loadbalancer("disable")

    assert_request_fails_to(sender, STICKY_VIP)
    assert_request_fails_to(sender, NON_STICKY_VIP)

    action_loadbalancer("enable")
    def test_GIVEN_output_parameters_already_chosen_WHEN_page_get_THEN_parameters_rendered(self):
        self.app.post(
            url(controller='model_run', action='output'),
            params=self.valid_params)
        response = self.app.get(url(controller='model_run', action='output'))
        doc = html.fromstring(response.normal_body)
        
        # Check that the first output variable is displayed, selected and the yearly and monthly period boxes selected:
        output_row_1 = doc.xpath('//div[@id="output_row_1"]/@style')
        assert_that(output_row_1, is_not(contains_string('display:none')))
        ov_select_1 = doc.xpath('//input[@name="ov_select_1"]/@checked')
        ov_yearly_1 = doc.xpath('//input[@name="ov_yearly_1"]/@checked')
        ov_monthly_1 = doc.xpath('//input[@name="ov_monthly_1"]/@checked')
        ov_daily_1 = doc.xpath('//input[@name="ov_daily_1"]/@checked')
        ov_hourly_1 = doc.xpath('//input[@name="ov_hourly_1"]/@checked')
        assert_that(len(ov_select_1), is_(1))
        assert_that(len(ov_yearly_1), is_(1))
        assert_that(len(ov_monthly_1), is_(1))
        assert_that(len(ov_daily_1), is_(0))
        assert_that(len(ov_hourly_1), is_(0))
        
        # For the second we expect the same but with the hourly period box selected
        output_row_2 = doc.xpath('//div[@id="output_row_2"]/@style')
        assert_that(output_row_2, is_not(contains_string('display:none')))
        ov_select_2 = doc.xpath('//input[@name="ov_select_2"]/@checked')
        ov_yearly_2 = doc.xpath('//input[@name="ov_yearly_2"]/@checked')
        ov_monthly_2 = doc.xpath('//input[@name="ov_monthly_2"]/@checked')
        ov_daily_2 = doc.xpath('//input[@name="ov_daily_2"]/@checked')
        ov_hourly_2 = doc.xpath('//input[@name="ov_hourly_2"]/@checked')
        assert_that(len(ov_select_2), is_(1))
        assert_that(len(ov_yearly_2), is_(0))
        assert_that(len(ov_monthly_2), is_(0))
        assert_that(len(ov_daily_2), is_(1))
        assert_that(len(ov_hourly_2), is_(1))
        
        # For the third we expect the monthly box selected
        output_row_3 = doc.xpath('//div[@id="output_row_3"]/@style')
        assert_that(output_row_3, is_not(contains_string('display:none')))
        ov_select_3 = doc.xpath('//input[@name="ov_select_3"]/@checked')
        ov_yearly_3 = doc.xpath('//input[@name="ov_yearly_3"]/@checked')
        ov_monthly_3 = doc.xpath('//input[@name="ov_monthly_3"]/@checked')
        ov_daily_3 = doc.xpath('//input[@name="ov_daily_3"]/@checked')
        ov_hourly_3 = doc.xpath('//input[@name="ov_hourly_3"]/@checked')
        assert_that(len(ov_select_3), is_(1))
        assert_that(len(ov_yearly_3), is_(0))
        assert_that(len(ov_monthly_3), is_(1))
        assert_that(len(ov_daily_3), is_(0))
        assert_that(len(ov_hourly_3), is_(0))
        
        # Finally we check that no other output parameters are selected or visible
        ov_selects = doc.xpath('//input[contains(@name, "ov_select_") and not(@checked)]')
        n_output_params = len(self.model_run_service.get_output_variables(include_depends_on_nsmax=False))
        assert_that(len(ov_selects), is_(n_output_params - 3))

        invisible_rows = doc.xpath('//div[contains(@id, "output_row_") and contains(@style, "display:none")]')
        assert_that(len(invisible_rows), is_(n_output_params - 3))
 def test_construction_with_no_path_loads_default_template(self):
     """_Package() call with no path loads default template"""
     prs = _Package().presentation
     assert_that(prs, is_not(None))
     slidemasters = prs.slidemasters
     assert_that(slidemasters, is_not(None))
     assert_that(len(slidemasters), is_(1))
     slidelayouts = slidemasters[0].slidelayouts
     assert_that(slidelayouts, is_not(None))
     assert_that(len(slidelayouts), is_(11))
Exemplo n.º 11
0
 def test_parser_wapiti_xml_parse_report(self, mock_lxml_etree_parse):
     from .wapiti_reports_2_3_0 import report_high
     with mock.patch('ptp.libptp.parser.AbstractParser._recursive_find', return_value=[report_high]):
         WapitiXMLParser.__format__ = ''
         my_wapiti = WapitiXMLParser()
         report = my_wapiti.parse_report()
         assert_that(report, has_items(*[{'ranking': HIGH, 'name': 'Cross Site Scripting', 'description': '\nCross-site scripting (XSS) is a type of computer security vulnerability typically found in web applications which allow code injection by malicious web users into the web pages viewed by other users. Examples of such code include HTML code and client-side scripts.            '}] * 1))
         assert_that(report, is_not(has_item([{'ranking': LOW}])))
         assert_that(report, is_not(has_item([{'ranking': UNKNOWN}])))
         assert_that(report, is_not(has_item([{'ranking': INFO}])))
         assert_that(report, is_not(has_item([{'ranking': MEDIUM}])))
Exemplo n.º 12
0
Arquivo: test_ptp.py Projeto: owtf/ptp
 def test_ptp_no_cumulative_parsing(self):
     my_ptp = PTP(cumulative=False)
     my_ptp.parser = MockParserInfo()  # Tool 1, first run
     report = my_ptp.parse()
     assert_that(1, equal_to(len(report)))
     assert_that(report, has_item({'ranking': constants.INFO}))
     assert_that(report, is_not(has_item({'ranking': constants.HIGH})))
     my_ptp.parser = MockParserHigh()  # Tool 2, second run
     report = my_ptp.parse()
     assert_that(1, equal_to(len(report)))
     assert_that(report, has_item({'ranking': constants.HIGH}))
     assert_that(report, is_not(has_item({'ranking': constants.INFO})))
Exemplo n.º 13
0
    def test_eq_hash_no_super(self):
        thing1 = ChildThingNoSuper()
        thing2 = ChildThingNoSuper()

        assert_that(thing1, is_(thing2))
        assert_that(hash(thing1), is_(hash(thing2)))

        thing1.a = 'A'
        assert_that(thing1, is_(thing2))
        assert_that(hash(thing1), is_(hash(thing2)))

        thing1.c = 'C'
        assert_that(thing1, is_not(thing2))
        assert_that(hash(thing1), is_not(hash(thing2)))
Exemplo n.º 14
0
    def testCloneNode(self):
        doc = Document()
        one = doc.createElement('one')
        two = doc.createElement('two')
        three = doc.createTextNode('three')
        two.append(three)
        one.append(two)

        res = one.cloneNode(1)
        assert type(res) is type(one), '"%s" != "%s"' % (type(res), type(one))
        assert type(res[0]) is type(one[0])
        assert_that( res, is_(one))
        assert_that( res, is_not(same_instance(one)))
        assert_that( res[0], is_not( same_instance(one[0]) ))
Exemplo n.º 15
0
    def test_to_user_data(self):
        line_sip = LineSIP()
        line_sip.private_value = 'private_value'
        provisioning_extension = line_sip.provisioning_extension = '192837'
        username = line_sip.username = '******'

        line_sip_dict = line_sip.to_user_data()

        assert_that(line_sip_dict, has_entries({
            'provisioning_extension': provisioning_extension,
            'username': username,
        }))
        assert_that(line_sip_dict, all_of(is_not(has_key('private_value')),  # not mapped
                                          is_not(has_key('secret'))))  # not set
Exemplo n.º 16
0
 def test_equal(self):
     """Testing of Rectangle2d.__eq__ method."""
     rectangle_a = Rectangle2d(Point2d(1, 2), 3, 4)
     rectangle_b = Rectangle2d(Point2d(1, 2), 3, 4)
     rectangle_c = Rectangle2d(Point2d(2, 2), 3, 4)
     rectangle_d = Rectangle2d(Point2d(1, 2), 5, 4)
     rectangle_e = Rectangle2d(Point2d(1, 2), 3, 5)
     rectangle_f = Rectangle2d(Point2d(1, 2), 3, 4, Vector2d(0, 1))
     assert_that(rectangle_a, equal_to(rectangle_b))
     assert_that(rectangle_a, is_not(equal_to(rectangle_c)))
     assert_that(rectangle_a, is_not(equal_to(rectangle_d)))
     assert_that(rectangle_a, is_not(equal_to(rectangle_e)))
     assert_that(rectangle_a, is_not(equal_to(rectangle_f)))
     assert_that(rectangle_a.__eq__(1234), equal_to(False))
Exemplo n.º 17
0
 def test_parser_owasp_cm008_parse_report(self, mock_handle):
     from .owasp_cm008_reports import report_low
     my_cm008 = OWASPCM008Parser(report_low)
     report = my_cm008.parse_report()
     assert_that(report, has_items(*[{'ranking': UNKNOWN}] * 2))
     assert_that(report, has_items(*[{'ranking': LOW}] * 2))
     assert_that(report, is_not(has_item([{'ranking': INFO}])))
     assert_that(report, is_not(has_item([{'ranking': MEDIUM}])))
     assert_that(report, is_not(has_item([{'ranking': HIGH}])))
     from .owasp_cm008_reports import report_medium
     my_cm008 = OWASPCM008Parser(report_medium)
     report = my_cm008.parse_report()
     assert_that(report, has_items(*[{'ranking': UNKNOWN}] * 1))
     assert_that(report, has_items(*[{'ranking': MEDIUM}] * 1))
     assert_that(report, is_not(has_item([{'ranking': INFO}])))
     assert_that(report, is_not(has_item([{'ranking': LOW}])))
     assert_that(report, is_not(has_item([{'ranking': HIGH}])))
     from .owasp_cm008_reports import report_high
     my_cm008 = OWASPCM008Parser(report_high)
     report = my_cm008.parse_report()
     assert_that(report, has_items(*[{'ranking': UNKNOWN}] * 2))
     assert_that(report, has_items(*[{'ranking': LOW}] * 2))
     assert_that(report, has_items(*[{'ranking': HIGH}] * 1))
     assert_that(report, is_not(has_item([{'ranking': INFO}])))
     assert_that(report, is_not(has_item([{'ranking': MEDIUM}])))
Exemplo n.º 18
0
    def test_swagger(self):
        response = self.client.get("/api/swagger")
        assert_that(response.status_code, is_(equal_to(200)))
        data = loads(response.data)

        upload = data["paths"]["/file"]["post"]
        upload_for = data["paths"]["/person/{person_id}/file"]["post"]

        # both endpoints return form data
        assert_that(
            upload["consumes"],
            contains("multipart/form-data"),
        )
        assert_that(
            upload_for["consumes"],
            contains("multipart/form-data"),
        )

        # one endpoint gets an extra query string parameter (and the other doesn't)
        assert_that(
            upload["parameters"],
            has_item(
                has_entries(name="extra"),
            ),
        )
        assert_that(
            upload_for["parameters"],
            has_item(
                is_not(has_entries(name="extra")),
            ),
        )

        # one endpoint gets a custom response type (and the other doesn't)
        assert_that(
            upload["responses"],
            all_of(
                has_key("204"),
                is_not(has_key("200")),
                has_entry("204", is_not(has_key("schema"))),
            ),
        )
        assert_that(
            upload_for["responses"],
            all_of(
                has_key("200"),
                is_not(has_key("204")),
                has_entry("200", has_entry("schema", has_entry("$ref", "#/definitions/FileResponse"))),
            ),
        )
Exemplo n.º 19
0
    def test_given_user_destination_then_func_key_created(self):
        user_row = self.add_user()

        func_key = FuncKey(type='speeddial',
                           destination='user',
                           destination_id=user_row.id)

        created_func_key = dao.create(func_key)
        assert_that(created_func_key, instance_of(FuncKey))
        assert_that(created_func_key, has_property('id', is_not(none())))

        user_destination_row = self.find_destination('user', user_row.id)
        assert_that(user_destination_row, is_not(none()))

        self.assert_func_key_row_created(user_destination_row)
 def test_that_config_includes_a_backends_list_if_config_contains_backends_definition(self):
     root = ET.Element('config')
     backends = ET.SubElement(root, 'backends')
     name = 'db'
     plugin = 'mysql'
     ET.SubElement(backends, 'backend', {'name':name, 'plugin':plugin})
     op = BackendParser()
     _dump_xml_as_file(root, 'backend.xml')
     op.parse(root)
     result = op.backends
     
     assert_that(result, is_not(None))
     assert_that(len(result), is_not(0))
     assert_that(result, has_key(name))
     assert_that(result[name].plugin, is_(plugin))
Exemplo n.º 21
0
    def test_given_group_destination_then_func_key_created(self):
        group_row = self.add_group()

        func_key = FuncKey(type='speeddial',
                           destination='group',
                           destination_id=group_row.id)

        created_func_key = dao.create(func_key)
        assert_that(created_func_key, instance_of(FuncKey))
        assert_that(created_func_key, has_property('id', is_not(none())))

        group_destination_row = self.find_destination('group', group_row.id)
        assert_that(group_destination_row, is_not(none()))

        self.assert_func_key_row_created(group_destination_row)
Exemplo n.º 22
0
    def test_given_queue_destination_then_func_key_created(self):
        queue_row = self.add_queuefeatures()

        func_key = FuncKey(type='speeddial',
                           destination='queue',
                           destination_id=queue_row.id)

        created_func_key = dao.create(func_key)
        assert_that(created_func_key, instance_of(FuncKey))
        assert_that(created_func_key, has_property('id', is_not(none())))

        queue_destination_row = self.find_destination('queue', queue_row.id)
        assert_that(queue_destination_row, is_not(none()))

        self.assert_func_key_row_created(queue_destination_row)
Exemplo n.º 23
0
    def test_given_conference_destination_then_func_key_created(self):
        conference_row = self.add_meetmefeatures()

        func_key = FuncKey(type='speeddial',
                           destination='conference',
                           destination_id=conference_row.id)

        created_func_key = dao.create(func_key)
        assert_that(created_func_key, instance_of(FuncKey))
        assert_that(created_func_key, has_property('id', is_not(none())))

        conference_destination_row = self.find_destination('conference', conference_row.id)
        assert_that(conference_destination_row, is_not(none()))

        self.assert_func_key_row_created(conference_destination_row)
Exemplo n.º 24
0
def assert_command_error(response, prefix, hint=None):
    """Verifies structure and basic content of command processor errors"""

    print tostring(response)

    err_el = response.find("error")
    assert_that(err_el, is_not(None))
    desc_el = err_el.find("desc")
    assert_that(desc_el, is_not(None))
    assert_that(desc_el.text, starts_with(prefix))

    if hint:
        hint_el = err_el.find("hint")
        assert_that(hint_el, is_not(None))
        assert_that(hint_el.text, starts_with(hint))
    def test_update_with_key(self):
        with SessionContext(self.graph):
            with transaction():
                encryptable = self.encryptable_store.create(
                    Encryptable(
                        key="private",
                        value="value",
                    ),
                )

        with SessionContext(self.graph):
            with transaction():
                res = self.encryptable_store.update(
                    encryptable.id,
                    Encryptable(
                        id=encryptable.id,
                        # Pass the key
                        key="private",
                        value="new-value",
                    ),
                )
                assert_that(
                    res,
                    has_properties(
                        key=is_(equal_to("private")),
                        value=is_(equal_to("new-value")),
                        encrypted_id=is_not(none()),
                    ),
                )

        with SessionContext(self.graph):
            encryptable = self.encryptable_store.retrieve(encryptable.id)

            assert_that(
                encryptable,
                has_properties(
                    key=is_(equal_to("private")),
                    value=is_(equal_to("new-value")),
                    encrypted_id=is_not(none()),
                ),
            )

            assert_that(
                self.encryptable_store.count(), is_(equal_to(1)),
            )
            assert_that(
                self.encrypted_store.count(), is_(equal_to(1)),
            )
Exemplo n.º 26
0
def GetCompletions_MaxDetailedCompletion_test( app ):
  RunTest( app, {
    'expect': {
      'data': has_entries( {
        'completions': all_of(
          contains_inanyorder(
            CompletionEntryMatcher( 'methodA' ),
            CompletionEntryMatcher( 'methodB' ),
            CompletionEntryMatcher( 'methodC' ),
          ),
          is_not( any_of(
            has_item(
              CompletionEntryMatcher( 'methodA', extra_params = {
                'menu_text': 'methodA (method) Foo.methodA(): void' } ) ),
            has_item(
              CompletionEntryMatcher( 'methodB', extra_params = {
                'menu_text': 'methodB (method) Foo.methodB(): void' } ) ),
            has_item(
              CompletionEntryMatcher( 'methodC', extra_params = {
                'menu_text': ( 'methodC (method) Foo.methodC(a: '
                               '{ foo: string; bar: number; }): void' ) } ) )
          ) )
        )
      } )
    }
  } )
Exemplo n.º 27
0
def EventNotification_FileReadyToParse_SyntaxKeywords_SeedWithCache_test(
    ycm, *args ):

  current_buffer = VimBuffer( name = 'current_buffer',
                              filetype = 'some_filetype' )

  with patch( 'ycm.client.event_notification.EventNotification.'
              'PostDataToHandlerAsync' ) as post_data_to_handler_async:
    with MockVimBuffers( [ current_buffer ], [ current_buffer ] ):
      ycm.OnFileReadyToParse()
      assert_that(
        # Positional arguments passed to PostDataToHandlerAsync.
        post_data_to_handler_async.call_args[ 0 ],
        contains(
          has_entry( 'syntax_keywords', has_items( 'foo', 'bar' ) ),
          'event_notification'
        )
      )

      # Do not send again syntax keywords in subsequent requests.
      ycm.OnFileReadyToParse()
      assert_that(
        # Positional arguments passed to PostDataToHandlerAsync.
        post_data_to_handler_async.call_args[ 0 ],
        contains(
          is_not( has_key( 'syntax_keywords' ) ),
          'event_notification'
        )
      )
Exemplo n.º 28
0
    def test_unicode_license(self):
        """invalid_license uses unicode copyright and multiline years.

        Where copyright is ©.
        """
        errors = check_license(self.invalid_license, year=2014)
        assert_that(errors, is_not(has_item("25: L101 copyright is missing")))
Exemplo n.º 29
0
def test_mmctl_unbinding_without_mm_running():
    """
    Title: Unbinding a port using mmctl when midolman is not running
    """
    mm1 = service.get_container_by_hostname('midolman1')
    port1 = VTM.port1
    iface_port2 = BM.get_interface_on_vport('port2')

    iface = mm1.create_vmguest(hw_addr=port1['mac_address'])
    VTM.addCleanup(iface.destroy)

    mm1.bind_port(iface, port1['id'], BindingType.MMCTL)
    VTM.addCleanup(mm1.unbind_port, iface, BindingType.MMCTL)

    iface.dhclient()
    iface.try_command_blocking("ping -c 5 %s" % (iface_port2.get_ip()))

    mm1.stop()

    mm1.unbind_port(iface, BindingType.MMCTL)

    mm1.start()

    ret = iface.exec_command_blocking("ping -c 5 %s" % (iface_port2.get_ip()))
    # Ping returns 0 if the ping succeeds, 1 or 2 on error conditions.
    assert_that(ret,
                is_not(equal_to(0)),
                "Ping should have failed, but did not.")
 def test_saved_file_has_plausible_contents(self):
     """_Package.save produces a .pptx with plausible contents"""
     # setup ------------------------
     pkg = _Package()
     # exercise ---------------------
     pkg.save(self.test_pptx_path)
     # verify -----------------------
     pkg = _Package(self.test_pptx_path)
     prs = pkg.presentation
     assert_that(prs, is_not(None))
     slidemasters = prs.slidemasters
     assert_that(slidemasters, is_not(None))
     assert_that(len(slidemasters), is_(1))
     slidelayouts = slidemasters[0].slidelayouts
     assert_that(slidelayouts, is_not(None))
     assert_that(len(slidelayouts), is_(11))
Exemplo n.º 31
0
 def test_bad_sampling(self):
     assert_that(self.timer, is_not(is_counter('foo', '100', None)))
Exemplo n.º 32
0
    def assert_private_template_created(self, template_id):
        template_row = self.session.query(FuncKeyTemplateSchema).get(template_id)
        assert_that(template_row, is_not(none()))

        assert_that(template_row, has_property('private', True))
        assert_that(template_row, has_property('name', none()))
Exemplo n.º 33
0
    def test_encrypted(self):
        with SessionContext(self.graph):
            with transaction():
                encryptable = self.encryptable_store.create(
                    Encryptable(
                        key="private",
                        value="value",
                    ), )

            assert_that(
                encryptable,
                has_properties(
                    key=is_(equal_to("private")),
                    value=is_(none()),
                    encrypted_id=is_not(none()),
                ),
            )
            assert_that(
                encryptable._members(),
                is_(
                    equal_to(
                        dict(
                            created_at=encryptable.created_at,
                            encrypted_id=encryptable.encrypted_id,
                            id=encryptable.id,
                            key=encryptable.key,
                            updated_at=encryptable.updated_at,
                        ))),
            )
            assert_that(
                self.encryptable_store.count(),
                is_(equal_to(1)),
            )
            assert_that(
                self.encrypted_store.count(),
                is_(equal_to(1)),
            )

            # NB: ORM events will not trigger if we can reuse the object from the session cache
            self.encryptable_store.expunge(encryptable)

            encryptable = self.encryptable_store.retrieve(encryptable.id)
            assert_that(
                encryptable,
                has_properties(
                    key=is_(equal_to("private")),
                    value=is_(equal_to("value")),
                    encrypted_id=is_not(none()),
                ),
            )

            with transaction():
                self.encryptable_store.delete(encryptable.id)

            assert_that(
                self.encryptable_store.count(),
                is_(equal_to(0)),
            )
            assert_that(
                self.encrypted_store.count(),
                is_(equal_to(0)),
            )
Exemplo n.º 34
0
    def test_GetCompletions_MoreThan10_NoResolve_ThenResolve(self, app):
        ClearCompletionsCache()
        request, response = RunTest(
            app,
            {
                'description':
                "More than 10 candiates after filtering, don't resolve",
                'request': {
                    'filetype': 'java',
                    'filepath': ProjectPath('TestWithDocumentation.java'),
                    'line_num': 6,
                    'column_num': 7,
                },
                'expect': {
                    'response':
                    requests.codes.ok,
                    'data':
                    has_entries({
                        'completions':
                        has_item(
                            CompletionEntryMatcher(
                                'useAString',
                                'MethodsWithDocumentation.useAString(String s) : void',
                                {
                                    'kind':
                                    'Method',
                                    # This is the un-resolved info (no documentation)
                                    'detailed_info':
                                    'useAString(String s) : void\n\n',
                                    'extra_data':
                                    has_entries({'resolve': instance_of(int)})
                                }), ),
                        'completion_start_column':
                        7,
                        'errors':
                        empty(),
                    })
                },
            })

        # We know the item we want is there, pull out the resolve ID
        resolve = None
        for item in response['completions']:
            if item['insertion_text'] == 'useAString':
                resolve = item['extra_data']['resolve']
                break

        assert resolve is not None

        request['resolve'] = resolve
        # Do this twice to prove that the request is idempotent
        for i in range(2):
            response = app.post_json('/resolve_completion', request).json

            print(f"Resolve response: { pformat( response ) }")

            nl = os.linesep
            assert_that(
                response,
                has_entries({
                    'completion':
                    CompletionEntryMatcher(
                        'useAString',
                        'MethodsWithDocumentation.useAString(String s) : void',
                        {
                            'kind':
                            'Method',
                            # This is the resolved info (no documentation)
                            'detailed_info':
                            'useAString(String s) : void\n'
                            '\n'
                            f'Multiple lines of description here.{ nl }'
                            f'{ nl }'
                            f' *  **Parameters:**{ nl }'
                            f'    { nl }'
                            f'     *  **s** a string'
                        }),
                    'errors':
                    empty(),
                }))

            # The item is resoled
            assert_that(response['completion'], is_not(has_key('resolve')))
            assert_that(response['completion'], is_not(has_key('item')))
Exemplo n.º 35
0
 def test_non_metric(self):
     assert_that(object(), is_not(is_metric()))
Exemplo n.º 36
0
def test_tokenize():
    validator = steps_checker.FuncValidator(func_block)
    tokens = validator._get_tokens()
    assert_that(tokens, is_not(empty()))
Exemplo n.º 37
0
def step(context, header):
    assert_that(context.response.headers.get(header), is_not(None))
    assert_that(context.response.headers.get(header), is_not(''))
 def test_hookable_set_external_identifiers(self):
     assert_that(set_external_identifiers,
                 has_attr('implementation', is_not(none())))
Exemplo n.º 39
0
def test_delete_security_group(contrail_api_client, contrail_security_group):
    contrail_api_client.security_group_delete(id=contrail_security_group.uuid)
    groups = contrail_api_client.security_groups_list()
    assert_that(
        groups['security-groups'],
        is_not(has_item(has_entry('uuid', contrail_security_group.uuid))))
Exemplo n.º 40
0
def test_delete_virtual_network(contrail_api_client, contrail_network):
    contrail_api_client.virtual_network_delete(id=contrail_network.uuid)
    networks = contrail_api_client.virtual_networks_list()
    assert_that(networks['virtual-networks'],
                is_not(has_item(has_entry('uuid', contrail_network.uuid))))
Exemplo n.º 41
0
def test_delete_network_ipam(contrail_api_client, contrail_ipam):
    contrail_api_client.network_ipam_delete(id=contrail_ipam.uuid)
    ipams = contrail_api_client.network_ipams_list()
    assert_that(ipams['network-ipams'],
                is_not(has_item(has_entry('uuid', contrail_ipam.uuid))))
Exemplo n.º 42
0
def test_delete_network_policy(contrail_api_client, contrail_network_policy):
    contrail_api_client.network_policy_delete(id=contrail_network_policy.uuid)
    policies = contrail_api_client.network_policys_list()
    assert_that(
        policies['network-policys'],
        is_not(has_item(has_entry('uuid', contrail_network_policy.uuid))))
Exemplo n.º 43
0
 def test_bad_name(self):
     assert_that(self.counter, is_not(is_counter('bar')))
Exemplo n.º 44
0
def step_it_should_fail(context):
    assert_that(context.command_result.returncode, is_not(equal_to(0)))
Exemplo n.º 45
0
def step_it_should_fail_with_result(context, result):
    assert_that(context.command_result.returncode, equal_to(result))
    assert_that(result, is_not(equal_to(0)))
Exemplo n.º 46
0
def test_search_do_not_find_extension_feature(extension):
    response = confd.extensions().get()
    assert_that(response.items,
                is_not(has_item(has_entries(context=extension['context']))))
Exemplo n.º 47
0
 def test_bad_kind(self):
     assert_that(self.counter, is_not(is_timer()))
Exemplo n.º 48
0
    def test_shouldInvokeCallbackForTheOnlyGivenApproval(self):
        authorized_permission = PermissionObjectFactory()
        authorized_user = UserObjectFactory(
            user_permissions=[authorized_permission])

        state1 = StateObjectFactory(label="state1")
        state2 = StateObjectFactory(label="state2")
        state3 = StateObjectFactory(label="state3")

        content_type = ContentType.objects.get_for_model(BasicTestModel)
        workflow = WorkflowFactory(initial_state=state1,
                                   content_type=content_type,
                                   field_name="my_field")

        transition_meta_1 = TransitionMetaFactory.create(
            workflow=workflow,
            source_state=state1,
            destination_state=state2,
        )

        transition_meta_2 = TransitionMetaFactory.create(
            workflow=workflow,
            source_state=state2,
            destination_state=state3,
        )

        transition_meta_3 = TransitionMetaFactory.create(
            workflow=workflow,
            source_state=state3,
            destination_state=state1,
        )

        meta1 = TransitionApprovalMetaFactory.create(
            workflow=workflow,
            transition_meta=transition_meta_1,
            priority=0,
            permissions=[authorized_permission])

        TransitionApprovalMetaFactory.create(
            workflow=workflow,
            transition_meta=transition_meta_2,
            priority=0,
            permissions=[authorized_permission])

        TransitionApprovalMetaFactory.create(
            workflow=workflow,
            transition_meta=transition_meta_3,
            priority=0,
            permissions=[authorized_permission])

        workflow_object = BasicTestModelObjectFactory()
        workflow_object.model.river.my_field.approve(as_user=authorized_user)
        workflow_object.model.river.my_field.approve(as_user=authorized_user)
        workflow_object.model.river.my_field.approve(as_user=authorized_user)

        assert_that(TransitionApproval.objects.filter(meta=meta1),
                    has_length(2))
        first_approval = TransitionApproval.objects.filter(
            meta=meta1, transition__iteration=0).first()
        assert_that(first_approval, is_not(none()))

        self.hook_pre_approve(workflow,
                              meta1,
                              transition_approval=first_approval)

        output = self.get_output()
        assert_that(output, none())

        workflow_object.model.river.my_field.approve(as_user=authorized_user)

        output = self.get_output()
        assert_that(output, none())
Exemplo n.º 49
0
def test_add_device():
    """Test out adding a device to a user's account."""
    # Pick Cloud Kit dashboard
    browser.select("inputDashboard", "0")

    # Step 1 and Step 2 should be visible now
    assert browser.is_text_present(STEP_TITLES[1])
    assert browser.is_text_present(STEP_TITLES[2])

    # Wait a moment for the devices fetch to work.
    do_sleep()

    # Make sure no devices are selected.
    # (This user has no devices in their account anyway.)
    assert_that(browser.find_by_name("inputDevice").first.value, is_(""))

    # check that the Create Dashboard button is not visible
    button_xpath = '//button[contains(., "Create Dashboard!")]'
    cbutton = browser.find_by_xpath(button_xpath)
    assert not cbutton.is_empty()
    assert not cbutton.first.visible

    # Click 'Add New Device' button
    add_new_button = browser.find_by_name("addDevice")
    assert not add_new_button.is_empty()
    add_new_button.click()

    # Check that the modal has appeared.
    assert browser.is_text_present(NEW_DEVICE_MODAL_TITLE, 1)
    assert browser.is_text_present("What's This?")

    # Click 'Cancel' button
    browser.find_by_xpath('//button[.="Cancel"]').first.click()
    # Check that the modal has disappeared.
    assert not browser.is_text_present(NEW_DEVICE_MODAL_TITLE, 1)
    assert not browser.is_text_present("What's This?")

    # Click 'Add New Device' button again.
    add_new_button.click()
    # Check that the modal has appeared.
    assert browser.is_text_present(NEW_DEVICE_MODAL_TITLE, 1)
    assert browser.is_text_present("What's This?")

    # Check that the "Add Device" button is disabled
    button = browser.find_by_xpath('//button[contains(., "Add Device")]')
    assert not button.is_empty()
    assert button.first['disabled'], "Add Device button isn't disabled!"

    add_button = button

    # Check that the serial number field has 00409D pre-filled
    assert_that(
        browser.find_by_name("input_mac").first['placeholder'],
        is_("00409D ______"))

    # Enter some non-numeric characters in the serial number field
    browser.fill("input_mac", "zanzibar")
    assert add_button.first['disabled'], "Add Device button isn't disabled!"

    # Enter valid characters
    browser.fill("input_mac", "665544")
    assert not add_button.first['disabled'], "Add Device button isn't enabled!"
    # Enter description
    browser.fill("input_desc", "Integration test device description")

    # Click the button
    add_button.click()

    # Wait a moment while the POST happens. We'll know it worked when the
    # notification comes up. (Wait up to 10 seconds)
    assert browser.is_text_present("provisioned to your Device Cloud account",
                                   wait_time=10)
    # We then attempt configuration. Wait for that to pass. Should only take a
    # moment
    do_sleep(multiplier=3)

    # Check that the modal has disappeared.
    assert not browser.is_text_present(NEW_DEVICE_MODAL_TITLE)
    assert not browser.is_text_present("What's This?")

    # We should have automatically selected the new device.
    sel_value = str(browser.find_by_name("inputDevice").first.value)
    assert_that(sel_value, is_not(""))
Exemplo n.º 50
0
 def test_equal(self):
     spa_1 = VNXHbaPort.create(VNXSPEnum.SP_A, 1)
     spa_1_dup = VNXHbaPort.create(VNXSPEnum.SP_A, 1)
     spa_2 = VNXHbaPort.create(VNXSPEnum.SP_A, 2)
     assert_that(spa_1_dup, equal_to(spa_1))
     assert_that(spa_1, is_not(equal_to(spa_2)))
Exemplo n.º 51
0
def YouCompleteMe_YcmCoreNotImported_test(ycm):
    assert_that('ycm_core', is_not(is_in(sys.modules)))
Exemplo n.º 52
0
def then_the_xlet_identity_shows_a_voicemail_1(step, vm_number):
    assert_that(world.xc_identity_infos['voicemail_num'], is_not(equal_to('')))
    assert_that(world.xc_identity_infos['voicemail_button'], is_(True))
Exemplo n.º 53
0
 def test_connection_port_not_equal_sp_port(self):
     c_port = VNXConnectionPort(sp='a', port_id=4, cli=t_cli())
     s_port = VNXSPPort.get(t_cli(), VNXSPEnum.SP_A, 4)
     # one has vport_id, others not, not equal
     assert_that(c_port, is_not(equal_to(s_port)))
Exemplo n.º 54
0
 def test_components_can_be_matchers(self):
     assert_that(self.counter, is_metric('c', 'foo', '1', none()))
     assert_that(self.timer, is_not(is_metric('ms', 'foo', '100', none())))
Exemplo n.º 55
0
 def test_hba_not_equal_sp_port(self):
     hba = test_hba()
     s_port = VNXSPPort.get(t_cli(), VNXSPEnum.SP_A, 3)
     assert_that(hba, is_not(equal_to(s_port)))
Exemplo n.º 56
0
 def test_registration(self):
     xmlconfig(StringIO(ZCML_STRING))
     provider = component.getUtility(IProvider, "ebay")
     assert_that(provider, is_not(None))
Exemplo n.º 57
0
 def YcmCoreNotImported_test(self):
     assert_that('ycm_core', is_not(is_in(sys.modules)))
Exemplo n.º 58
0
def step_the_command_returncode_is_nonzero(context):
    assert_that(context.command_result.returncode, is_not(equal_to(0)))
Exemplo n.º 59
0
def test_bound_network_interfaces(os_faults_steps, computes):
    """Verify if DPDK vRouter binds network interfaces."""
    devices = dpdk.get_devices(os_faults_steps, computes)
    assert_that(devices.values(),
                only_contains(
                    has_entries(settings.DPDK_ENABLED_GROUP, is_not(empty()))))
Exemplo n.º 60
0
 def test_bad_value(self):
     assert_that(self.counter, is_not(is_counter('foo', '2')))