Exemplo n.º 1
0
def test_equality():
    nested_join = Join(Collection.ACHIEVEMENT).on("else")
    join1 = Join(Collection.ABILITY).on("something").nest(nested_join)
    join2 = Join(Collection.ABILITY).on("something").nest(nested_join)

    assert join1 == join2

    join1 = join1.to("yet")

    assert join1 != join2

    assert join1 != object()
Exemplo n.º 2
0
def test_factory_modify_nested():
    join: Join = Join(Collection.ABILITY).on("some_key")
    child_join: Join = Join(Collection.CURRENCY).on("another_key")

    join.nest(child_join)

    factory: Callable[[], Join] = join.get_factory()
    new_join: Join = factory()

    assert new_join == join

    child_join.to("yet_another_key")

    assert new_join != join
Exemplo n.º 3
0
def test_factory_modify_object():
    join: Join = Join(Collection.ABILITY).on("some_key")
    child_join: Join = Join(Collection.CURRENCY).on("another_key")

    join.nest(child_join)

    factory = join.get_factory()
    new_join: Join = factory()

    assert new_join == join

    join = join.to("yet_another_key")

    assert new_join != join
Exemplo n.º 4
0
def test_factory_alteration():
    join: Join = Join(Collection.ABILITY).on("some_key")

    factory = join.get_factory()
    new_join: Join = factory()

    assert new_join == join

    new_join = new_join.to("yet_another_key")
    new_new_join: Join = factory()

    assert new_new_join == join
Exemplo n.º 5
0
def test_items_lateral_nest():
    join = (Join(Collection.ABILITY).on("parent").nest(
        Join(Collection.ACHIEVEMENT).on("child")).nest(
            Join(Collection.CURRENCY).on("sibling")))
    assert str(
        join) == "ability^on:parent(achievement^on:child,currency^on:sibling)"
Exemplo n.º 6
0
def test_items_deep_nest():
    join = (Join(Collection.ABILITY).on("parent").nest(
        Join(Collection.ACHIEVEMENT).on("child").nest(
            Join(Collection.CURRENCY).on("grandchild"))))
    assert (str(join) ==
            "ability^on:parent(achievement^on:child(currency^on:grandchild))")
Exemplo n.º 7
0
def test_items_simple_nest():
    join = (Join(Collection.ABILITY).on("parent").nest(
        Join(Collection.ACHIEVEMENT).on("child")))
    assert str(join) == "ability^on:parent(achievement^on:child)"
Exemplo n.º 8
0
from typing import Callable

from ps2_census import Collection, Join

# Item to weapon
item_to_weapon_join_factory: Callable[[], Join] = (Join(
    Collection.ITEM_TO_WEAPON).on("item_id").to("item_id").inject_at(
        "item_to_weapon").get_factory())

weapon_join_factory: Callable[[], Join] = (Join(Collection.WEAPON).on(
    "weapon_id").to("weapon_id").inject_at("weapon").get_factory())

# Weapon to fire groups
weapon_to_fire_group_join_factory: Callable[[], Join] = (Join(
    Collection.WEAPON_TO_FIRE_GROUP).list(1).on("weapon_id").to(
        "weapon_id").inject_at("weapon_to_fire_groups").get_factory())

# Item to attachments
item_attachment_join_factory: Callable[[], Join] = (Join(
    Collection.ITEM_ATTACHMENT).on("item_id").to("item_id").list(1).inject_at(
        "item_attachments").nest(
            Join(Collection.ITEM).on("attachment_item_id").to("item_id").
            inject_at("item").nest(
                Join(Collection.ZONE_EFFECT).on("passive_ability_id").to(
                    "ability_id").list(1).inject_at("zone_effects").nest(
                        Join(Collection.ZONE_EFFECT_TYPE).on(
                            "zone_effect_type_id").to("zone_effect_type_id").
                        inject_at("zone_effect_type")))).get_factory())

# Weapon to datasheet
weapon_datasheet_join_factory: Callable[[], Join] = (Join(
Exemplo n.º 9
0
def test_join():
    join = Join(Collection.ACHIEVEMENT)
    query = Query(Collection.ABILITY).join(join)

    assert query.parameters == {"c:join": [str(join)]}
Exemplo n.º 10
0
##
#
#  This example gets pretty much everything that's to know about the TR TRAC-5 carbine.
#  Output is in the adjacent JSON file.
#
##

from typing import Callable

from ps2_census import Collection, Join, Query

item_to_weapon_join_factory: Callable[[], Join] = (Join(
    Collection.ITEM_TO_WEAPON).on("item_id").to("item_id").inject_at(
        "item_to_weapon").get_factory())

weapon_join_factory: Callable[[], Join] = (Join(Collection.WEAPON).on(
    "weapon_id").to("weapon_id").inject_at("weapon").get_factory())

weapon_to_fire_group_join_factory: Callable[[], Join] = (Join(
    Collection.WEAPON_TO_FIRE_GROUP).list(1).on("weapon_id").to(
        "weapon_id").inject_at("weapon_to_fire_groups").get_factory())

fire_group_join_factory: Callable[[], Join] = (Join(Collection.FIRE_GROUP).on(
    "fire_group_id").to("fire_group_id").inject_at("fire_group").get_factory())

fire_group_to_fire_mode_join_factory: Callable[[], Join] = (Join(
    Collection.FIRE_GROUP_TO_FIRE_MODE).list(1).on("fire_group_id").to(
        "fire_group_id").inject_at("fire_group_to_fire_modes").get_factory())

fire_mode_join_factory: Callable[[], Join] = (Join(Collection.FIRE_MODE_2).on(
    "fire_mode_id").to("fire_mode_id").inject_at("fire_mode").get_factory())
Exemplo n.º 11
0
def test_outer():
    join = Join(Collection.ABILITY).outer(1)
    assert str(join) == "ability^outer:1"
Exemplo n.º 12
0
def test_terms():
    join = Join(Collection.ABILITY).terms(("field1", "value1"), ("field2", 2))
    assert str(join) == "ability^terms:field1=value1'field2=2"
Exemplo n.º 13
0
def test_inject_at():
    join = Join(Collection.ABILITY).inject_at("field")
    assert str(join) == "ability^inject_at:field"
Exemplo n.º 14
0
def test_hide():
    join = Join(Collection.ABILITY).hide("field1", "field2")
    assert str(join) == "ability^hide:field1'field2"
Exemplo n.º 15
0
def test_show():
    join = Join(Collection.ABILITY).show("field1", "field2")
    assert str(join) == "ability^show:field1'field2"
Exemplo n.º 16
0
def test_list():
    join = Join(Collection.ABILITY).list(1)
    assert str(join) == "ability^list:1"
Exemplo n.º 17
0
def test_simple_nest():
    join = Join(Collection.ABILITY).nest(Join(Collection.ACHIEVEMENT))
    assert str(join) == "ability(achievement)"
Exemplo n.º 18
0
def test_join():
    join = Join(Collection.ABILITY)
    assert str(join) == "ability"
Exemplo n.º 19
0
import json
import time
from collections import Counter
from typing import Callable, Dict, Iterable, List, Tuple, Union

from ps2_census import Collection, Join, Query
from ps2_census.enums import Faction
from slugify import slugify

from utils import batch

ACTIVITY_PERIOD: int = 12 * 60 * 60

character_events_query_factory: Callable[[], Query] = Query(
    Collection.CHARACTERS_EVENT).join(
        Join(Collection.ACHIEVEMENT).on("achievement_id").to("achievement_id").
        inject_at("achievement")).join(
            Join(Collection.CHARACTER).outer(0).on("character_id").
            to("character_id").inject_at("character")).join(
                Join(Collection.CHARACTER).on("attacker_character_id").
                to("character_id").inject_at("attacker_character")).join(
                    Join(Collection.ITEM).on("attacker_weapon_id").
                    to("item_id").inject_at("attacker_weapon_item")).join(
                        Join(Collection.VEHICLE).on("attacker_vehicle_id").to(
                            "vehicle_id").inject_at("vehicle")).sort(
                                ("timestamp", -1)).get_factory()

outfit_members_query_factory: Callable[[], Query] = (Query(
    Collection.OUTFIT).join(
        Join(Collection.OUTFIT_MEMBER).on("outfit_id").to("outfit_id").
        outer(0).list(1).inject_at("members").nest(
            Join(Collection.CHARACTER).on("character_id").to("character_id").
Exemplo n.º 20
0
def test_deep_nest():
    join = Join(Collection.ABILITY).nest(
        Join(Collection.ACHIEVEMENT).nest(Join(Collection.CURRENCY)))
    assert str(join) == "ability(achievement(currency))"
Exemplo n.º 21
0
def test_multi_join():
    join_1 = Join(Collection.ACHIEVEMENT)
    join_2 = Join(Collection.CHARACTER)
    query = Query(Collection.ABILITY).join(join_1).join(join_2)

    assert query.parameters == {"c:join": [str(join_1), str(join_2)]}
Exemplo n.º 22
0
def test_lateral_nest():
    join = (Join(Collection.ABILITY).nest(Join(Collection.ACHIEVEMENT)).nest(
        Join(Collection.CURRENCY)))
    assert str(join) == "ability(achievement,currency)"
Exemplo n.º 23
0
from typing import Callable

from ps2_census import Collection, Join

# Fire group to fire mode
fire_group_to_fire_mode_join_factory: Callable[[], Join] = (
    Join(Collection.FIRE_GROUP_TO_FIRE_MODE)
    .list(1)
    .on("fire_group_id")
    .to("fire_group_id")
    .inject_at("fire_group_to_fire_modes")
    .get_factory()
)

fire_mode_join_factory: Callable[[], Join] = (
    Join(Collection.FIRE_MODE_2)
    .on("fire_mode_id")
    .to("fire_mode_id")
    .inject_at("fire_mode")
    .get_factory()
)

# Fire mode to direct damage effect
fire_mode_to_damage_direct_effect_join_factory: Callable[[], Join] = (
    Join(Collection.EFFECT)
    .on("damage_direct_effect_id")
    .to("effect_id")
    .inject_at("damage_direct_effect")
    .nest(
        Join(Collection.EFFECT_TYPE)
        .on("effect_type_id")
Exemplo n.º 24
0
def test_on_to():
    join = Join(Collection.ABILITY).on("on_field").to("to_field")
    assert str(join) == "ability^on:on_field^to:to_field"