def test_if_file_was_uploaded_to_s3(self):
        upload_zip_to_s3(self.project, mock.MagicMock(Logger))

        s3_object_list = [
            o for o in self.s3.Bucket('palp-lambda-zips').objects.all()]
        self.assertEqual(s3_object_list[0].bucket_name, 'palp-lambda-zips')
        self.assertEqual(s3_object_list[0].key, 'v123/palp.zip')
    def test_if_file_was_uploaded_to_s3_with_bucket_prefix(self):
        self.project.set_property("bucket_prefix", "palp/")

        upload_zip_to_s3(self.project, mock.MagicMock(Logger))

        s3_object_list = [o for o in self.s3.Bucket("palp-lambda-zips").objects.all()]
        self.assertEqual(s3_object_list[0].bucket_name, "palp-lambda-zips")
        self.assertEqual(s3_object_list[0].key, "palp/v123/palp.zip")
 def test_release_successful_with_bucket_prefix(self):
     self.project.set_property("bucket_prefix", "palp/")
     upload_zip_to_s3(self.project, mock.MagicMock(Logger))
     lambda_release(self.project, mock.MagicMock(Logger))
     s3_keys = [o.key for o in self.s3.Bucket(self.bucket_name).objects.all()]
     release_keyname = "{0}latest/{1}.zip".format(self.project.get_property("bucket_prefix"), self.project.name)
     self.assertTrue(release_keyname in s3_keys)
     s3_grants = self.s3.Object(bucket_name=self.bucket_name, key=release_keyname).Acl().grants
     self.assertDictContainsSubset({"Permission": "FULL_CONTROL"}, s3_grants[0])
    def test_teamcity_output_if_set(self, flush_text_line_mock):
        self.project.set_property("teamcity_output", True)
        self.project.set_property("teamcity_parameter", "palp_keyname")

        upload_zip_to_s3(self.project, mock.MagicMock(Logger))

        flush_text_line_mock.assert_called_with(
            ("##teamcity[setParameter " "name='palp_keyname' value='v123/palp.zip']")
        )
 def test_release_successful(self):
     upload_zip_to_s3(self.project, mock.MagicMock(Logger))
     lambda_release(self.project, mock.MagicMock(Logger))
     s3_keys = [o.key for o
                in self.s3.Bucket(self.bucket_name).objects.all()]
     release_keyname = '{0}latest/{1}.zip'.format(
             self.project.get_property('bucket_prefix'), self.project.name)
     self.assertTrue(release_keyname in s3_keys)
     s3_grants = self.s3.Object(
         bucket_name=self.bucket_name, key=release_keyname).Acl().grants
     self.assertDictContainsSubset(
         {"Permission": "FULL_CONTROL"},
         s3_grants[0],
         "Default ACL of FULL_CONTROL not found!")
    def test_teamcity_output_if_not_set(self, flush_text_line_mock):
        upload_zip_to_s3(self.project, mock.MagicMock(Logger))

        flush_text_line_mock.assert_not_called()