Exemplo n.º 1
0
    def test_dose_not_exist(self, s3_client, now_time_string):
        repository = AttendanceHistoryRepository()
        repository.s3 = s3_client

        JST = timezone(timedelta(hours=+9), 'JST')
        dt = datetime.strptime(now_time_string, '%Y/%m/%d %H:%M:%S')
        target_timestamp = datetime.fromtimestamp(timestamp=dt.timestamp(),
                                                  tz=JST)

        repository.merged_data(target_timestamp)
Exemplo n.º 2
0
    def test_normal(self, s3_client, put_bucket_items, now_time_string,
                    source_file):
        repository = AttendanceHistoryRepository()
        repository.s3 = s3_client

        JST = timezone(timedelta(hours=+9), 'JST')
        dt = datetime.strptime(now_time_string, '%Y/%m/%d %H:%M:%S')
        target_timestamp = datetime.fromtimestamp(timestamp=dt.timestamp(),
                                                  tz=JST)

        merged_data = repository.merged_data(target_timestamp)

        assert merged_data is not None

        rel_path = f'fixtures/{source_file}'
        filename = str(Path(__file__).parent.joinpath(rel_path).resolve())

        with open(filename) as fp:
            assert merged_data == fp.read()
Exemplo n.º 3
0
    def test_normal(self, now_time_string, expected):
        JST = timezone(timedelta(hours=+9), 'JST')
        dt = datetime.strptime(now_time_string, '%Y/%m/%d %H:%M:%S')
        target_timestamp = datetime.fromtimestamp(timestamp=dt.timestamp(),
                                                  tz=JST)

        get_put_file_key = \
            AttendanceHistoryRepository()._get_data_file_key(target_timestamp)

        assert get_put_file_key == expected
Exemplo n.º 4
0
    def test_normal(self, time_list, time_string):
        JST = timezone(timedelta(hours=+9), 'JST')
        dt = datetime.strptime(time_string, '%Y/%m/%d %H:%M:%S')
        target_timestamp = datetime.fromtimestamp(timestamp=dt.timestamp(),
                                                  tz=JST)

        target_list = \
            AttendanceHistoryRepository()._fetch_target_lists(target_timestamp)

        assert len(target_list) == len(time_list)
        assert target_list == time_list
Exemplo n.º 5
0
    def test_normal(self, now_time_string, finish_date_string):
        JST = timezone(timedelta(hours=+9), 'JST')
        dt = datetime.strptime(now_time_string, '%Y/%m/%d %H:%M:%S')
        target_timestamp = datetime.fromtimestamp(timestamp=dt.timestamp(),
                                                  tz=JST)

        finish_date = \
            AttendanceHistoryRepository()._get_finish_date(target_timestamp)

        expected = datetime.strptime(finish_date_string, '%Y/%m/%d %H:%M:%S')

        assert finish_date == expected
Exemplo n.º 6
0
    def test_normal(self, s3_client, now_time_string, source_file, dist_file):
        repository = AttendanceHistoryRepository()
        repository.s3 = s3_client

        JST = timezone(timedelta(hours=+9), 'JST')
        dt = datetime.strptime(now_time_string, '%Y/%m/%d %H:%M:%S')
        target_timestamp = datetime.fromtimestamp(timestamp=dt.timestamp(),
                                                  tz=JST)

        bucket_name = os.environ['HISTORY_DATA_BUCKET_NAME']
        key_prefix = os.environ['HISTORY_DATA_KEY_PREFIX']

        rel_path = f'fixtures/{source_file}'
        fixture_filename = str(
            Path(__file__).parent.joinpath(rel_path).resolve())

        with open(fixture_filename) as fp:
            repository.put_data(fp.read(), target_timestamp)

        object = s3_client.get_object(Bucket=bucket_name,
                                      Key=f'{key_prefix}{dist_file}')

        assert object.get('Body') is not None