2019-04-18 15:01:25 +03:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
|
|
|
import os
|
|
|
|
import shutil
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
2019-05-09 12:12:30 +03:00
|
|
|
from bugbug import bugzilla, repository
|
2019-04-18 15:01:25 +03:00
|
|
|
|
|
|
|
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), "fixtures")
|
|
|
|
|
|
|
|
|
2019-06-03 16:52:17 +03:00
|
|
|
@pytest.fixture
|
2019-04-18 15:01:25 +03:00
|
|
|
def mock_data(tmp_path_factory):
|
|
|
|
tmp_path = tmp_path_factory.mktemp("")
|
|
|
|
os.mkdir(tmp_path / "data")
|
|
|
|
|
|
|
|
DBs = [os.path.basename(bugzilla.BUGS_DB), os.path.basename(repository.COMMITS_DB)]
|
|
|
|
|
|
|
|
for f in DBs:
|
|
|
|
shutil.copyfile(os.path.join(FIXTURES_DIR, f), tmp_path / "data" / f)
|
|
|
|
|
|
|
|
os.chdir(tmp_path)
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def get_fixture_path():
|
|
|
|
def _get_fixture_path(path):
|
|
|
|
path = os.path.join(FIXTURES_DIR, path)
|
|
|
|
assert os.path.exists(path)
|
|
|
|
return path
|
|
|
|
|
|
|
|
return _get_fixture_path
|