"""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()

[((532, 542), 'custom_components.hacs.hacsbase.data.HacsData', 'HacsData', ([], {}), '()\n', (540, 542), False, 'from custom_components.hacs.hacsbase.data import HacsData\n'), ((554, 564), 'custom_components.hacs.share.get_hacs', 'get_hacs', ([], {}), '()\n', (562, 564), False, 'from custom_components.hacs.share import get_hacs\n'), ((582, 605), 'tests.dummy_repository.dummy_repository_base', 'dummy_repository_base', ([], {}), '()\n', (603, 605), False, 'from tests.dummy_repository import dummy_repository_base\n'), ((740, 755), 'homeassistant.core.HomeAssistant', 'HomeAssistant', ([], {}), '()\n', (753, 755), False, 'from homeassistant.core import HomeAssistant\n'), ((822, 837), 'custom_components.hacs.hacsbase.configuration.Configuration', 'Configuration', ([], {}), '()\n', (835, 837), False, 'from custom_components.hacs.hacsbase.configuration import Configuration\n'), ((948, 958), 'custom_components.hacs.hacsbase.data.HacsData', 'HacsData', ([], {}), '()\n', (956, 958), False, 'from custom_components.hacs.hacsbase.data import HacsData\n'), ((970, 980), 'custom_components.hacs.share.get_hacs', 'get_hacs', ([], {}), '()\n', (978, 980), False, 'from custom_components.hacs.share import get_hacs\n'), ((997, 1012), 'homeassistant.core.HomeAssistant', 'HomeAssistant', ([], {}), '()\n', (1010, 1012), False, 'from homeassistant.core import HomeAssistant\n'), ((1079, 1094), 'custom_components.hacs.hacsbase.configuration.Configuration', 'Configuration', ([], {}), '()\n', (1092, 1094), False, 'from custom_components.hacs.hacsbase.configuration import Configuration\n'), ((1280, 1290), 'custom_components.hacs.hacsbase.data.HacsData', 'HacsData', ([], {}), '()\n', (1288, 1290), False, 'from custom_components.hacs.hacsbase.data import HacsData\n'), ((1302, 1312), 'custom_components.hacs.share.get_hacs', 'get_hacs', ([], {}), '()\n', (1310, 1312), False, 'from custom_components.hacs.share import get_hacs\n'), ((1329, 1344), 'homeassistant.core.HomeAssistant', 'HomeAssistant', ([], {}), '()\n', (1342, 1344), False, 'from homeassistant.core import HomeAssistant\n')]