-- -- --- --- --- --- --- --- ------- ------- ------- |
from unittest.mock import patch
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- |
import pytest
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- |
from wily.archivers import Archiver, BaseArchiver, Revision
-- -- --- --- --- --- --- --- ------- ------- ------- |
from wily.commands import build
-- -- --- --- --- --- --- --- ------- ------- ------- |
from wily.config import DEFAULT_CONFIG
-- -- --- --- --- --- --- --- ------- ------- ------- |
from wily.operators import BaseOperator, Operator, OperatorLevel
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- |
02 -- --- --- --- --- --- --- ------- ------- ------- |
class MockArchiverCls(BaseArchiver):
02 -- --- --- --- --- --- --- ------- ------- ------- |
name = "test"
02 -- --- --- --- --- --- --- ------- ------- ------- |
02 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
def __init__(self, *args, **kwargs):
02 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
pass
02 -- --- --- --- --- --- --- ------- ------- ------- |
02 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
def revisions(self, path, max_revisions):
02 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
return [
02 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
Revision(
02 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
key="12345",
02 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
author_name="Local User", # Don't want to leak local data
02 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
author_email="-", # as above
02 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
date=12_345_679,
02 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
message="None",
02 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
tracked_files=[],
02 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
tracked_dirs=[],
02 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
added_files=[],
02 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
modified_files=[],
02 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
deleted_files=[],
02 -- 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
)
02 -- 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
]
02 -- --- --- --- --- --- --- ------- ------- ------- |
02 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
def checkout(self, revision, options):
02 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
pass # noop
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- |
02 -- --- --- --- --- --- --- ------- ------- ------- |
class MockOperatorCls(BaseOperator):
02 -- --- --- --- --- --- --- ------- ------- ------- |
name = "test"
02 -- --- --- --- --- --- --- ------- ------- ------- |
data = {}
02 -- --- --- --- --- --- --- ------- ------- ------- |
02 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
def __init__(self, *args, **kwargs):
02 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
pass
02 -- --- --- --- --- --- --- ------- ------- ------- |
02 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
def run(self, module, options):
02 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
return self.data
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- |
MockOperator = Operator("mock", MockOperatorCls, "for testing", OperatorLevel.File)
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- |
MockArchiver = Archiver("mock", MockArchiverCls, "for testing")
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- |
@pytest.fixture
-- 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
def config():
-- 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
cfg = DEFAULT_CONFIG
-- 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
return cfg
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- 01 001 002 001 002 003 003 0004.75 0002.38 0000.50 |
def test_build_simple(config):
-- -- 001 002 001 002 003 003 0004.75 0002.38 0000.50 |
_test_operators = (MockOperator,)
-- -- --- --- --- --- --- --- ------- ------- ------- |
with patch("wily.state.resolve_archiver", return_value=MockArchiver):
-- -- --- --- --- --- --- --- ------- ------- ------- |
result = build.build(config, MockArchiver, _test_operators)
-- -- --- --- --- --- --- --- ------- ------- ------- |
assert result is None