"""Test IAM Policies for correctness."""
import json

from foremast.iam.construct_policy import construct_policy

ANSWER1 = {
    'Version': '2012-10-17',
    'Statement': [
        {
            'Effect': 'Allow',
            'Action': [
                's3:GetObject',
                's3:ListObject'
            ],
            'Resource': [
                'arn:aws:s3:::archaius-stage/forrest/unicornforrest',
                'arn:aws:s3:::archaius-stage/forrest/unicornforrest/*'
            ]
        }
    ]
}


def test_main():
    """Check general assemblage."""
    settings = {'services': {'s3': True}}
    policy_json = construct_policy(app='unicornforrest',
                                   env='stage',
                                   group='forrest',
                                   pipeline_settings=settings)

    assert json.loads(policy_json) == ANSWER1

    # TODO: Test other services besides S3
    settings.update({'services': {'dynamodb': ['coreforrest', 'edgeforrest',
                                               'attendantdevops']}})
    policy_json = construct_policy(pipeline_settings=settings)
    policy = json.loads(policy_json)

@@ -565,16 +565,140 @@
 age.%22%22%22%0A
+    settings = %7B%7D%0A%0A    policy_json = construct_policy(pipeline_settings=settings)%0A    assert json.loads(policy_json) == %7B%7D%0A%0A
     sett

Test IAM Policy with no "services"