Пример #1
0
    def test_create_workload_fresh_directory(self):
        workunit1 = self.undertest.get_workunit()
        assert_that(workunit1.get_filename(), is_in(self.test_files))
        self.progress_manager.record_done(workunit1.get_filename())

        workunit2 = self.undertest.get_workunit()
        assert_that(workunit2.get_filename(), is_in(self.test_files))
        assert_that(workunit2.get_filename(),
                    is_not(equal_to(workunit1.get_filename())))
        self.progress_manager.record_done(workunit2.get_filename())

        self.assertRaises(NoAvailableWorkException, self.undertest.get_workunit)
Пример #2
0
    def test_removing_items(self):
        """
        Test that item can be removed from inventory
        """
        item = mock()

        self.character.inventory.append(item)

        assert_that(item, is_in(self.character.inventory))

        self.character.inventory.remove(item)

        assert_that(item, is_not(is_in(self.character.inventory)))
Пример #3
0
    def test_deleting_items(self):
        """
        Test that item can be deleted from inventory
        """
        item = mock()

        self.character.inventory.append(item)

        assert_that(item, is_in(self.character.inventory))

        del self.character.inventory[0]

        assert_that(item, is_not(is_in(self.character.inventory)))
Пример #4
0
def step_impl(context):
    """
    :type context behave.runner.Context
    """

    stg_list_cnts = dict()
    stg_list = list()

    stg = mysql.select(context.dev_xmart, "select sourcelistingid from xmart.stg_listing;")
    mysql.close_connection(con=context.dev_xmart)

    for row in stg:
        row = str(row)
        # print("========", id)
        first_quot = row.find("'")
        comma = row.find(",")
        stg_list.append(row[first_quot+1:comma-1])

    for aa in context.id_exception:
        assert_that(aa, is_in(stg_list))
        # if aa in stg_list:
        #     print(aa)

    for bb in stg_list:
        stg_list_cnts[bb] = stg_list_cnts.get(bb, 0) + 1
    # print(stg_list_cnts)

    for key,val in stg_list_cnts.items():
        assert_that(val, is_(1))

    print("Assertion complete (2 of 3). Listings that are in the Exceptions table appear only once in Stg table. \n")
Пример #5
0
def test_title_header():
    """The 'title' h1 should read "Log in". """
    h1 = splinter_tests.browser.find_by_css("h1.title")

    assert not h1.is_empty()

    assert_that("Log in", is_in(h1.first.text))
Пример #6
0
 def AssertResponse( self, response ):
   assert_that( response.status_code, equal_to( requests.codes.ok ) )
   assert_that( HMAC_HEADER, is_in( response.headers ) )
   assert_that(
     self._ContentHmacValid( response ),
     equal_to( True )
   )
Пример #7
0
    def test_target_single(self):
        """
        Targeting a single character should be possible
        """
        spell = self.spell_generator.create_spell(spell_name="healing wind", targets=[self.character])

        assert_that(self.character, is_in(spell.targets))
Пример #8
0
    def test_marshal_has_correct_keys(self):
        key1 = "testKey1"
        value1 = "testValue1"

        key2 = "testKey2"
        value2 = "testValue2"
        self._order.parse({key1: value1,
                           key2: value2})
        marshaldata = self._order.marshal()

        assert_that(key1, is_in(marshaldata))
        assert_that(key2, is_in(marshaldata))
        assert_that(
            dict(self._order),
            equal_to({"testKey1": "testValue1", "testKey2": "testValue2"})
        )

        assert_that(value1, marshaldata[key1])
        assert_that(value2, marshaldata[key2])
def delete_line(line_id):
    line = line_read_helper.find_by_id(line_id)
    if not line:
        return

    assert_that(line['protocol'], is_in(['sip', 'sccp']),
                "Acceptance cannot delete line with protocol '%s'" % line['protocol'])

    _delete_line_associations(line_id)
    _delete_line(line)
Пример #10
0
	def test_get_clients(self):
		# Given
		self.client['email'] = "*****@*****.**"
		# When
		self.tester.post("/clients", data=self.client)
		get = self.tester.get("/clients")
		# Then
		assert_that(get.status_code, equal_to(200))
		assert_that(self.client,
			 is_in(loads(get.data)['all']))
Пример #11
0
    def test_caster_is_not_targeted(self):
        """
        Under no circumstances, caster should not be targeted
        """
        params = SpellCastingParameters(caster = self.caster,
                                        direction = 7,
                                        spell_name = 'proto')

        targets = targeting_single_target(params)

        assert_that(self.caster, is_not(is_in(targets)))
Пример #12
0
    def test_targeting_empty_direction(self):
        """
        Targeting to incorrect direction should not add anyone to targets list
        """
        params = SpellCastingParameters(caster = self.caster,
                                        direction = 1,
                                        spell_name = 'proto')

        targets = targeting_single_target(params)

        assert_that(self.target1, is_not(is_in(targets)))
Пример #13
0
    def test_targeting_correct_direction(self):
        """
        When targeting towards character, a spell should hit
        """
        params = SpellCastingParameters(caster = self.caster,
                                        direction = 7,
                                        spell_name = 'proto')

        targets = [data.target for data in targeting_single_target(params)]

        assert_that(self.target1, is_in(targets))
Пример #14
0
 def has_variable(self, variable, expected_value):
     channels = self._ari.channels.list()
     candidates = []
     for channel in channels:
         try:
             value = channel.getChannelVar(variable=variable)['value']
         except ARINotFound:
             continue
         if value == expected_value:
             candidates.append(channel.id)
     return is_in(candidates)
 def test_instance_refs_are_garbage_collected(self):
     """_Package instance refs are garbage collected with old instances"""
     pkg = _Package()
     pkg1_repr = "%r" % pkg
     pkg = _Package()
     # pkg2_repr = "%r" % pkg
     gc.collect()
     reprs = [repr(pkg_inst) for pkg_inst in _Package.instances()]
     # log.debug("pkg1, pkg2, reprs: %s, %s, %s"
     #           % (pkg1_repr, pkg2_repr, reprs))
     assert_that(pkg1_repr, is_not(is_in(reprs)))
Пример #16
0
    def test_get_capability_profile_usage_tags(self):
        unity = t_unity()
        tag = "capacity"
        cp = unity.get_capability_profile(usage_tags=tag)
        assert_that(cp, instance_of(UnityCapabilityProfileList))
        assert_that(len(cp), 1)
        assert_that(cp[0].existed, equal_to(True))
        assert_that(tag, is_in(cp[0].usage_tags))

        cp2 = unity.get_capability_profile(usage_tags=[tag])
        assert_that(cp2, instance_of(UnityCapabilityProfileList))
        assert_that(len(cp2), 1)
        assert_that(cp2[0].existed, equal_to(True))
        assert_that(tag, is_in(cp2[0].usage_tags))

        # None tags will not pass to rest url
        # it's same with get_capability_profile()
        cp3 = unity.get_capability_profile(usage_tags=None)
        assert_that(cp3, instance_of(UnityCapabilityProfileList))
        assert_that(len(cp3), 2)
        assert_that(cp3[0].existed, equal_to(True))
Пример #17
0
	def test_all_wines(self):
		# Given
		self.wine['name'] = "test_all_wines"
		# Then
		post = self.tester.post("/wines", 
			data=self.wine)
		get_all = self.tester.get("/wines")	
		data = loads(get_all.data)['all']
		for wine in data: wine.pop("id")
		copy = self.wine.copy()
		copy.pop('type')
		# When
		assert_that(get_all.status_code, 200)
		assert_that(copy, is_in(data))
Пример #18
0
    def test_corners_are_rounded(self):
        """
        Spells with spherical area of effect should not target to square area
        """
        add_character(self.level, (7, 7), self.target3)

        params = SpellCastingParameters(caster = self.caster,
                                        direction = 7,
                                        spell_name = 'proto')

        targets = targeting_spherical_area(params,
                                           radius = 2)

        assert_that(self.target3, is_not(is_in(targets)))
Пример #19
0
	def test_wine_by_type(self):
		# Given
		self.wine['name'] = "test_delete_wine"
		# When
		post = self.tester.post("/wines", 
			data=self.wine)
		get_white = self.tester.get("/types/white")
		data = loads(get_white.data)['all']
		for white in data: white.pop('id')
		copy = self.wine.copy()
		copy.pop('type')
		# Then
		assert_that(get_white.status_code, equal_to(200))
		assert_that(copy, is_in(data))
Пример #20
0
    def _create_test_image(self, name):
        """ Create an test image for tests to use on a datastore """
        datastore = self._find_configured_datastore_in_host_config()

        # ttylinux is the default image that is copied to datastore
        # when agent starts
        src_image = Image("ttylinux", datastore)
        dst_image = Image(name, datastore)

        # Copy image
        request = Host.CopyImageRequest(src_image, dst_image)
        response = self.host_client.copy_image(request)
        assert_that(response.result, is_in([CopyImageResultCode.OK, CopyImageResultCode.DESTINATION_ALREADY_EXIST]))

        return dst_image, datastore
Пример #21
0
    def test_country_vocabulary(self):
        from zope.schema import Choice

        class IA(Interface):
            choice = Choice(title=u"Choice",
                            vocabulary=u"Countries")

        o = object()

        choice = IA['choice'].bind(o)
        assert_that(choice.vocabulary, is_(not_none()))
        assert_that('us', is_in(choice.vocabulary))
        term = choice.vocabulary.getTermByToken('us')
        assert_that(term, has_property('value', "United States"))
        ext = term.toExternalObject()
        assert_that(ext, has_entry('flag', u'/++resource++country-flags/us.gif'))
        assert_that(ext, has_entry('title', 'United States'))

        schema = JsonSchemafier(IA).make_schema()
        assert_that(schema, has_entry('choice', has_entry('choices', has_item(ext))))
Пример #22
0
def getcountry(threeletter="PAK"):
    print threeletter
    baseurl = "http://api.worldbank.org/datafiles/%s_Country_MetaData_en_EXCEL.xls"
    value = {'dsID': 'World Bank',
             'region': threeletter,
             'source': baseurl % threeletter,
             'is_number': True}

    fh = dl.grab(baseurl % threeletter, [404])
    if not fh:
        return
    messy = messytables.excel.XLSTableSet(fh)
    table = xypath.Table.from_messy(list(messy.tables)[0])
    indicators = table.filter(is_in(indicator_list))
    indname = indicators.shift(x=-1)
    if not len(indname) == len(indicator_list):
        print "missing indicators", [x.value for x in indname]

    code = table.filter(equal_to('Indicator Code'))

    years = code.fill(xypath.RIGHT)
    junction = indname.junction(years)
    for ind_cell, year_cell, value_cell in junction:
        vdict = dict(value)
        vdict['indID'] = ind_cell.value
        vdict['period'] = year_cell.value
        vdict['value'] = value_cell.value

        indicator = {'indID': vdict['indID']}
        nameunits = re.search('(.*)\((.*)\)', vdict['indID'])
        if nameunits:
            (indicator['name'], indicator['units']) = nameunits.groups()
        else:
            indicator['name'] = vdict['indID']
            indicator['units'] = 'uno'
        Indicator(**indicator).save()
        v = Value(**vdict)
        if not v.is_blank():
            v.save()
    print len(session.query(Value).filter(Value.dsID == 'World Bank').all())
    session.commit()
Пример #23
0
    def test_simple_status(self):
        """GET / displays some recent statuses"""
        instance_path = tempfile.mkdtemp()
        app.instance_path = instance_path
        filenames = []
        for sha in range(10):
            filename = os.path.join(app.instance_path,
                                    "status_{0}.txt".format(sha))
            with open(filename, "w+") as f:
                f.write("\n".join(["{0}: Signature missing",
                                   "{0}: Needs more reviewers"]).format(sha))
            filenames.append(filename)

        tester = app.test_client(self)
        response = tester.get("/")

        assert_that(response.status_code, equal_to(200))
        for sha in range(10):
            assert_that("/status/{0}".format(sha), is_in(str(response.data)))

        shutil.rmtree(instance_path)
Пример #24
0
    def test_install_uninstall(self):
        lsm = LocalSiteManager(None, None)
        registration = UtilityRegistration(lsm, None, None, None, None)
        event = Registered(registration)

        class IFoo(Interface):
            pass

        # If we're not contained, we get proxied!
        class Foo(Contained):
            pass

        install_utility_on_registration(Foo(), 'name', IFoo, event)

        assert_that(lsm['name'], is_(Foo))
        assert_that(lsm.getUtility(IFoo), is_(Foo))

        queryNextUtility(lsm['name'], IFoo)

        uninstall_utility_on_unregistration('name', IFoo, event)

        assert_that('name', is_not(is_in(lsm)))
        assert_that(lsm.queryUtility(IFoo), is_(none()))
def step_attacked_by(context, a_, opponent):
    context.ninja_fight.opponent = opponent
    # -- VERIFY: Optional part feature.
    assert_that(a_, is_in(["a", None]))
    assert_that(opponent, is_in(["Chuck Norris", "samurai"]))
Пример #26
0
def check_wake_word_file_status(context):
    """An account that contributed wake word samples has those samples removed."""
    deleted_account = context.accounts["foo"]
    file_repository = WakeWordFileRepository(context.db)
    files_pending_delete = file_repository.get_pending_delete()
    assert_that(deleted_account.id, is_in(files_pending_delete))
Пример #27
0
 def assert_filter_by(self, expr):
     assert_that(expr, is_in(self.filter_by))
Пример #28
0
 def _get_prop():
     stack.get()
     return waiter.expect_that(
         getattr(stack, property_name).lower(),
         is_not(is_in(transit_values)))
Пример #29
0
 def check_button_import_key_pair_disabled(self):
     """Step to check `import Key Pair` disabled if quota exceeded."""
     page_keypairs = self._page_keypairs()
     assert_that(
         'disabled',
         is_in(page_keypairs.button_import_keypair.get_attribute("class")))
Пример #30
0
 def _check_router_rescheduled():
     l3_agents = self.get_l3_agents_for_router(
         router, filter_attrs=config.HA_STATE_ACTIVE_ATTRS, check=False)
     waiter.expect_that(l3_agents, is_not(empty()))
     waiter.expect_that(old_l3_agent, is_not(is_in(l3_agents)))
     return l3_agents
Пример #31
0
 def AssertResponse(self, response):
     assert_that(response.status_code, equal_to(requests.codes.ok))
     assert_that(HMAC_HEADER, is_in(response.headers))
     assert_that(self._ContentHmacValid(response), equal_to(True))
Пример #32
0
 def test_contains(self) -> None:
     assert_that("a", is_in(self.data_backend))
Пример #33
0
 def YcmCoreNotImported_test(self):
     assert_that('ycm_core', is_not(is_in(sys.modules)))
Пример #34
0
 def is_found(self):
     bridge_ids = (bridge.id for bridge in self._ari.bridges.list())
     return is_in(list(bridge_ids))
def validate_updated_skill_setting_value(context):
    _get_device_skill_settings(context)
    assert_that(len(context.device_skill_settings), equal_to(3))
    expected_settings_values = dict(textfield='New skill text value')
    assert_that(expected_settings_values,
                is_in(context.device_settings_values))
Пример #36
0
 def is_hungup(self):
     channel_ids = (channel.id for channel in self._ari.channels.list())
     return all_of(instance_of(str), not_(is_in(list(channel_ids))))
Пример #37
0
 def is_ringing(self):
     channels = self._ari.channels.list()
     channel_ids = (channel.id for channel in channels
                    if channel.json['state'] == 'Ringing')
     return is_in(list(channel_ids))
Пример #38
0
 def is_ringback(self):
     # There is currently no way to tell if a channel is ringback or not. It is considered Up.
     channels = self._ari.channels.list()
     channel_ids = (channel.id for channel in channels
                    if channel.json['state'] == 'Up')
     return is_in(list(channel_ids))
Пример #39
0
def check_request_success(context):
    assert_that(
        context.response.status_code, is_in([HTTPStatus.OK, HTTPStatus.NO_CONTENT])
    )
Пример #40
0
def step_impl(context):
    context.matching = context.search.get_automatic_matching()
    for i in context.matching:
        assert_that("wikip", is_in(i))
Пример #41
0
 def _check_router_is_on_agent():
     l3_agents = self.get_l3_agents_for_router(router, check=False)
     return waiter.expect_that(l3_agent, is_in(l3_agents))
Пример #42
0
def step_impl(context):
    context.chrome_driver.implicitly_wait(5)
    context.result = Result(context.chrome_driver)
    new_url = context.result.get_new_url()
    assert_that("search?source=", is_in(new_url))
Пример #43
0
 def _check_port_interface_presence():
     ports = self._client.get_interfaces_ports(router['id'])
     matcher = is_in(ports)
     if not must_present:
         matcher = is_not(matcher)
     return waiter.expect_that(port, matcher)
Пример #44
0
def test_add_widget_simple():
    # First, make sure we're at the dashboard page.
    # (Note: We want the first thing we do in this test function to be a yield,
    # so that later asserts which aren't contained in yielded functions are not
    # executed when nose runs this function to acquire the generator.)
    yield check_we_are_at_dashboard_page

    # Click 'Add Widget' (also checks that we end up on the 'Create a new
    # Widget' page)
    yield click_add_widget

    # If we click Cancel, do we end up back on the dashboard page?
    yield click_cancel

    # Return to Add Widget page
    yield click_add_widget

    # Open the username menu, so we can check the links
    expand_username_menu()

    # Verify the 'Devices', 'Advanced Options' and 'Manage Account' links
    yield do_check_link("Devices", splinter_tests.SERVER_URL + "/#/devices")
    yield do_check_link("Advanced Options",
                        splinter_tests.SERVER_URL + "/#/advanced")
    yield do_check_link("Manage Account", "https://login.etherios.com/home.do")

    # 'Cancel' should bring us back to the dashboard
    yield click_cancel

    # 'Add Widget' should bring us back there
    yield click_add_widget

    # Verify all the other links that should be on this page.
    for linktext, url in get_general_page_links():
        yield do_check_link(linktext, url)

    # Wait for Angular to catch up to us (specifically, to allow Angular to
    # fetch the user's devices and populate the selection box)
    do_sleep()

    # Test how selecting a gateway changes the error state on the page
    # TODO Should this go in something like test_add_widget_page?

    gateway_selection_row = browser.find_by_xpath(
        # Find the 'select' with name 'device', get its grandparent
        '//select[@name = "device"]/../..')
    assert not gateway_selection_row.is_empty()
    assert gateway_selection_row.first.has_class('has-error')

    # There should also be some error text near the top of the page
    # Find the list item with a bold "Gateway:" string inside it
    err_item_xpath = ("//div[contains(@class, 'alert alert-danger')]/ul/li"
                      "/strong[.='Gateway:']/..")
    gateway_error = browser.find_by_xpath(err_item_xpath)
    assert not gateway_error.is_empty()
    # Check that this item is visible on the page
    assert gateway_error.first.visible
    # The error should be 'You need to select a gateway'
    assert_that("You need to select a gateway", is_in(gateway_error.text))

    # If we select a gateway, the has-error class should go away
    # test_user has only one device, so select value 0
    browser.select("device", "0")

    assert not gateway_selection_row.first.has_class('has-error')
    # The error should also disappear
    # The 'Gateway:' error item is only hidden when the value becomes valid,
    # and not destroyed, so we can reuse the gateway_error variable from above
    assert not gateway_error.first.visible
 def _assert_no_docker_image_running(self, name):
     assert_that(name, is_not(is_in(sh.docker('ps'))))
Пример #46
0
def impl(context, character_name, place_name):
    character = get_character(context, character_name)
    place = get_location(context, place_name)

    assert_that(character, is_not(is_in(place['\ufdd0:characters'])))
Пример #47
0
    def test_demonizedoptionsilence(self):
        sys.stdout = MemoryWriter()
        sys.stderr = MemoryWriter()
        sys.stdin = MemoryReader()
        fh = open(ACONFIG, 'w')
        fh.write('info = green, on_blue\n')
        fh.write('debug = yellow\n')
        fh.close()

        class OptionsMock2(object):
            def __init__(self):
                pass

            def __getattr__(self, method):
                if method == 'silence':
                    return True
                if method == 'configfile':
                    return ACONFIG
                return False

        class ActionMock(object):
            def __init__(self):
                pass

            def notify(self, message, log):
                pass

            def connectSMTP(self):
                pass

        def setup_mail(properties):
            return ActionMock()

        def wait_for(secs):
            if self.raise_count == 0:
                write_log()
                return
            raise KeyboardInterrupt

        def chdir(directory):
            return True

        def umask(integer):
            return True

        def setsid():
            return True

        def dup2(one, two):
            return True

        def fork():
            return -1

        onelogtrace = 'this is an info booo log trace'
        anotherlogtrace = 'this is a debug log trace'

        def write_log():
            fh = open(self.log_name, 'a')
            fh.write(onelogtrace + '\n')
            fh.write(anotherlogtrace + '\n')
            fh.close()
            self.raise_count += 1

        log4tailer.setup_mail = setup_mail
        options_mock = OptionsMock2()
        args = [self.log_name]
        default_config = DefaultConfig()
        log4tailer.setup_config(options_mock, default_config)
        os.fork = fork
        os.chdir = chdir
        os.setsid = setsid
        os.dup2 = dup2
        os.umask = umask
        log4tailer.monitor(options_mock, args, default_config, wait_for)
        expectedlogtrace = ("\x1b[32m\x1b[44mthis is an info booo log "
                            "trace\x1b[0m")
        assert_that(expectedlogtrace, is_in(sys.stdout.captured))
Пример #48
0
 def _check_router_rescheduled():
     l3_agents = self._client.get_l3_agents_for_router(router['id'])
     return waiter.expect_that(old_l3_agent, is_not(is_in(l3_agents)))
Пример #49
0
def YouCompleteMe_YcmCoreNotImported_test( ycm ):
  assert_that( 'ycm_core', is_not( is_in( sys.modules ) ) )
Пример #50
0
 def _check_network_rescheduled():
     dhcp_agents = self._client.get_dhcp_agents_for_network(
         network['id'])
     dhcp_agents_ids = [agent['id'] for agent in dhcp_agents]
     return waiter.expect_that(old_dhcp_agent['id'],
                               is_not(is_in(dhcp_agents_ids)))
Пример #51
0
 def test_empty_input_does_not_raise_500(self):
     """
     Ensure empty/unsaved data does not raise 500s in serializer.
     """
     response = self.create_empty_via_api()
     assert_that(response.status_code, is_in([201, 400]))
             'source': baseurl.format(threeletter.lower()),
             'is_number': True}

    while True:
        fh = dl.grab(baseurl.format(threeletter), [404])
        if not fh:
            return
        try:
            messy = messytables.excel.XLSTableSet(fh)
            break  # success!
        except messytables.error.ReadError, e:
            print e
            return
            
    table = xypath.Table.from_messy(list(messy.tables)[0])
    indicators = table.filter(is_in(indicator_list))
    indname = indicators.shift(x=-1)
    if not len(indname) == len(indicator_list):
        print "missing indicators", [x.value for x in indname]

    code = table.filter(equal_to('Indicator Code'))

    years = code.fill(xypath.RIGHT)
    junction = indname.junction(years)
    for ind_cell, year_cell, value_cell in junction:
        vdict = dict(value)
        vdict['indID'] = ind_cell.value
        vdict['period'] = year_cell.value
        vdict['value'] = value_cell.value

        indicator = {'indID': vdict['indID']}
Пример #53
0
 def YcmCoreNotImported_test( self ):
   assert_that( 'ycm_core', is_not( is_in( sys.modules ) ) )
Пример #54
0
def step_attacked_by(context, a_, opponent):
    context.ninja_fight.opponent = opponent
    # -- VERIFY: Optional part feature.
    assert_that(a_, is_in(["a", None]))
    assert_that(opponent, is_in(["Chuck Norris", "samurai"]))
Пример #55
0
def check_for_added_files(context):

    def check_command_entity_association(cfile_id):
        c_result = context.connection.post(Statement("MATCH (e:FILE_ENTITY) <-[APPLIED_TO]- (c:COMMAND) "
                                                     "WHERE id(e) = {} RETURN c".format(context.mapping[cfile_id])))
        assert_that(len(c_result[0]['data']), is_(1), "Exactly one file data associated with " + file)

    entities = context.connection.find("FILE_ENTITY")
    assert_that(len(entities), is_(6), "We found 6 entities")

    # Make sure that the file entities are associated with one command object each
    for file in ["A", "B", "C", "D", "E", "F"]:
        check_command_entity_association(file)

    commands = context.connection.find("COMMAND")
    assert_that(len(commands), is_(6), "We found 6 commands")
    command_mapping = {}

    # Set up a mapping between filenames and commands operating on those files
    for command in commands:
        print(command[1]['data'])
        c_data = json.loads(command[1]['data'])
        if 'filename' in c_data:
            command_mapping[c_data['filename']] = command[1]
            command_mapping[c_data['filename']]['data'] = c_data

    # Verify that the data and type of each command is as expected
    assert_that(command_mapping["File A"]['data']['content'], is_("VGhpcyBpcyB0aGUgZmlsZSdzIGNvbnRlbnQ="))
    assert_that('content', not is_in(command_mapping["Directory B"]['data']))
    assert_that(command_mapping["File C"]['data']['content'], is_("U29tZSBvdGhlciBjb250ZW50"))
    assert_that('content', not is_in(command_mapping["File C"]['data']))
    assert_that(command_mapping["File D"]['data']['content'], is_("U3RpbGwgbW9yZSBjb250ZW50"))
    assert_that(command_mapping["File F"]['data']['content'], is_("SW50ZXJpb3Igc3R1ZmY="))

    assert_that(command_mapping["File A"]['data']['type'], is_("file"))
    assert_that(command_mapping["Directory B"]['data']['type'], is_("directory"))
    assert_that(command_mapping["File C"]['data']['type'], is_("file"))
    assert_that(command_mapping["File D"]['data']['type'], is_("file"))
    assert_that(command_mapping["Directory E"]['data']['type'], is_("directory"))
    assert_that(command_mapping["File F"]['data']['type'], is_("file"))

    assert_that(command_mapping["File A"]['type'], is_("create"))
    assert_that(command_mapping["Directory B"]['type'], is_("create"))
    assert_that(command_mapping["File C"]['type'], is_("create"))
    assert_that(command_mapping["File D"]['type'], is_("create"))
    assert_that(command_mapping["Directory E"]['type'], is_("create"))
    assert_that(command_mapping["File F"]['type'], is_("create"))

    # Ensure that the commands are associated with the previous revision id
    commands_associated = context.connection.post(Statement("MATCH (c:COMMAND) -[:OCCURRED]-> "
                                                            "(r:REVISION) WHERE id(r) = {} RETURN c"
                                                  .format(context.first_rev)))
    assert_that(len(commands_associated[0]['data']), is_(6), "We found 6 commands")

    # Make sure that the commit updated the current revision and left nothing behind.
    result = context.connection.post(Statement("MATCH (:BRANCH {name:'head'}) <-[:AT]- (r:REVISION) return r"))

    assert_that(len(result[0]['data']), is_(1), "There was only one current revision")

    result = context.connection.post(Statement("MATCH (:BRANCH {name: 'head'}) <-[:AT]- (r:REVISION) -[:APPLIED_TO]-> (n) return n"))

    assert_that(len(result[0]['data']), is_(0), "The new revision has no commands associated with it")
Пример #56
0
    def test_demonizedoptionsilence(self):
        sys.stdout = MemoryWriter()
        sys.stderr = MemoryWriter()
        sys.stdin = MemoryReader()
        fh = open(ACONFIG, 'w')
        fh.write('info = green, on_blue\n')
        fh.write('debug = yellow\n')
        fh.close()

        class OptionsMock2(object):
            def __init__(self):
                pass

            def __getattr__(self, method):
                if method == 'silence':
                    return True
                if method == 'configfile':
                    return ACONFIG
                return False

        class ActionMock(object):
            def __init__(self):
                pass

            def notify(self, message, log):
                pass

            def connectSMTP(self):
                pass

        def setup_mail(properties):
            return ActionMock()

        def wait_for(secs):
            if self.raise_count == 0:
                write_log()
                return
            raise KeyboardInterrupt

        def chdir(directory):
            return True

        def umask(integer):
            return True

        def setsid():
            return True

        def dup2(one, two):
            return True

        def fork():
            return -1

        onelogtrace = 'this is an info booo log trace'
        anotherlogtrace = 'this is a debug log trace'

        def write_log():
            fh = open(self.log_name, 'a')
            fh.write(onelogtrace + '\n')
            fh.write(anotherlogtrace + '\n')
            fh.close()
            self.raise_count += 1

        log4tailer.setup_mail = setup_mail
        options_mock = OptionsMock2()
        args = [self.log_name]
        default_config = DefaultConfig()
        log4tailer.setup_config(options_mock, default_config)
        os.fork = fork
        os.chdir = chdir
        os.setsid = setsid
        os.dup2 = dup2
        os.umask = umask
        log4tailer.monitor(options_mock, args, default_config,
                wait_for)
        expectedlogtrace = ("\x1b[32m\x1b[44mthis is an info booo log "
            "trace\x1b[0m")
        assert_that(expectedlogtrace,
                is_in(sys.stdout.captured))
Пример #57
0
def YouCompleteMe_YcmCoreNotImported_test( ycm ):
  assert_that( 'ycm_core', is_not( is_in( sys.modules ) ) )
Пример #58
0
 def subscribed():
     try:
         assert_that(uuid, not_(is_in(sentinel.consumers())))
     except requests.exceptions.ConnectionError:
         raise AssertionError()
Пример #59
0
 def assert_status(self, *statuses):
     assert_that(statuses, only_contains(instance_of(int)))
     assert_that(self.response.status_code, is_in(statuses),
                 self.response.text)
Пример #60
0
 def _check_network_is_on_agent():
     dhcp_agents = self._client.get_dhcp_agents_for_network(
         network['id'])
     return waiter.expect_that(dhcp_agent, is_in(dhcp_agents))