import json
import unittest

import awacs.aws as aws
import awacs.s3 as s3


class TestConditions(unittest.TestCase):
    def test_for_all_values(self):
        c = aws.Condition(
            aws.ForAllValuesStringLike(
                "dynamodb:requestedAttributes", ["PostDateTime", "Message", "Tags"]
            )
        )
        pd = aws.PolicyDocument(
            Statement=[
                aws.Statement(
                    Action=[s3.ListBucket],
                    Effect=aws.Allow,
                    Resource=[s3.ARN("myBucket")],
                    Condition=c,
                )
            ]
        )
        self.assertEqual(
            {
                u"Statement": [
                    {
                        u"Action": [u"s3:ListBucket"],
                        u"Condition": {
                            u"ForAllValues:StringLike": {
                                u"dynamodb:requestedAttributes": [
                                    u"PostDateTime",
                                    u"Message",
                                    u"Tags",
                                ]
                            }
                        },
                        u"Effect": u"Allow",
                        u"Resource": [u"arn:aws:s3:::myBucket"],
                    }
                ]
            },
            json.loads(pd.to_json()),
        )

import json
import unittest

import awacs.aws as aws
import awacs.s3 as s3


class TestConditions(unittest.TestCase):
    def test_for_all_values(self):
        c = aws.Condition(
            aws.ForAllValuesStringLike(
                "dynamodb:requestedAttributes", ["PostDateTime", "Message", "Tags"]
            )
        )
        pd = aws.PolicyDocument(
            Statement=[
                aws.Statement(
                    Action=[s3.ListBucket],
                    Effect=aws.Allow,
                    Resource=[s3.ARN("myBucket")],
                    Condition=c,
                )
            ]
        )
        self.assertEqual(
            {
                "Statement": [
                    {
                        "Action": ["s3:ListBucket"],
                        "Condition": {
                            "ForAllValues:StringLike": {
                                "dynamodb:requestedAttributes": [
                                    "PostDateTime",
                                    "Message",
                                    "Tags",
                                ]
                            }
                        },
                        "Effect": "Allow",
                        "Resource": ["arn:aws:s3:::myBucket"],
                    }
                ]
            },
            json.loads(pd.to_json()),
        )

Remove 'u' prefix from strings
Remove 'u' prefix from strings

  import json
  import unittest
  
  import awacs.aws as aws
  import awacs.s3 as s3
  
  
  class TestConditions(unittest.TestCase):
      def test_for_all_values(self):
          c = aws.Condition(
              aws.ForAllValuesStringLike(
                  "dynamodb:requestedAttributes", ["PostDateTime", "Message", "Tags"]
              )
          )
          pd = aws.PolicyDocument(
              Statement=[
                  aws.Statement(
                      Action=[s3.ListBucket],
                      Effect=aws.Allow,
                      Resource=[s3.ARN("myBucket")],
                      Condition=c,
                  )
              ]
          )
          self.assertEqual(
              {
-                 u"Statement": [
+                 "Statement": [
                      {
-                         u"Action": [u"s3:ListBucket"],
+                         "Action": ["s3:ListBucket"],
-                         u"Condition": {
+                         "Condition": {
-                             u"ForAllValues:StringLike": {
+                             "ForAllValues:StringLike": {
-                                 u"dynamodb:requestedAttributes": [
+                                 "dynamodb:requestedAttributes": [
-                                     u"PostDateTime",
+                                     "PostDateTime",
-                                     u"Message",
+                                     "Message",
-                                     u"Tags",
+                                     "Tags",
                                  ]
                              }
                          },
-                         u"Effect": u"Allow",
+                         "Effect": "Allow",
-                         u"Resource": [u"arn:aws:s3:::myBucket"],
+                         "Resource": ["arn:aws:s3:::myBucket"],
                      }
                  ]
              },
              json.loads(pd.to_json()),
          )
  
Remove 'u' prefix from strings
## Code Before:
import json
import unittest

import awacs.aws as aws
import awacs.s3 as s3


class TestConditions(unittest.TestCase):
    def test_for_all_values(self):
        c = aws.Condition(
            aws.ForAllValuesStringLike(
                "dynamodb:requestedAttributes", ["PostDateTime", "Message", "Tags"]
            )
        )
        pd = aws.PolicyDocument(
            Statement=[
                aws.Statement(
                    Action=[s3.ListBucket],
                    Effect=aws.Allow,
                    Resource=[s3.ARN("myBucket")],
                    Condition=c,
                )
            ]
        )
        self.assertEqual(
            {
                u"Statement": [
                    {
                        u"Action": [u"s3:ListBucket"],
                        u"Condition": {
                            u"ForAllValues:StringLike": {
                                u"dynamodb:requestedAttributes": [
                                    u"PostDateTime",
                                    u"Message",
                                    u"Tags",
                                ]
                            }
                        },
                        u"Effect": u"Allow",
                        u"Resource": [u"arn:aws:s3:::myBucket"],
                    }
                ]
            },
            json.loads(pd.to_json()),
        )

## Instruction:
Remove 'u' prefix from strings
## Code After:
import json
import unittest

import awacs.aws as aws
import awacs.s3 as s3


class TestConditions(unittest.TestCase):
    def test_for_all_values(self):
        c = aws.Condition(
            aws.ForAllValuesStringLike(
                "dynamodb:requestedAttributes", ["PostDateTime", "Message", "Tags"]
            )
        )
        pd = aws.PolicyDocument(
            Statement=[
                aws.Statement(
                    Action=[s3.ListBucket],
                    Effect=aws.Allow,
                    Resource=[s3.ARN("myBucket")],
                    Condition=c,
                )
            ]
        )
        self.assertEqual(
            {
                "Statement": [
                    {
                        "Action": ["s3:ListBucket"],
                        "Condition": {
                            "ForAllValues:StringLike": {
                                "dynamodb:requestedAttributes": [
                                    "PostDateTime",
                                    "Message",
                                    "Tags",
                                ]
                            }
                        },
                        "Effect": "Allow",
                        "Resource": ["arn:aws:s3:::myBucket"],
                    }
                ]
            },
            json.loads(pd.to_json()),
        )
