Exemple #1
0
def classifier_repository():
    classifier_repository = MemoryClassifierRepository(ExpressionParser())
    classifier_repository.load({
        "xs":
        Classifier(**{
            "id": "xs",
            "name": "Extra Small",
            "amount": 1
        }),
        "s":
        Classifier(**{
            "id": "s",
            "name": "Small",
            "amount": 2
        }),
        "m":
        Classifier(**{
            "id": "m",
            "name": "Medium",
            "amount": 3
        }),
        "l":
        Classifier(**{
            "id": "l",
            "name": "Large",
            "amount": 5
        }),
        "xl":
        Classifier(**{
            "id": "xl",
            "name": "Extra Large",
            "amount": 8
        })
    })
    return classifier_repository
Exemple #2
0
def classification_repository():
    classification_repository = MemoryClassificationRepository(
        ExpressionParser())
    classification_repository.load({
        "1":
        Classification(id="1", task_id="1.1", classifier_id="m"),
        "2":
        Classification(id="2", task_id="1.2", classifier_id="l"),
        "3":
        Classification(id="3", task_id="1.3", classifier_id="s"),
        "4":
        Classification(id="4", task_id="1.4", classifier_id="xs"),
        "5":
        Classification(id="5", task_id="2.1", classifier_id="m"),
        "6":
        Classification(id="6", task_id="3.1", classifier_id="l"),
        "7":
        Classification(id="7", task_id="3.2", classifier_id="s"),
        "8":
        Classification(id="8", task_id="4.1", classifier_id="m"),
        "9":
        Classification(id="9", task_id="5.1", classifier_id="l"),
        "10":
        Classification(id="10", task_id="6.1", classifier_id="l"),
        "11":
        Classification(id="11", task_id="6.2", classifier_id="xs"),
        "12":
        Classification(id="12", task_id="6.3", classifier_id="m"),
        "13":
        Classification(id="13", task_id="6.4", classifier_id="l"),
        "14":
        Classification(id="14", task_id="7.1", classifier_id="xl"),
    })
    return classification_repository
def memory_repository() -> MemoryRepository:
    parser = ExpressionParser()
    entity_dict = {
        "1": DummyEntity('1', 'value_1'),
        "2": DummyEntity('2', 'value_2'),
        "3": DummyEntity('3', 'value_3'),
    }
    repository = MemoryRepository[DummyEntity](parser)
    repository.load(entity_dict)
    return repository
def test_rst_factory_rst_task_repository(rst_factory):
    parser = ExpressionParser()
    analyzer = RstAnalyzer()

    class MockLoader:
        @property
        def nodes(self):
            return {}

    repository = rst_factory.rst_task_repository(parser, MockLoader())
    assert isinstance(repository, RstTaskRepository)
def test_memory_repository_add() -> None:
    parser = ExpressionParser()
    memory_repository = MemoryRepository[DummyEntity](parser)

    item = DummyEntity("1", "value_1")

    is_saved = memory_repository.add(item)

    assert len(memory_repository.items) == 1
    assert is_saved
    assert "1" in memory_repository.items.keys()
    assert item in memory_repository.items.values()
Exemple #6
0
def task_repository():
    task_repository = MemoryTaskRepository(ExpressionParser())
    task_repository.load({
        '0':
        Task(id='', name='Bicycle Project', summary=True, parent_id=''),
        '1':
        Task(id='1', name='Frame Set', summary=True, parent_id='0'),
        '1.1':
        Task(id='1.1', name='Make Frame', parent_id='1'),
        '1.2':
        Task(id='1.2', name='Forge Handlebar', parent_id='1'),
        '1.3':
        Task(id='1.3', name='Build Fork', parent_id='1'),
        '1.4':
        Task(id='1.4', name='Make Seat', parent_id='1'),
        '2':
        Task(id='2', name='Crank Set', summary=True, parent_id='0'),
        '2.1':
        Task(id='2.1', name='Make Crank Set', parent_id='2'),
        '3':
        Task(id='3', name='Wheels', summary=True, parent_id='0'),
        '3.1':
        Task(id='3.1', name='Make Front Wheel', parent_id='3'),
        '3.2':
        Task(id='3.2', name='Make Rear Wheel', parent_id='3'),
        '4':
        Task(id='4', name='Braking Systems', summary=True, parent_id='0'),
        '4.1':
        Task(id='4.1', name='Design Braking Systems', parent_id='4'),
        '5':
        Task(id='5', name='Shifting Systems', summary=True, parent_id='0'),
        '5.1':
        Task(id='5.1', name='Design Shifting Systems', parent_id='5'),
        '6':
        Task(id='6', name='Integration', summary=True, parent_id='0'),
        '6.1':
        Task(id='6.1', name='Define Concept', parent_id='6'),
        '6.2':
        Task(id='6.2', name='Draft Design', parent_id='6'),
        '6.3':
        Task(id='6.3', name='Assembly Parts', parent_id='6'),
        '6.4':
        Task(id='6.4', name='Make Testing', parent_id='6'),
        '7':
        Task(id='7', name='Project Management', summary=True, parent_id='0'),
        '7.1':
        Task(id='7.1', name='Plan Project', parent_id='7')
    })
    return task_repository
def json_repository(tmpdir) -> JsonRepository:
    item_dict = {
        "1": vars(DummyEntity('1', 'value_1')),
        "2": vars(DummyEntity('2', 'value_2')),
        "3": vars(DummyEntity('3', 'value_3'))
    }

    file_path = str(tmpdir.mkdir("authark").join('authark_data.json'))
    collection_name = 'dummies'
    with open(file_path, 'w') as f:
        data = dumps({collection_name: item_dict})
        f.write(data)

    parser = ExpressionParser()
    json_repository = JsonRepository(file_path=file_path,
                                     parser=parser,
                                     collection_name=collection_name,
                                     item_class=DummyEntity)
    return json_repository
def rst_repository(rst_loader) -> RstRepository:
    parser = ExpressionParser()
    repository = RstRepository[DummyEntity](parser, rst_loader, DummyEntity)
    repository.load()
    return repository
def rst_classification_repository(rst_loader) -> RstClassificationRepository:
    parser = ExpressionParser()
    repository = RstClassificationRepository(parser, rst_loader)
    return repository
def rst_task_repository(rst_loader) -> RstTaskRepository:
    parser = ExpressionParser()
    repository = RstTaskRepository(parser, rst_loader)
    return repository
def parser() -> ExpressionParser:
    return ExpressionParser()
Exemple #12
0
def slot_repository():
    slot_repository = MemorySlotRepository(ExpressionParser())
    return slot_repository
Exemple #13
0
def schedule_repository():
    schedule_repository = MemoryScheduleRepository(ExpressionParser())
    return schedule_repository
Exemple #14
0
def merged_link_repository():
    link_repository = MemoryLinkRepository(ExpressionParser())
    link_repository.load({
        '1':
        Link(**{
            'id': '1',
            'source': '',
            'target': '1.1'
        }),
        '2':
        Link(**{
            'id': '2',
            'source': '1.1',
            'target': '1.2'
        }),
        '3':
        Link(**{
            'id': '3',
            'source': '1.2',
            'target': '1.3'
        }),
        '4':
        Link(**{
            'id': '4',
            'source': '1.3',
            'target': '1.4'
        }),
        '5':
        Link(**{
            'id': '5',
            'source': '1.4',
            'target': '2.1'
        }),
        '6':
        Link(**{
            'id': '6',
            'source': '2.1',
            'target': '3.1'
        }),
        '7':
        Link(**{
            'id': '7',
            'source': '3.1',
            'target': '3.2'
        }),
        '8':
        Link(**{
            'id': '8',
            'source': '3.2',
            'target': '4.1'
        }),
        '9':
        Link(**{
            'id': '9',
            'source': '4.1',
            'target': '5.1'
        }),
        '10':
        Link(**{
            'id': '10',
            'source': '3.1',
            'target': '6.1'
        }),
        '11':
        Link(**{
            'id': '10',
            'source': '3.2',
            'target': '6.1'
        }),
        '12':
        Link(**{
            'id': '11',
            'source': '6.1',
            'target': '6.2'
        }),
        '13':
        Link(**{
            'id': '12',
            'source': '6.2',
            'target': '6.3'
        }),
        '14':
        Link(**{
            'id': '13',
            'source': '6.3',
            'target': '6.4'
        }),
        '15':
        Link(**{
            'id': '14',
            'source': '6.4',
            'target': '7.1'
        }),
    })
    return link_repository