Exemplo n.º 1
0
    def test_with_missing_references_we_raise_UnpopulatedReferenceError(
        self, group_membership_body
    ):
        id_refs = IdReferences()

        with pytest.raises(UnpopulatedReferenceError):
            id_refs.fill_out(group_membership_body)
Exemplo n.º 2
0
    def test_we_can_fill_out_a_reference(self, group_membership_body):
        id_refs = IdReferences()
        id_refs.add_concrete_id(DataType.GROUP, "group_ref", "real_id")

        id_refs.fill_out(group_membership_body)

        group_id = group_membership_body["data"]["relationships"]["group"]["data"]["id"]

        assert group_id == "real_id"
Exemplo n.º 3
0
    def __init__(self, executor, observer=None, batch_size=100):
        """
        :param executor: An executor to carry out commands
        :param observer: An observer to view commands
        :param batch_size: Commands to wait for before executing
        """

        self.executor = executor
        self.observer = observer or Observer()

        # Pass _execute_batch() to the CommandBatcher so it can call us back
        # when the batch is ready.
        self.batcher = CommandBatcher(on_flush=self._execute_batch,
                                      batch_size=batch_size)

        # A container for any custom references to objects
        self.id_refs = IdReferences()
        self.reports = defaultdict(list)
        self.config = None
        self.command_count = 0
Exemplo n.º 4
0
    def test_we_can_add_a_concrete_id(self):
        id_refs = IdReferences()

        id_refs.add_concrete_id(DataType.GROUP.value, "my_ref", "real_id")

        assert id_refs._ref_to_concrete[DataType.GROUP]["my_ref"] == "real_id"