<commit_before>#!/usr/bin/env python3

import os, pytest, tempfile, datetime

from cozify import conftest, config, hub, cloud

from . import fixtures_devices as dev

@pytest.fixture
def default_hub(scope='module'):
    barehub = lambda:0
    config.setStatePath() # reset to default config
    config.dump_state()
    barehub.hub_id = hub.getDefaultHub()
    barehub.name = hub.name(barehub.hub_id)
    barehub.host = hub.host(barehub.hub_id)
    barehub.token = hub.token(barehub.hub_id)
    barehub.remote = hub.remote
    return barehub

@pytest.fixture
def tmp_cloud(scope='module'):
    with Tmp_cloud() as cloud:
        yield cloud

@pytest.fixture
def live_cloud(scope='module'):
    config.setStatePath() # reset to default
    return cloud

@pytest.fixture
def id(scope='module'):
    return 'deadbeef-aaaa-bbbb-cccc-dddddddddddd'

@pytest.fixture
def tmphub(scope='module'):
    with tmp_hub() as hub:
        yield hub

@pytest.fixture
def id(scope='module'):
    return 'deadbeef-aaaa-bbbb-cccc-dddddddddddd'

@pytest.fixture
def livehub(scope='module'):
    config.setStatePath() # default config assumed to be live
    config.dump_state() # dump state so it's visible in failed test output
    assert hub.ping()
    return hub

class Tmp_cloud():
    """Creates a temporary cloud state with test data.
    """
    def __init__(self):
        self.configfile, self.configpath = tempfile.mkstemp()
        self.section = 'Cloud'<commit_msg>Fixture to access individual test devices directly<commit_after>#!/usr/bin/env python3

import os, pytest, tempfile, datetime

from cozify import conftest, config, hub, cloud

from . import fixtures_devices as dev

@pytest.fixture
def default_hub(scope='module'):
    barehub = lambda:0
    config.setStatePath() # reset to default config
    config.dump_state()
    barehub.hub_id = hub.getDefaultHub()
    barehub.name = hub.name(barehub.hub_id)
    barehub.host = hub.host(barehub.hub_id)
    barehub.token = hub.token(barehub.hub_id)
    barehub.remote = hub.remote
    return barehub

@pytest.fixture
def tmp_cloud(scope='module'):
    with Tmp_cloud() as cloud:
        yield cloud

@pytest.fixture
def live_cloud(scope='module'):
    config.setStatePath() # reset to default
    return cloud

@pytest.fixture
def id(scope='module'):
    return 'deadbeef-aaaa-bbbb-cccc-dddddddddddd'

@pytest.fixture
def tmphub(scope='module'):
    with tmp_hub() as hub:
        yield hub

@pytest.fixture
def id(scope='module'):
    return 'deadbeef-aaaa-bbbb-cccc-dddddddddddd'

@pytest.fixture
def devices(scope='module'):
    return dev

@pytest.fixture
def livehub(scope='module'):
    config.setStatePath() # default config assumed to be live
    config.dump_state() # dump state so it's visible in failed test output
    assert hub.ping()
    return hub

class Tmp_cloud():
    """Creates a temporary cloud state with test data.
    """
    def __init__(self):
        self.configfile, self.configpath = tempfile.mkstemp()
        self.section = 'Cloud'
{'fraction_non_alphanumeric': 0.1118508655126498, 'fraction_numerical': 0.0013315579227696406, 'mean_word_length': 3.7547468354430378, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 4, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '735232', 'n_tokens_mistral': 998, 'n_tokens_neox': 1010, 'n_words': 250}