# Path: onix/scrapers.py
# def get_commit_from_timestamp(timestamp):
# def _write(data, destination_filename):
# def _scrape(url, entry, commit=None, destination_filename=None):
# def scrape_battle_formats_data(commit=None):
# def scrape_battle_pokedex(commit=None):
# def scrape_battle_aliases(commit=None):
# def scrape_battle_items(commit=None):
# def scrape_battle_movedex(commit=None):
# def scrape_formats(commit=None):
# 
# Path: onix/contexts.py
# class Context(object):
# class ResourceMissingError(Exception):
#     def __init__(self, **resources):
#     def __init__(self, resource):
# def require(context, *resources):
# def _get_context(commit, force_refresh):
# def get_standard_context(force_refresh=False):
# def get_historical_context(timestamp):


import datetime
import json
import shutil
import os
import pytest
from onix import scrapers
from onix import contexts as cxs
    def test_require_for_missing_standard_resource(self):
        with pytest.raises(cxs.ResourceMissingError):
            cxs.require(self.cx, 'formats')

    def test_require_for_missing_nonstandard_resource(self):
        with pytest.raises(cxs.ResourceMissingError):
            cxs.require(self.cx, 'gawhag')

    def test_require_for_nonstandard_resource_set_to_none(self):
        # still counts as missing
        with pytest.raises(cxs.ResourceMissingError):
            cxs.require(self.cx, 'duketastrophe')


@pytest.mark.online
class TestGetStandardContext(object):

    def test_get_local_standard_context(self):

        try:
            cxs.get_standard_context()  # scrape once if not already scraped

            mock_pokedex = {'wooper': dict(entry='Water Fish')}
            json.dump(mock_pokedex, open('.psdata/pokedex.json', 'w+'))

            cx = cxs.get_standard_context()

            assert mock_pokedex == cx.pokedex

        finally:

# Path: onix/scrapers.py
# def get_commit_from_timestamp(timestamp):
# def _write(data, destination_filename):
# def _scrape(url, entry, commit=None, destination_filename=None):
# def scrape_battle_formats_data(commit=None):
# def scrape_battle_pokedex(commit=None):
# def scrape_battle_aliases(commit=None):
# def scrape_battle_items(commit=None):
# def scrape_battle_movedex(commit=None):
# def scrape_formats(commit=None):
# 
# Path: onix/contexts.py
# class Context(object):
# class ResourceMissingError(Exception):
#     def __init__(self, **resources):
#     def __init__(self, resource):
# def require(context, *resources):
# def _get_context(commit, force_refresh):
# def get_standard_context(force_refresh=False):
# def get_historical_context(timestamp):


# Path: tests/test_contexts.py
import datetime
import json
import shutil
import os
import pytest
from onix import scrapers
from onix import contexts as cxs

    def test_require_for_missing_standard_resource(self):
        with pytest.raises(cxs.ResourceMissingError):
            cxs.require(self.cx, 'formats')

    def test_require_for_missing_nonstandard_resource(self):
        with pytest.raises(cxs.ResourceMissingError):
            cxs.require(self.cx, 'gawhag')

    def test_require_for_nonstandard_resource_set_to_none(self):
        # still counts as missing
        with pytest.raises(cxs.ResourceMissingError):
            cxs.require(self.cx, 'duketastrophe')


@pytest.mark.online
class TestGetStandardContext(object):

    def test_get_local_standard_context(self):

        try:
            cxs.get_standard_context()  # scrape once if not already scraped

            mock_pokedex = {'wooper': dict(entry='Water Fish')}
            json.dump(mock_pokedex, open('.psdata/pokedex.json', 'w+'))

            cx = cxs.get_standard_context()

            assert mock_pokedex == cx.pokedex

        finally:

            scrapers.scrape_battle_pokedex()