Exemplo n.º 1
0
 def test__init__(self):
     temp_file = Temp_File()
     assert Files.exists(temp_file.tmp_folder)
     assert Files.not_exists(temp_file.tmp_file)
     assert Files.not_exists(temp_file.file_path)
     assert temp_file.tmp_folder in temp_file.file_path
     assert '/' == temp_file.file_path.replace(temp_file.tmp_folder,
                                               '').replace(
                                                   temp_file.tmp_file, '')
Exemplo n.º 2
0
    def test__using_with__no_params(self):
        with Temp_File() as temp:
            assert Files.file_extension(temp.file_path) == '.tmp'
            assert Files.exists(temp.file_path)
            assert Files.contents(temp.file_path) == '...'
        assert Files.not_exists(temp.file_path)

        with Temp_File('abc', 'txt') as temp:
            assert Files.file_extension(temp.file_path) == '.txt'
            assert Files.exists(temp.file_path)
            assert Files.contents(temp.file_path) == 'abc'
        assert Files.not_exists(temp.file_path)
Exemplo n.º 3
0
def upload_dependency(target):
    s3        = S3()
    s3_bucket = AWS_Config().lambda_s3_bucket()
    s3_file   = 'lambdas-dependencies/{0}.zip'.format(target)
    path_libs = Files.path_combine('../../../_lambda_dependencies/', target)
    if Files.not_exists(path_libs):
        raise Exception(f"In Lambda upload_dependency, could not find dependency for: {target} , which resolved to {path_libs}")
    s3.folder_upload(path_libs, s3_bucket, s3_file)
    return s3.file_exists(s3_bucket, s3_file)
Exemplo n.º 4
0
    def start(self):
        if Files.not_exists(self.web_root):
            Files.folder_create(self.web_root)  # make sure root folder exists

        self.server_proc = subprocess.Popen(
            [self.python_path, "-m", "http.server",
             str(self.port)],
            cwd=self.web_root)
        self.wait_for_server_started()
        return self