Пример #1
0
def describe_checked(region, criteria):
    instances = TEST_FLEET or fleet.Fleet(region)
    is_included = filters.compile(criteria)
    matches = filter(is_included, instances)

    for match in matches:
        click.echo(describe_instance(match))
Пример #2
0
 def test_multiple_criteria(self):
     is_included = filters.compile([
         'role:hammer',
         'target:nail',
     ])
     assert is_included({'role': 'hammer', 'target': 'nail',
                         'other': 'whocares'})
     assert not is_included({'role': 'hammer'})
     assert not is_included({'role': 'hammer', 'target': 'other'})
     assert not is_included({'role': 'other', 'target': 'nail'})
Пример #3
0
def list_checked(region, criteria, public=False, private=False):
    instances = TEST_FLEET or fleet.Fleet(region)
    is_included = filters.compile(criteria)
    matches = filter(is_included, instances)

    if public:
        show = lambda i: i['PublicDnsName']
    elif private:
        show = lambda i: i['PrivateDnsName']
    else:
        show = lambda i: i['Id']

    for i in matches:
        s = show(i)
        if s:
            click.echo(s)
Пример #4
0
 def test_single_criteria(self):
     is_included = filters.compile(['name:bob'])
     assert is_included({'name': 'bob'})
     assert is_included({'name': 'bob', 'other': 'whocares'})
     assert not is_included({'name': 'bub', 'other': 'whocares'})
Пример #5
0
 def test_empty_criteria_accepts_all(self):
     is_included = filters.compile([])
     assert is_included('cheese')
     assert is_included(None)
Пример #6
0
 def test_compiling_multi_colon_filter(self):
     is_included = filters.compile(['Name::::::'])
     assert is_included({'Name': ':::::'})
     assert not is_included({'Name': 'dog'})
Пример #7
0
 def test_compiling_bad_filter(self):
     with self.assertRaises(filters.InvalidCriteria):
         filters.compile(['dog'])