def test_deletion_filtered_tags(): """ Test deletion methods """ # creating tests objects first_ami = AMI() first_ami.name = "test-ami1" first_ami.id = 'ami-28c2b348' first_ami.creation_date = "2017-11-04T01:35:31.000Z" second_ami = AMI() second_ami.name = "test-ami2" second_ami.id = 'ami-28c2b349' second_ami.creation_date = "2017-11-04T01:35:31.000Z" second_ami.tags = [ AWSTag.object_with_json(dict(Key="env", Value="prod")), AWSTag.object_with_json(dict(Key="role", Value="nginx")), ] third_ami = AMI() third_ami.name = "test-ami3" third_ami.id = 'ami-28c2b350' third_ami.creation_date = "2017-11-04T01:35:31.000Z" third_ami.tags = [ AWSTag.object_with_json(dict(Key="env", Value="dev")), AWSTag.object_with_json(dict(Key="role", Value="nginx")), ] # constructing dicts amis_dict = dict() amis_dict[first_ami.id] = first_ami amis_dict[second_ami.id] = second_ami amis_dict[third_ami.id] = third_ami parser = parse_args( [ '--keep-previous', '0', '--tag', 'role=nginx', ] ) app = App(parser) # testing filter candidates = app.fetch_candidates(amis_dict) candidates_tobedeleted = app.prepare_candidates(candidates) assert len(candidates) == 3 assert candidates_tobedeleted == [second_ami, third_ami] parser = parse_args( [ '--keep-previous', '0', '--tag', 'role=nginx', '--tag', 'env=dev', ] ) app = App(parser) candidates_tobedeleted2 = app.prepare_candidates(candidates) assert len(candidates) == 3 assert candidates_tobedeleted2 == [third_ami]
def test_get_awstag_from_none(): aws_tag = AWSTag.object_with_json(None) assert aws_tag is None
def test_get_awstag_from_none(): aws_tag = AWSTag.object_with_json(None) assert aws_tag is None
def test_get_awstag_from_json(): json_to_parse = {"Key": "Name", "Value": "Test"} aws_tag = AWSTag.object_with_json(json_to_parse) assert aws_tag.value == "Test" assert aws_tag.key == "Name"
def test_get_awstag_from_json(): json_to_parse = {"Key": "Name", "Value": "Test"} aws_tag = AWSTag.object_with_json(json_to_parse) assert aws_tag.value == "Test" assert aws_tag.key == "Name"