def test_lambda_upload_file(self):
        deploy_lambda = Deploy_Lambda(self.lambda_handler)
        package = deploy_lambda.package
        aws_lambda = package.aws_lambda

        deploy_lambda.add_function_source_code()

        assert run.__module__ == self.expected_module
        assert run.__name__ == 'run'
        assert '/osbot_aws/lambdas/dev/hello_world.py' in package.get_files()
        assert len(files_list(aws_lambda.folder_code)) == len(
            package.get_files())
        assert file_exists(
            path_combine(aws_lambda.folder_code,
                         'osbot_aws/lambdas/dev/hello_world.py'))

        assert aws_lambda.s3_bucket == f'{self.expected_account_id}-osbot-lambdas'
        assert aws_lambda.s3_key == f'lambdas/{self.expected_module}.zip'

        assert self.s3.file_exists(bucket=aws_lambda.s3_bucket,
                                   key=aws_lambda.s3_key) is True
        assert self.s3.file_delete(bucket=aws_lambda.s3_bucket,
                                   key=aws_lambda.s3_key) is True
        assert self.s3.file_exists(bucket=aws_lambda.s3_bucket,
                                   key=aws_lambda.s3_key) is False

        self.s3.folder_upload(folder=aws_lambda.folder_code,
                              s3_bucket=aws_lambda.s3_bucket,
                              s3_key=aws_lambda.s3_key)

        assert self.s3.file_exists(bucket=aws_lambda.s3_bucket,
                                   key=aws_lambda.s3_key) is True
    def test_process_folder(self):
        path_data = self.pre_processor.storage.hd2_data()

        filename = os.path.basename(self.test_file)
        folder_to_process = self.pre_processor.prepare_folder(self.temp_dir)
        assert folder_to_process.startswith(self.pre_processor.storage.hd1())
        assert os.path.isdir(folder_to_process)
        assert os.path.isfile(os.path.join(folder_to_process, filename))
        folder_delete_all(folder_to_process)

        assert not os.path.isfile(os.path.join(folder_to_process, filename))

        self.pre_processor.clear_data_and_status_folders()
        self.pre_processor.process_folder(self.temp_dir)
        assert os.path.isdir(folder_to_process)
        assert os.path.isfile(os.path.join(folder_to_process, filename))
        assert len(files_list(path_data)) == 1

        self.pre_processor.process_folder(self.temp_dir)
        assert len(files_list(path_data)) == 1

        folder_delete_all(folder_to_process)
        self.pre_processor.clear_data_and_status_folders()
    def test_process_files(self):
        path_data = self.pre_processor.storage.hd2_data()
        path_status = self.pre_processor.storage.hd2_status()

        assert len(files_list(path_data)) == 0
        assert len(
            files_list(path_status)) == 1  # should have the status.json file

        self.pre_processor.process_files()

        pprint('**********: DATA')
        pprint(files_list(path_data))
        pprint('**********: STATUS')
        pprint(files_list(path_status))
        pprint('------------------------')
        assert len(files_list(path_data)) > 0
        assert len(files_list(path_status)) == 1  # should have: status.json
 def files_in_target_Folder(self):
     return files_list(self.target_folder)
Beispiel #5
0
 def files(self):
     files = files_list(self.path_test_files)
     return list_filter(files, lambda x: x.find('.DS_Store') == -1
                        )  # todo: add better method to OSBot-utils
Beispiel #6
0
 def pdfs(self):
     return files_list(self.path_test_files, "*.jpg")
Beispiel #7
0
 def images(self):
     return files_list(self.path_test_files, "*.jpg")
Beispiel #8
0
 def jsons(self):
     return files_list(self.path_test_files, "*.json")