예제 #1
0
    def test_correct_output_nonempty(self, s3_client, local_client, capsys):
        config = {
            "targets": {
                "foo": {
                    "local_folder": local_client.get_uri(),
                    "s3_uri": s3_client.get_uri(),
                    "aws_access_key_id": "",
                    "aws_secret_access_key": "",
                    "region_name": "eu-west-2",
                }
            }
        }
        set_s3_index(
            s3_client,
            {
                "milk": {
                    "local_timestamp": get_timestamp(1989, 10, 23, 11, 30)
                },
                "honey": {
                    "local_timestamp": get_timestamp(2016, 12, 12, 8, 30)
                },
                "ginger": {
                    "local_timestamp": None
                },
            },
        )
        set_local_index(
            local_client,
            {
                "milk": {
                    "local_timestamp": get_timestamp(2016, 12, 12, 8, 30)
                },
                "honey": {
                    "local_timestamp": get_timestamp(2016, 11, 10, 18, 40)
                },
                "lemon": {
                    "local_timestamp": get_timestamp(2017, 2, 2, 8, 30)
                },
                "ginger": {
                    "local_timestamp": None
                },
            },
        )

        args = argparse.Namespace(target="foo",
                                  sort_by="key",
                                  show_all=False,
                                  descending=False)
        command = LsCommand(args, config, create_logger())
        command.run()

        out, err = capsys.readouterr()

        assert err == ""
        assert out == ("key    local                s3\n"
                       "-----  -------------------  -------------------\n"
                       "honey  2016-11-10 18:40:00  2016-12-12 08:30:00\n"
                       "lemon  2017-02-02 08:30:00\n"
                       "milk   2016-12-12 08:30:00  1989-10-23 11:30:00\n"
                       "Total Size: 0.00Mb\n")
예제 #2
0
    def test_correct_output_nonempty(self, s3_client, local_client, capsys):
        config = {
            'targets': {
                'foo': {
                    'local_folder': local_client.get_uri(),
                    's3_uri': s3_client.get_uri(),
                    'aws_access_key_id': '',
                    'aws_secret_access_key': '',
                    'region_name': 'eu-west-2',
                }
            }
        }
        set_s3_index(
            s3_client, {
                'milk': {
                    'local_timestamp': get_timestamp(1989, 10, 23, 11, 30)
                },
                'honey': {
                    'local_timestamp': get_timestamp(2016, 12, 12, 8, 30)
                },
                'ginger': {
                    'local_timestamp': None,
                }
            })
        set_local_index(
            local_client, {
                'milk': {
                    'local_timestamp': get_timestamp(2016, 12, 12, 8, 30)
                },
                'honey': {
                    'local_timestamp': get_timestamp(2016, 11, 10, 18, 40)
                },
                'lemon': {
                    'local_timestamp': get_timestamp(2017, 2, 2, 8, 30)
                },
                'ginger': {
                    'local_timestamp': None,
                }
            })

        args = argparse.Namespace(
            target='foo',
            sort_by='key',
            show_all=False,
            descending=False,
        )
        command = LsCommand(args, config, create_logger())
        command.run()

        out, err = capsys.readouterr()

        assert err == ""
        assert out == ('key    local                s3\n'
                       '-----  -------------------  -------------------\n'
                       'honey  2016-11-10 18:40:00  2016-12-12 08:30:00\n'
                       'lemon  2017-02-02 08:30:00\n'
                       'milk   2016-12-12 08:30:00  1989-10-23 11:30:00\n')
예제 #3
0
파일: main.py 프로젝트: Alexplusm/bazaa
def test_user_statistics():
    user_id = "i-user-2"
    game_id = "5c7713c7-3960-4c0d-ae7f-c27417ed234d"
    ext_system_id = "b0e4c252-9b72-4761-b574-fff694965dcf"
    params = {
        "extSystemId": ext_system_id,
        "gameIds": game_id,
        # "totalOnly": "TrUe",
        "from": str(get_timestamp(timedelta(days=-10))),
        "to": str(get_timestamp(timedelta(days=1))),
    }
    res = get_statistics_user(user_id, params)
    print("result: ", res)
예제 #4
0
    def test_show_all(self, s3_client, local_client, capsys):
        config = {
            "targets": {
                "foo": {
                    "local_folder": local_client.get_uri(),
                    "s3_uri": s3_client.get_uri(),
                    "aws_access_key_id": "",
                    "aws_secret_access_key": "",
                    "region_name": "eu-west-2",
                }
            }
        }
        set_s3_index(
            s3_client,
            {
                "cheese": {
                    "local_timestamp": get_timestamp(2017, 12, 12, 8, 30)
                },
                "crackers": {
                    "local_timestamp": None
                },
            },
        )
        set_local_index(
            local_client,
            {
                "cheese": {
                    "local_timestamp": get_timestamp(2017, 2, 2, 8, 30)
                },
                "crackers": {
                    "local_timestamp": None
                },
            },
        )

        args = argparse.Namespace(target="foo",
                                  sort_by="key",
                                  show_all=True,
                                  descending=False)
        command = LsCommand(args, config, create_logger())
        command.run()

        out, err = capsys.readouterr()

        assert err == ""
        assert out == ("key       local                s3\n"
                       "--------  -------------------  -------------------\n"
                       "cheese    2017-02-02 08:30:00  2017-12-12 08:30:00\n"
                       "crackers  <deleted>\n"
                       "Total Size: 0.00Mb\n")
예제 #5
0
    def test_show_all(self, s3_client, local_client, capsys):
        config = {
            'targets': {
                'foo': {
                    'local_folder': local_client.get_uri(),
                    's3_uri': s3_client.get_uri(),
                    'aws_access_key_id': '',
                    'aws_secret_access_key': '',
                    'region_name': 'eu-west-2',
                }
            }
        }
        set_s3_index(
            s3_client, {
                'cheese': {
                    'local_timestamp': get_timestamp(2017, 12, 12, 8, 30)
                },
                'crackers': {
                    'local_timestamp': None,
                }
            })
        set_local_index(
            local_client, {
                'cheese': {
                    'local_timestamp': get_timestamp(2017, 2, 2, 8, 30)
                },
                'crackers': {
                    'local_timestamp': None,
                }
            })

        args = argparse.Namespace(
            target='foo',
            sort_by='key',
            show_all=True,
            descending=False,
        )
        command = LsCommand(args, config, create_logger())
        command.run()

        out, err = capsys.readouterr()

        assert err == ""
        assert out == ('key       local                s3\n'
                       '--------  -------------------  -------------------\n'
                       'cheese    2017-02-02 08:30:00  2017-12-12 08:30:00\n'
                       'crackers  <deleted>\n')
예제 #6
0
def generate_telemetry():
    return {
        'device_id': REGISTERED_DEVICE_ID,
        'timestamp': get_timestamp(),
        'gps': {
            'lat': random.uniform(-90, 90),
            'lng': random.uniform(-180, 180),
        },
        # TODO if applicable (depends on vehicle propulsion ?) add "charge"
        # confirm if Agency must check with registred vehicle propulsion type
    }
예제 #7
0
def test_get_csv_intent():
    def helper(sc: tp.SystemCorpus) -> tp.CSVIntent:
        """In get_csv_intent() the newest tuple is obtained from file."""
        write_three_distinct_intents(sc)
        message = src.dataset.create_message('foo', 'bar', [], False, sc.corpus)
        response = tp.Response('bar', -1.0, [])
        classification = tp.Classification(sc.system, message, response)
        return src.results.get_csv_intent(classification)

    expected = tp.CSVIntent(id=3, timestamp=get_timestamp(), sentence='foo', gold_standard='bar',
                            classification='bar', confidence=-1.0, time=0)
    result = run_with_file_operations(test_get_csv_intent.__name__, helper)
    assert expected == result
예제 #8
0
def create_csv_intent(x: int) -> src.typ.CSVIntent:
    return src.typ.CSVIntent(x, get_timestamp(), 'sentence', 'intent', 'classification', -1.0, -1)
예제 #9
0
파일: game.py 프로젝트: Alexplusm/bazaa
import requests
import json
from datetime import timedelta, datetime

import sys
sys.path.append('../..')
from tests.config import get_url_start
from tests.utils import get_timestamp

url = get_url_start() + "/api/v1/game"

json_data = {
    "ext_system_id": "custom-ext_system-id",
    "name": "new game",
    "answer_type": 2,
    "start_date":   str(get_timestamp(timedelta(days=1))),
    "end_date":     str(get_timestamp(timedelta(days=3))),
    "question": "Choose answer",
    "options": "yep, nope"
}

json_data2 = {
    "ext_system_id": "custom-ext_system-id",
    "name": "new game",
    "answer_type": 2,
    "start_date":   str(get_timestamp(timedelta(days=1))),
    "end_date":     str(get_timestamp(timedelta(days=2))),
    "question": "Choose answer",
    "options": "yep, nope"
}
예제 #10
0
파일: main.py 프로젝트: Alexplusm/bazaa
from tests.statistics.statistics import (get_statistics_user)
from tests.screenshot.screenshot import (get_screenshot_results)

# prepare game

ext_system = {
    # "extSystemId": "ext-id-5",
    "description": "some description",
    "postResultsUrl": "https://abc/lol.php"
}

game = {
    "extSystemId": None,
    "name": "new game",
    "answerType": 2,
    "startDate": str(get_timestamp(timedelta(days=2))),
    "endDate": str(get_timestamp(timedelta(days=3))),
    "question": "Choose answer",
    "options": "yep, nope"
}


def complete_test():
    print("Config: ", get_url_start())
    ext_system_id = create_ext_system(ext_system)
    if ext_system_id is None:
        ext_system_id = ext_system["extSystemId"]

    game["extSystemId"] = ext_system_id
    game_id = create_game(game)
    if game_id is None: