"""Data Test Suite."""
from aiogithubapi.objects import repository
import pytest
import os
from homeassistant.core import HomeAssistant
from custom_components.hacs.hacsbase.data import HacsData
from custom_components.hacs.helpers.classes.repository import HacsRepository
from custom_components.hacs.hacsbase.configuration import Configuration
from custom_components.hacs.share import get_hacs

from tests.dummy_repository import dummy_repository_base


@pytest.mark.asyncio
async def test_hacs_data_async_write1(tmpdir):
    data = HacsData()
    hacs = get_hacs()
    repository = dummy_repository_base()
    repository.data.installed = True
    repository.data.installed_version = "1"
    hacs.repositories = [repository]
    hacs.hass = HomeAssistant()
    hacs.hass.config.config_dir = tmpdir
    hacs.configuration = Configuration()
    await data.async_write()


@pytest.mark.asyncio
async def test_hacs_data_async_write2(tmpdir):
    data = HacsData()
    hacs = get_hacs()
    hacs.hass = HomeAssistant()
    hacs.hass.config.config_dir = tmpdir
    hacs.configuration = Configuration()
    hacs.system.status.background_task = False
    hacs.system.disabled = False
    await data.async_write()


@pytest.mark.asyncio
async def test_hacs_data_restore(tmpdir):
    data = HacsData()
    hacs = get_hacs()
    hacs.hass = HomeAssistant()
    hacs.hass.config.config_dir = tmpdir
    await data.restore()

[((16, 11, 16, 21), 'custom_components.hacs.hacsbase.data.HacsData', 'HacsData', ({}, {}), '()', False, 'from custom_components.hacs.hacsbase.data import HacsData\n'), ((17, 11, 17, 21), 'custom_components.hacs.share.get_hacs', 'get_hacs', ({}, {}), '()', False, 'from custom_components.hacs.share import get_hacs\n'), ((18, 17, 18, 40), 'tests.dummy_repository.dummy_repository_base', 'dummy_repository_base', ({}, {}), '()', False, 'from tests.dummy_repository import dummy_repository_base\n'), ((22, 16, 22, 31), 'homeassistant.core.HomeAssistant', 'HomeAssistant', ({}, {}), '()', False, 'from homeassistant.core import HomeAssistant\n'), ((24, 25, 24, 40), 'custom_components.hacs.hacsbase.configuration.Configuration', 'Configuration', ({}, {}), '()', False, 'from custom_components.hacs.hacsbase.configuration import Configuration\n'), ((30, 11, 30, 21), 'custom_components.hacs.hacsbase.data.HacsData', 'HacsData', ({}, {}), '()', False, 'from custom_components.hacs.hacsbase.data import HacsData\n'), ((31, 11, 31, 21), 'custom_components.hacs.share.get_hacs', 'get_hacs', ({}, {}), '()', False, 'from custom_components.hacs.share import get_hacs\n'), ((32, 16, 32, 31), 'homeassistant.core.HomeAssistant', 'HomeAssistant', ({}, {}), '()', False, 'from homeassistant.core import HomeAssistant\n'), ((34, 25, 34, 40), 'custom_components.hacs.hacsbase.configuration.Configuration', 'Configuration', ({}, {}), '()', False, 'from custom_components.hacs.hacsbase.configuration import Configuration\n'), ((42, 11, 42, 21), 'custom_components.hacs.hacsbase.data.HacsData', 'HacsData', ({}, {}), '()', False, 'from custom_components.hacs.hacsbase.data import HacsData\n'), ((43, 11, 43, 21), 'custom_components.hacs.share.get_hacs', 'get_hacs', ({}, {}), '()', False, 'from custom_components.hacs.share import get_hacs\n'), ((44, 16, 44, 31), 'homeassistant.core.HomeAssistant', 'HomeAssistant', ({}, {}), '()', False, 'from homeassistant.core import HomeAssistant\n')]