def test_query(self):
        from zope.site import SiteManagerAdapter
        from zope import component
        component.provideAdapter(SiteManagerAdapter)
        top_site = SiteManagerContainer()
        top_sm = LocalSiteManager(top_site)
        top_site.setSiteManager(top_sm)
        assert_that(top_sm.__parent__, is_(top_site))
        assert_that(top_site, provides(ISite))
        interface.alsoProvides(top_site, ILocationInfo)

        child_site = SiteManagerContainer()
        child_site.__parent__ = top_site
        child_site.getParent = lambda: child_site.__parent__
        interface.alsoProvides(child_site, ILocationInfo)
        child_sm = LocalSiteManager(child_site)
        child_site.setSiteManager(child_sm)

        assert_that(child_sm.__bases__, is_((top_sm,)))


        class IFoo(Interface):
            pass

        @interface.implementer(IFoo)
        class Foo(Contained):
            pass

        child_foo = Foo()
        top_foo = Foo()

        child_foo.__parent__ = child_site
        top_foo.__parent__ = top_site

        top_sm.registerUtility(top_foo, IFoo)
        child_sm.registerUtility(child_foo, IFoo)

        child_foo.__conform__ = lambda self, _:  child_sm
        from zope import component
        component.getSiteManager(child_foo)


        x = queryNextUtility(child_foo, IFoo)
        assert_that(x, is_(top_foo))

        class IBaz(Interface): pass

        x = queryNextUtility(child_foo, IBaz)
        assert_that(x, is_(none()))

        x = queryNextUtility(top_foo, IFoo)
        assert_that(x, is_(none()))

        x = queryNextUtility(component.getGlobalSiteManager(), IFoo)
        assert_that(x, is_(none()))

        global_foo = Foo()
        component.provideUtility(global_foo, IFoo)
        x = queryNextUtility(component.getGlobalSiteManager(), IFoo)
        assert_that(x, is_(global_foo))
Exemple #2
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()))
Exemple #3
0
 def verify_dm_1(dm):
     assert_that(dm.status, equal_to('ok'))
     assert_that(dm.mover_id, equal_to(1))
     assert_that(dm.uptime, equal_to(7086723))
     assert_that(dm.i18n_mode, equal_to('UNICODE'))
     assert_that(dm.name, equal_to('server_2'))
     assert_that(dm.existed, equal_to(True))
     assert_that(dm.version, equal_to('T8.1.7.70'))
     assert_that(dm.standby_fors, none())
     assert_that(dm.dns_domain, none())
     assert_that(dm.failover_policy, equal_to('auto'))
     assert_that(dm.host_id, equal_to(1))
     assert_that(dm.role, equal_to('primary'))
     assert_that(dm.standbys, only_contains(2))
     assert_that(dm.timezone, equal_to('GMT'))
     interface = next(i for i in dm.interfaces if i.name == 'el30')
     assert_that(interface.mover_id, equal_to(1))
     assert_that(interface.ip_addr, equal_to('172.18.70.2'))
     assert_that(interface.name, equal_to('el30'))
     assert_that(interface.existed, equal_to(True))
     assert_that(interface.broadcast_addr, equal_to('172.18.255.255'))
     assert_that(interface.net_mask, equal_to('255.255.0.0'))
     assert_that(interface.up, equal_to(True))
     assert_that(interface.mtu, equal_to(1500))
     assert_that(interface.ip_version, equal_to('IPv4'))
     assert_that(interface.mac_addr, equal_to('2:60:48:20:b:0'))
     assert_that(interface.device, equal_to('cge0'))
     assert_that(interface.vlan_id, equal_to(0))
     dedup_settings = dm.dedup_settings
     assert_that(dedup_settings.cpu_high_watermark, equal_to(90))
     assert_that(dedup_settings.minimum_scan_interval, equal_to(7))
     assert_that(dedup_settings.duplicate_detection_method,
                 equal_to('sha1'))
     assert_that(dedup_settings.mover_id, equal_to(1))
     assert_that(dedup_settings.minimum_size, equal_to(24))
     assert_that(dedup_settings.access_time, equal_to(15))
     assert_that(dedup_settings.file_extension_exclude_list, equal_to(''))
     assert_that(dedup_settings.case_sensitive, equal_to(False))
     assert_that(dedup_settings.cifs_compression_enabled, equal_to(True))
     assert_that(dedup_settings.modification_time, equal_to(15))
     assert_that(dedup_settings.sav_vol_high_watermark, equal_to(90))
     assert_that(dedup_settings.backup_data_high_watermark, equal_to(90))
     assert_that(dedup_settings.maximum_size, equal_to(8388608))
     assert_that(dedup_settings.cpu_low_watermark, equal_to(40))
     assert_that(dedup_settings.existed, equal_to(True))
     device = next(i for i in dm.devices if i.name == 'fxg-8-0')
     assert_that(device.mover_id, equal_to(1))
     assert_that(device.name, equal_to('fxg-8-0'))
     assert_that(device.existed, equal_to(True))
     assert_that(device.type, equal_to('physical-ethernet'))
     assert_that(device.interfaces, equal_to('10.110.42.83'))
     assert_that(device.speed, equal_to('FD10000'))
     route = next(i for i in dm.route if i.destination == '172.18.0.0')
     assert_that(route.mover_id, equal_to(1))
     assert_that(route.existed, equal_to(True))
     assert_that(route.destination, equal_to('172.18.0.0'))
     assert_that(route.net_mask, equal_to('255.255.0.0'))
     assert_that(route.ip_version, equal_to('IPv4'))
     assert_that(route.interface, equal_to('172.18.70.2'))
     assert_that(route.gateway, equal_to('172.18.70.2'))
Exemple #4
0
    def test_given_custom_protocol_is_no_longer_assocaited_then_protocol_removed(self):
        line = self.add_line(protocol='custom', protocolid=1234)

        self.fixes.fix(line.id)

        line = self.session.query(Line).first()
        assert_that(line.protocol, none())
        assert_that(line.protocolid, none())
    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)),
            )
Exemple #6
0
    def test_given_line_has_custom_endpoint_when_getting_then_line_has_no_caller_id(self):
        custom_row = self.add_usercustom()
        line_row = self.add_line(protocol='custom',
                                 protocolid=custom_row.id)

        line = line_dao.get(line_row.id)

        assert_that(line.caller_id_name, none())
        assert_that(line.caller_id_num, none())
Exemple #7
0
    def test_fetch_device_and_config_when_device_does_not_exist(self):
        with self.provd_managers() as (device_manager, config_manager, _):
            device_manager.get.side_effect = HTTPError('', 404, '', '', StringIO(''))

            device, config = device_dao.fetch_device_and_config(self.deviceid)

            assert_that(device, none())
            assert_that(config, none())
            device_manager.get.assert_called_once_with(self.deviceid)
            assert_that(config_manager.find.call_count, equal_to(0))
Exemple #8
0
    def test_given_endpoint_is_associated_to_line_then_line_is_dissociated(self):
        sip_row = self.add_usersip()
        line_row = self.add_line(endpoint='sip', endpoint_id=sip_row.id)

        sip = dao.get(sip_row.id)
        dao.delete(sip)

        line_row = self.session.query(Line).get(line_row.id)
        assert_that(line_row.endpoint, none())
        assert_that(line_row.endpoint_id, none())
Exemple #9
0
 def verify_root_fs_1(fs):
     assert_that(fs.fs_id, equal_to(1))
     assert_that(fs.internal_use, equal_to(True))
     assert_that(fs.name, equal_to('root_fs_1'))
     assert_that(fs.volume, equal_to(10))
     assert_that(fs.policies, none())
     assert_that(fs.pools, none())
     assert_that(fs.storages, equal_to(1))
     assert_that(fs.type, equal_to('uxfs'))
     assert_that(fs.size, equal_to(16))
    def test_construct(self):
        v = InvalidValue()
        assert_that(v, has_property('value', none()))
        assert_that(v, has_property('field', none()))

        v = InvalidValue(value=1, field=1)
        assert_that(v, has_property('value', 1))
        assert_that(v, has_property('field', 1))

        with self.assertRaises(TypeError):
            InvalidValue(value=1, field=2, other=3)
Exemple #11
0
    def test_given_line_associated_to_sccp_when_deleted_then_line_dissociated(self):
        sccp = self.add_sccpline(context='default', name='1000')
        line = self.add_line(context='default', name='1000', number='1000',
                             protocol='sccp', protocolid=sccp.id)

        sccp = dao.get(sccp.id)
        dao.delete(sccp)

        line = self.session.query(Line).get(line.id)
        assert_that(line.endpoint, none())
        assert_that(line.endpoint_id, none())
Exemple #12
0
    def test_creates_an_empty_vlan(self):
        self.client.add_vlan(1000)

        vlan = self.get_vlan_from_list(1000)
        assert_that(vlan.number, is_(1000))
        assert_that(vlan.name, is_(none()))
        assert_that(vlan.access_groups[IN], is_(none()))
        assert_that(vlan.access_groups[OUT], is_(none()))
        assert_that(vlan.vrf_forwarding, is_(none()))
        assert_that(vlan.ips, is_(empty()))
        assert_that(vlan.vrrp_groups, is_(empty()))
        assert_that(vlan.dhcp_relay_servers, is_(empty()))
Exemple #13
0
    def test_create_minimal_parameters(self):
        created_sccp = dao.create(SCCP())
        sccp_row = self.session.query(SCCP).first()

        assert_that(created_sccp.id, equal_to(sccp_row.id))
        assert_that(created_sccp.options, contains())

        assert_that(sccp_row.name, equal_to(''))
        assert_that(sccp_row.context, equal_to(''))
        assert_that(sccp_row.cid_name, equal_to(''))
        assert_that(sccp_row.cid_num, equal_to(''))
        assert_that(sccp_row.allow, none())
        assert_that(sccp_row.disallow, none())
Exemple #14
0
    def test_get_minimal_parameters(self):
        line_row = self.add_line(context='default',
                                 provisioningid=123456)

        line = line_dao.get(line_row.id)

        assert_that(line.id, equal_to(line_row.id))
        assert_that(line.context, equal_to(line_row.context))
        assert_that(line.provisioning_code, equal_to('123456'))
        assert_that(line.position, equal_to(1))
        assert_that(line.endpoint, none())
        assert_that(line.endpoint_id, none())
        assert_that(line.caller_id_name, none())
        assert_that(line.caller_id_num, none())
Exemple #15
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)
Exemple #16
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)
Exemple #17
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)
Exemple #18
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)
Exemple #19
0
    def test_create_minimal_parameters(self):
        line = Line(context='default', provisioningid=123456)

        created_line = line_dao.create(line)

        assert_that(created_line.id, is_not(none()))
        assert_that(created_line.context, equal_to('default'))
        assert_that(created_line.position, equal_to(1))
        assert_that(created_line.endpoint, none())
        assert_that(created_line.endpoint_id, none())
        assert_that(created_line.provisioning_code, has_length(6))
        assert_that(created_line.caller_id_name, none())
        assert_that(created_line.caller_id_num, none())
        assert_that(created_line.configregistrar, equal_to('default'))
        assert_that(created_line.ipfrom, equal_to(''))
    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)),
            )
Exemple #21
0
    def test_get_user_config_with_no_line(self):
        user = self.add_user()

        result = user_dao.get_user_config(user.id)

        assert_that(result[str(user.id)]["context"], none())
        assert_that(result[str(user.id)]["linelist"], equal_to([]))
Exemple #22
0
    def test_given_line_has_no_associated_name_then_name_removed(self):
        line = self.add_line(name="linename")

        self.fixes.fix(line.id)

        line = self.session.query(Line).first()
        assert_that(line.name, none())
Exemple #23
0
    def test_batch_last_updated(self):
        records = {
            # timestamps in ascending order
            'some_data': [
                {'_timestamp': d_tz(2018, 1, 1)},
                {'_timestamp': d_tz(2019, 1, 1)},
                {'_timestamp': d_tz(2020, 1, 1)},
            ],
            # timestamps in descending order
            'some_other_data': [
                {'_timestamp': d_tz(2017, 1, 1)},
                {'_timestamp': d_tz(2016, 1, 1)},
                {'_timestamp': d_tz(2015, 1, 1)},
            ]
        }

        for key, items in records.iteritems():
            self.engine.create_data_set(key, 0)
            for item in items:
                self.engine.save_record(key, item)

        some_data_set = DataSet(self.engine, {'name': 'some_data'})
        some_other_data_set = DataSet(self.engine, {'name': 'some_other_data'})
        yet_another_data_set = DataSet(self.engine, {'name': 'yet_another_data'})

        self.engine.batch_last_updated([some_data_set, some_other_data_set, yet_another_data_set])

        some_data_set_last_updated = some_data_set.get_last_updated()
        some_other_data_set_last_updated = some_other_data_set.get_last_updated()
        yet_another_data_set_last_updated = yet_another_data_set.get_last_updated()

        assert_that(some_data_set_last_updated, is_(d_tz(2020, 1, 1, 0, 0, 0)))
        assert_that(some_other_data_set_last_updated, is_(d_tz(2017, 1, 1, 0, 0, 0)))
        assert_that(yet_another_data_set_last_updated, is_(none()))
Exemple #24
0
    def test_delete(self):
        line_row = self.add_line()

        line_dao.delete(line_row)

        deleted_line = self.session.query(Line).get(line_row.id)
        assert_that(deleted_line, none())
Exemple #25
0
    def test_fix_timezone(self):
        assert_that(self.base.fix_timezone(None), is_(none()))

        time = datetime.datetime(2013, 1, 1, 12, 0, 0, tzinfo=pytz.timezone("CET"))
        utc_time = datetime.datetime(2013, 1, 1, 11, 0, 0, tzinfo=pytz.timezone("UTC"))

        assert_that(self.base.fix_timezone(time), is_(utc_time))
Exemple #26
0
    def test_edit_null_parameters(self):
        line_row = self.add_line(endpoint='sccp',
                                 endpoint_id=1234)

        line = line_dao.get(line_row.id)
        line.endpoint = None
        line.endpoint_id = None

        line_dao.edit(line)

        edited_line = self.session.query(Line).get(line_row.id)
        assert_that(edited_line.id, equal_to(line.id))
        assert_that(edited_line.endpoint, none())
        assert_that(edited_line.protocol, none())
        assert_that(edited_line.endpoint_id, none())
        assert_that(edited_line.protocolid, none())
    def test_aq_property(self):

        class IBaz(Interface):
            pass

        class IFoo(Interface):
            ob = Object(IBaz)

        @implementer(IBaz)
        class Baz(object):
            pass

        class BazAQ(Implicit, Baz):
            pass

        @implementer(IFoo)
        class Foo(Base):
            ob = AcquisitionFieldProperty(IFoo['ob'])

        assert_that(Foo, has_property('ob', is_(AcquisitionFieldProperty)))

        # pylint:disable=blacklisted-name
        foo = Foo()
        assert_that(foo, has_property('ob', none()))

        foo.ob = Baz()
        assert_that(foo, has_property('ob', is_not(aq_inContextOf(foo))))

        foo.ob = BazAQ()
        assert_that(foo, has_property('ob', aq_inContextOf(foo)))
Exemple #28
0
    def test_given_allow_and_disallow_are_set_when_removed_then_database_updated(self):
        row = self.add_sccpline(context='',
                                name='',
                                cid_name='',
                                cid_num='',
                                allow="gsm,g729",
                                disallow="alaw,ulaw")

        sccp = dao.get(row.id)
        sccp.options = []
        dao.edit(sccp)

        row = self.session.query(SCCP).first()

        assert_that(row.allow, none())
        assert_that(row.disallow, none())
Exemple #29
0
    def test_given_extension_does_not_exist_then_returns_nothing(self, context_find_by_extension_id):
        context_find_by_extension_id.return_value = None

        result = line_extension_service.find_by_extension_id(2)

        assert_that(result, none())
        context_find_by_extension_id.assert_called_once_with(2)
Exemple #30
0
    def test_given_no_extension_then_returns_none(self, find_by_line_id, extension_get):
        line_id = 1
        find_by_line_id.return_value = None

        result = ule_service.find_extension(line_id)

        assert_that(result, none())
 def test_dict_to_filter_string_empty(self):
     ret = UnityClient.dict_to_filter_string({})
     assert_that(ret, none())
     ret = UnityClient.dict_to_filter_string(None)
     assert_that(ret, none())
Exemple #32
0
 def test_filesystem_snap(self):
     snap = UnitySnap(cli=t_rest(), _id='171798691852')
     fs = snap.filesystem
     assert_that(fs, instance_of(UnityFileSystem))
     assert_that(fs.storage_resource, equal_to(snap.storage_resource))
     assert_that(snap.lun, none())
Exemple #33
0
 def test_getitem(self):
     prop = UrlProperty()
     getter = prop.make_getitem()
     with self.assertRaises(KeyError):
         getter(object(), 'foobar')
     assert_that(getter(object(), prop.data_name), is_(none()))
Exemple #34
0
    def test_it_should_return_none_when_not_found(self):
        result = self.filter(find('id', 0),
                             (AVAILABLE_STATION, NO_BIKES_STATION))

        assert_that(result, is_(none()))
Exemple #35
0
    def test_find_no_sccp(self):
        result = sccp_dao.find(42)

        assert_that(result, none())
Exemple #36
0
 def test_try_import_none(self):
     mod = try_import('paramiko_none')
     assert_that(mod, none())
Exemple #37
0
    def test_find_by_user_id_no_users_or_voicemail(self):
        result = user_voicemail_dao.find_by_user_id(1)

        assert_that(result, none())
Exemple #38
0
    def assert_sip_line_was_not_associated_with_voicemail(self, protocol_id, voicemail_id):
        result_usersip_row = self.session.query(UserSIPSchema).get(protocol_id)

        assert_that(result_usersip_row.mailbox, none())
Exemple #39
0
    def test_find_no_extension(self):
        result = extension_dao.find(1)

        assert_that(result, none())
Exemple #40
0
def then_i_can_get_a_user_token(context, username, password):
    token = _create_token(context, username, password)
    assert_that(token['token'], is_not(none()))
Exemple #41
0
 def f():
     port = VNXHbaPort.create('A', 'a1')
     assert_that(port.is_valid(), equal_to(False))
     assert_that(port.port_id, none())
Exemple #42
0
def test_has_initially_no_metadata_or_images():
    album = Album()
    for tag in Album.tags():
        assert_that(getattr(album, tag), none(), tag)

    assert_that(album.images, empty(), "images")
 def test_dict_to_filter_string_value_all_none(self):
     ret = UnityClient.dict_to_filter_string({'a': None, 'b': None})
     assert_that(ret, none())
Exemple #44
0
    def test_find_by_user_id_with_user_without_line_or_voicemail(self):
        user_row = self.add_user(firstname='King')

        result = user_voicemail_dao.find_by_user_id(user_row.id)

        assert_that(result, none())
Exemple #45
0
    def test_find_no_call_filter(self):
        result = call_filter_dao.find(42)

        assert_that(result, none())
    def test_given_one_type_when_other_name_queried_returns_none(self):
        self.add_func_key_type(name='speeddial')

        result = dao.find_type_for_name('transfer')

        assert_that(result, none())
Exemple #47
0
    def test_given_call_filter_does_not_exist_then_returns_null(self):
        call_filter = call_filter_dao.find_by(name='42')

        assert_that(call_filter, none())
    def test_given_no_destination_types_then_returns_none(self):
        result = dao.find_destination_type_for_name('type')

        assert_that(result, none())
Exemple #49
0
    def test_find_by_user_id_with_user_without_voicemail(self):
        user_row = self.add_user_line_with_exten(firstname='King', exten='1000', context='default')

        result = user_voicemail_dao.find_by_user_id(user_row.id)

        assert_that(result, none())
    def test_reverse_lookup_with_invalid_user_uuid(self):
        result = self.reverse('123456', 'default', 'invalid_uuid')

        assert_that(result['display'], is_(none()))
Exemple #51
0
def EventNotification_OnFileReadyToParse_NoProjectFile_test(app, *args):
    # We raise an error if we can't detect a .tern-project file.
    # We only do this on the first OnFileReadyToParse event after a
    # server startup.
    response = app.post_json('/event_notification',
                             BuildRequest(filepath=PathToTestFile('..'),
                                          event_name='FileReadyToParse',
                                          filetype='javascript'),
                             expect_errors=True)

    print('event response: {0}'.format(pformat(response.json)))

    eq_(response.status_code, requests.codes.internal_server_error)

    assert_that(
        response.json,
        ErrorMatcher(
            RuntimeError, 'Warning: Unable to detect a .tern-project file '
            'in the hierarchy before ' + PathToTestFile('..') +
            ' and no global .tern-config file was found. '
            'This is required for accurate JavaScript '
            'completion. Please see the User Guide for '
            'details.'))

    debug_info = app.post_json('/debug_info',
                               BuildRequest(filetype='javascript')).json
    assert_that(
        debug_info['completer']['servers'][0]['extras'],
        contains(
            has_entries({
                'key': 'configuration file',
                'value': none()
            }),
            has_entries({
                'key': 'working directory',
                'value': utils.GetCurrentDirectory()
            })))

    # Check that a subsequent call does *not* raise the error.
    response = app.post_json('/event_notification',
                             BuildRequest(event_name='FileReadyToParse',
                                          filetype='javascript'),
                             expect_errors=True)

    print('event response: {0}'.format(pformat(response.json)))

    eq_(response.status_code, requests.codes.ok)
    assert_that(response.json, empty())

    # Restart the server and check that it raises it again.
    app.post_json(
        '/run_completer_command',
        BuildRequest(filepath=PathToTestFile('..'),
                     command_arguments=['RestartServer'],
                     filetype='javascript'))

    response = app.post_json('/event_notification',
                             BuildRequest(filepath=PathToTestFile('..'),
                                          event_name='FileReadyToParse',
                                          filetype='javascript'),
                             expect_errors=True)

    print('event response: {0}'.format(pformat(response.json)))

    eq_(response.status_code, requests.codes.internal_server_error)

    assert_that(
        response.json,
        ErrorMatcher(
            RuntimeError, 'Warning: Unable to detect a .tern-project file '
            'in the hierarchy before ' + PathToTestFile('..') +
            ' and no global .tern-config file was found. '
            'This is required for accurate JavaScript '
            'completion. Please see the User Guide for '
            'details.'))

    # Finally, restart the server in a folder containing a .tern-project file. We
    # expect no error in that case.
    app.post_json(
        '/run_completer_command',
        BuildRequest(filepath=PathToTestFile(),
                     command_arguments=['RestartServer'],
                     filetype='javascript'))

    response = app.post_json('/event_notification',
                             BuildRequest(filepath=PathToTestFile(),
                                          event_name='FileReadyToParse',
                                          filetype='javascript'),
                             expect_errors=True)

    print('event response: {0}'.format(pformat(response.json)))

    eq_(response.status_code, requests.codes.ok)
    assert_that(response.json, empty())

    debug_info = app.post_json('/debug_info',
                               BuildRequest(filetype='javascript')).json
    assert_that(
        debug_info['completer']['servers'][0]['extras'],
        contains(
            has_entries({
                'key': 'configuration file',
                'value': PathToTestFile('.tern-project')
            }),
            has_entries({
                'key': 'working directory',
                'value': PathToTestFile()
            })))
Exemple #52
0
    def test_given_outcall_does_not_exist_then_returns_null(self):
        outcall = outcall_dao.find_by(id=42)

        assert_that(outcall, none())
Exemple #53
0
 def test_set_sp_error(self):
     port = VNXHbaPort.create('Z', 3)
     assert_that(port.is_valid(), equal_to(False))
     assert_that(port.sp, none())
Exemple #54
0
 def test_lun_snap(self):
     snap = UnitySnap(cli=t_rest(), _id='38654705785')
     lun = snap.lun
     assert_that(lun, instance_of(UnityLun))
     assert_that(snap.filesystem, none())
Exemple #55
0
    def test_find_no_outcall(self):
        result = outcall_dao.find(42)

        assert_that(result, none())
Exemple #56
0
def test__initial_state(values_fetcher):
    assert_that(values_fetcher._period_range.start, none())
    assert_that(values_fetcher._period_range.end, none())
Exemple #57
0
 def test_given_row_with_value_does_not_exist_then_returns_null(self):
     result = custom_dao.find_by(interface='abcd')
     assert_that(result, none())
Exemple #58
0
def nothing():
    return described_as("nothing", none())
Exemple #59
0
def then_i_can_create_a_token(context):
    token = _create_token(context, 'root', 'wazosecret')
    assert_that(token['token'], is_not(none()))
Exemple #60
0
def validate_absence_of_membership(context):
    acct_repository = AccountRepository(context.db)
    membership = acct_repository.get_active_account_membership(
        context.accounts['foo'].id)
    assert_that(membership, none())