Ejemplo n.º 1
0
    def test_valid_json(self, mock_s3client, mock_matcher):
        # Mock Setup
        mock_returned_s3client = mock_s3client()
        mock_s3client.does_bucket_exist.return_value = True
        mock_matcher.return_value = [
            'release-1.0.0.tar.gz', 'release-1.0.1.tar.gz'
        ]

        io = testutil.mock_stdout()
        testutil.put_stdin(payloads.check_payload)

        self.assertEqual(0, check.execute())

        # Mock Assertions
        mock_s3client.assert_called_with("apiKey123", "secretKey321",
                                         "eu-west-1")
        mock_returned_s3client.does_bucket_exist.assert_called_with(
            'bucketName')
        mock_returned_s3client.list_files.assert_called_with('bucketName')
        mock_matcher.assert_called_once_with("release-(.*).tar.gz",
                                             unittest.mock.ANY,
                                             "release-1.0.0.tar.gz")

        self.assertEqual(
            '[{"version": "release-1.0.0.tar.gz"}, {"version": "release-1.0.1.tar.gz"}]',
            testutil.read_from_io(io))
Ejemplo n.º 2
0
    def test_invalid_json(self):
        testutil.put_stdin('{"sourcez":{'
                           '"apiKey":"apiKey123",'
                           '"secretKey":"secretKey321'
                           '"},'
                           '"version":{"version":"version-v1-dev"}}')

        self.assertEqual(-1, check.execute())
Ejemplo n.º 3
0
    def test_valid_json_invalid_credentials_or_bucket_does_not_exist(
            self, mock_s3client):
        # Mock Setup
        mock_returned_s3client = mock_s3client()
        mock_returned_s3client.does_bucket_exist.return_value = False

        testutil.put_stdin(payloads.check_payload)
        self.assertEqual(-1, check.execute())
Ejemplo n.º 4
0
    def test_valid_json_without_version(self, mock_class):
        # Mock Setup
        mock_class.does_bucket_exist.return_value = True

        io = testutil.mock_stdout()
        testutil.put_stdin(payloads.check_payload_without_version)
        self.assertEqual(0, check.execute())
        self.assertEqual("[]", testutil.read_from_io(io))
    def test_version_not_required_json(self):
        testutil.put_stdin(
            """
            {
               "source":{
                  "access_key_id": "apiKey123",
                  "secret_access_key": "secretKey321"
               }
            }
            """)

        self.assertEqual(check.execute(), 0)
    def test_version_is_empty(self):
        testutil.put_stdin(
            """
            {
               "source":{
                  "access_key_id": "apiKey123",
                  "secret_access_key": "secretKey321"
               },
               "version": {}
            }
            """)

        self.assertEqual(check.execute(), 0)
Ejemplo n.º 7
0
    def test_invalid_json(self):
        testutil.put_stdin("""
            {
               "sourcez":{
                  "user": "******",
                  "password": "******",
                  "host": "hostname"
               },
               "version":{
                  "version": ""
               }
            }
            """)

        self.assertEqual(check.execute(), -1)
Ejemplo n.º 8
0
 def test_invalid_mysql(self, mock_mysql_handler):
     mock_mysql_handler.return_value = None
     testutil.put_stdin("""
         {
            "source":{
               "user": "******",
               "password": "******",
               "host": "hostname"
            },
            "version":{
               "version": "some-version"
            }
         }
         """)
     self.assertEqual(check.execute(), -1)
    def test_invalid_json(self):
        testutil.put_stdin(
            """
            {
               "sourcez":{
                  "access_key_id": "apiKey123",
                  "secret_access_key": "secretKey321"
               },
               "version":{
                  "schema": "version-v1-dev"
               }
            }
            """)

        self.assertEqual(check.execute(), -1)
Ejemplo n.º 10
0
 def test_valid_mysql(self, mock_mysql_handler):
     mock_actual_instance = mock_mysql_handler()
     io = testutil.mock_stdout()
     testutil.put_stdin("""
         {
            "source":{
               "user": "******",
               "password": "******",
               "host": "hostname"
            },
            "version":{
               "version": "some-version"
            }
         }
         """)
     self.assertEqual(check.execute(), 0)
     mock_actual_instance.close_connection.assert_called_once()
     self.assertEqual(testutil.read_from_io(io), "[{}]")
Ejemplo n.º 11
0
    def test_json(self):
        testutil.put_stdin(
            """
            {
               "source":{
                  "access_key_id": "apiKey123",
                  "secret_access_key": "secretKey321"
               },
               "version":{
                  "schema": "version-v1-dev"
               }
            }
            """)

        self.assertEqual(check.execute(), 0)
        Serverless.execute_command.assert_called_once_with(['config', 'credentials',
                                                            '--provider', 'aws',
                                                            '--key', 'apiKey123',
                                                            '--secret', 'secretKey321'])