def test_get_many( read_database: ReadDatabase, connection: ConnectionHandler, query_helper: SqlQueryHelper, ): fqid1 = "c/1" model1 = MagicMock() fqid2 = "c/2" model2 = MagicMock() connection.query = q = MagicMock(return_value=[{ "fqid": fqid1, "data": model1 }, { "fqid": fqid2, "data": model2 }]) q_fqid1 = MagicMock() q_fqid2 = MagicMock() models = read_database.get_many([q_fqid1, q_fqid2]) assert q.call_args.args[1] == [( q_fqid1, q_fqid2, )] assert models == {fqid1: model1, fqid2: model2}
def test_get_many_no_fqids(read_database: ReadDatabase, connection: ConnectionHandler): connection.query = q = MagicMock() assert read_database.get_many([], {}) == {} assert q.call_count == 0