query
stringlengths 9
9.05k
| document
stringlengths 10
222k
| negatives
sequencelengths 19
20
| metadata
dict |
---|---|---|---|
Representation of a circuit as "Rotation list". On top of the structure (see Structured script representation), 1Q layers are compiled to the corresponding rotations. The 1Q layers are now represented with a rotation vector. rotations_1Q = [layer, qubit, rotation_vector] rotation_vector = [axis_of_rotation (3 numbers), angle_of_rotation] | def __init__(self, rotations_1Q, lines_2Q, n_qubits):
self.rotations_1Q = rotations_1Q
self.lines_2Q = lines_2Q
self.n_qubits = n_qubits
dim_depth, dim_qubits, dim_rot = self.rotations_1Q.shape
self.depth = 1+2*len(lines_2Q)
# 1Q rotations vector does not match the depth
if not((2*dim_depth-1) == self.depth):
raise ValueError('1Q rotations vector does not match the depth')
# 1Q rotations vector does not match the qubit number
if not(dim_qubits == n_qubits):
raise ValueError(
'1Q rotations vector does not match the qubit number')
# 1Q rotations vector does not match the parameter number
if not(dim_rot == 4):
raise ValueError(
'1Q rotations vector does not match the parameter number') | [
"def two_qubit_rotation(self, bits, symbols):\n circuit = cirq.Circuit()\n circuit += cirq.Circuit(self.one_qubit_rotation(bits[0], symbols[0:3]))\n circuit += cirq.Circuit(self.one_qubit_rotation(bits[1], symbols[3:6]))\n circuit += [cirq.ZZ(*bits)**symbols[6]]\n circuit += [cirq.YY(*bits)**symbols[7]]\n circuit += [cirq.XX(*bits)**symbols[8]]\n circuit += cirq.Circuit(self.one_qubit_rotation(bits[0], symbols[9:12]))\n circuit += cirq.Circuit(self.one_qubit_rotation(bits[1], symbols[12:]))\n return circuit",
"def _tk1_to_rotations(a: float, b: float, c: float) -> Circuit:\n circ = Circuit(1)\n circ.Rz(c, 0).Rx(b, 0).Rz(a, 0)\n return circ",
"def __repr__(self):\n return _almathswig.Rotation___repr__(self)",
"def __repr__(self):\n return _almathswig.Rotation3D___repr__(self)",
"def test_rot_decomposition(self, diff_method):\r\n dev = qml.device(\"default.qubit\", wires=1)\r\n\r\n def circuit(weights):\r\n qml.Rot(weights[0], weights[1], weights[2], wires=0)\r\n return qml.expval(qml.PauliX(0))\r\n\r\n circuit = qml.QNode(circuit, dev, diff_method=diff_method)\r\n params = np.array([1.0, 2.0, 3.0])\r\n tapes = qml.metric_tensor(circuit, only_construct=True)(params)\r\n assert len(tapes) == 3\r\n\r\n # first parameter subcircuit\r\n assert len(tapes[0].operations) == 0\r\n\r\n # Second parameter subcircuit\r\n assert len(tapes[1].operations) == 4\r\n assert isinstance(tapes[1].operations[0], qml.RZ)\r\n assert tapes[1].operations[0].data == [1]\r\n # PauliY decomp\r\n assert isinstance(tapes[1].operations[1], qml.PauliZ)\r\n assert isinstance(tapes[1].operations[2], qml.S)\r\n assert isinstance(tapes[1].operations[3], qml.Hadamard)\r\n\r\n # Third parameter subcircuit\r\n assert len(tapes[2].operations) == 2\r\n assert isinstance(tapes[2].operations[0], qml.RZ)\r\n assert isinstance(tapes[2].operations[1], qml.RY)\r\n assert tapes[2].operations[0].data == [1]\r\n assert tapes[2].operations[1].data == [2]\r\n\r\n result = qml.metric_tensor(circuit)(params)\r\n assert result.shape == (3, 3)",
"def c(inputs, **kwargs):\n qml.templates.AngleEmbedding(inputs, wires=list(range(n_qubits)))\n qml.templates.StronglyEntanglingLayers(kwargs[\"w1\"], wires=list(range(n_qubits)))\n qml.RX(kwargs[\"w2\"][0], wires=0 % n_qubits)\n qml.RX(kwargs[\"w3\"], wires=1 % n_qubits)\n qml.Rot(*kwargs[\"w4\"], wires=2 % n_qubits)\n qml.templates.StronglyEntanglingLayers(kwargs[\"w5\"], wires=list(range(n_qubits)))\n qml.Rot(*kwargs[\"w6\"], wires=3 % n_qubits)\n qml.RX(kwargs[\"w7\"], wires=4 % n_qubits)\n return [qml.expval(qml.PauliZ(i)) for i in range(output_dim)]",
"def __str__(self):\n return _almathswig.Rotation___str__(self)",
"def add_rotation_layer(self, rotation_blocks:Optional[Union[str, cirq.Gate, Callable,\n List[str],List[cirq.Gate],List[Callable],\n List['TemplateCircuitBlock']]] =None):\n rotation_blocks = self._parse_rotation_blocks(rotation_blocks)\n for i, block in enumerate(rotation_blocks):\n if self._reuse_param_per_layer:\n self.reset_index()\n if isinstance(block, TemplateCircuitBlock):\n interaction_graphs = self.get_interaction_graphs(i, block.num_block_qubits)\n for qubits in interaction_graphs:\n if self._reuse_param_per_template:\n self.reset_index()\n block.build(self, qubits)\n else:\n for qubit in range(self.n_qubit):\n gate = self.parameterise_gate(block)\n self.apply_gate_operation(gate, qubit)",
"def getRotationTrajectory(self) -> SO3Trajectory:\n return SO3Trajectory(self.times,[m[:9] for m in self.milestones])",
"def rotationData(self):\n return [self.detections.rotationTimeTags, self.detections.rotations], self.b1, self.b2",
"def rotation(self):\n\t\treturn self.piv.a.rotate.v",
"def to_revolute_chain(self):\n T_zero = {\"p0\": SE3.identity()}\n ang_lims_map = {}\n old_to_new_names = {\n \"p0\": \"p0\"\n } # Returned for user of the method (to map old joint names to new ones)\n ub, lb = spherical_angle_bounds_to_revolute(self.ub, self.lb)\n count = 1\n joint_prev = \"p0\"\n for (\n joint\n ) in self.d: # Assumes the dictionary is in chain order (perhaps enforce?)\n new_node1 = \"p\" + str(count)\n count += 1\n # ub[new_node1] = self.ub[joint]\n # lb[new_node1] = self.lb[joint]\n ang_lims_map[joint] = new_node1\n\n new_node2 = \"p\" + str(count)\n count += 1\n old_to_new_names[joint] = new_node2\n\n Ry = SE3(SO3(roty(np.pi / 2)), np.zeros(3))\n T_zero[new_node1] = T_zero[joint_prev].dot(Ry)\n d = self.d[joint]\n Ry_back = SE3(SO3(roty(-np.pi / 2)), np.zeros(3))\n T_zero[new_node2] = T_zero[new_node1].dot(Ry_back).dot(trans_axis(d, \"z\"))\n\n joint_prev = new_node2\n\n # for key in T_zero:\n # if key not in ub.keys() and key is not 'p0':\n # ub[key] = np.pi\n # lb[key] = -np.pi\n\n params = {\"T_zero\": T_zero, \"ub\": ub, \"lb\": lb}\n return RobotRevolute(params), old_to_new_names, ang_lims_map",
"def init_rotation(self):\n self.l_rotation = [0] * len(self.l_img_name)",
"def rotorconversion(x):\n return cf.MultiVector(layout, val_rotorconversion(x))",
"def rotate(self, theta, legs):\n U, onew = rotationTensor(theta, self.symmetries, legs)\n B = U @ self\n new = list(onew)\n old = list(legs)\n if B.internallegs != self.internallegs:\n old.append(self.internallegs[0])\n new.append(B.internallegs[0])\n B.swaplegs({n: o for o, n in zip(old, new)})\n return B.couplingAddapt(self.coupling)",
"def visualize_matrix_rotation():\n if NUMPY_IS_LOADED:\n obj = object3d()\n m33 = matrix33()\n \n def render_multi_matrices(lom): \n outvecs = []\n for m in lom: \n tmp = m33_to_vectors( m )\n outvecs.extend( tmp )\n return outvecs\n \n axis = vec3(3,3,0)\n \n m1 = m33.from_vec3( axis , 45 )\n \n rendervecs = render_multi_matrices( [m1,m33] )\n\n # viz the axis\n rendervecs.append(axis)\n obj.vectorlist_to_obj( rendervecs )\n obj.save(PYCORE_OBJ_OUT) \n else:\n print(\"ERROR NUMPY IS DISABLED \")",
"def __repr__(self):\n # first check for identity quaternion to avoid nans\n if self.real != 1:\n theta = numpy.arccos(self.real)\n angle = 360 * theta / numpy.pi\n xyz = self.pure / numpy.sin(theta)\n else:\n angle = 0.\n xyz = self.pure\n result = \"Transformation: tx ty tz rx ry rz angle\\n %g %g %g %g %g %g %g\" \\\n % (self.trans[0], self.trans[1], self.trans[2],\n xyz[0], xyz[1], xyz[2], angle)\n return result",
"def rotation(self, params):\n pass",
"def c(inputs, w1, w2, w4, w5, w6, w7, w3=0.5): # pylint: disable=too-many-arguments\n qml.templates.AngleEmbedding(inputs, wires=list(range(n_qubits)))\n qml.templates.StronglyEntanglingLayers(w1, wires=list(range(n_qubits)))\n qml.RX(w2[0], wires=0 % n_qubits)\n qml.RX(w3, wires=1 % n_qubits)\n qml.Rot(*w4, wires=2 % n_qubits)\n qml.templates.StronglyEntanglingLayers(w5, wires=list(range(n_qubits)))\n qml.Rot(*w6, wires=3 % n_qubits)\n qml.RX(w7, wires=4 % n_qubits)\n return [qml.expval(qml.PauliZ(i)) for i in range(output_dim)]"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Representation of a circuit as "XY list". On top of the Euler list (see Euler list representation), The euler angles are compiled into a single MW gate (rotation around axis in the azimutal plane) through virtual phase updates. The 1Q layers are now represented with an XY vector. rotations_1Q = [layer, qubit, XY_vector] XY_vector = [axis(azimutal angle), rotation_angle] | def __init__(self, XY_rotations, lines_2Q, n_qubits):
self.XY_rotations = XY_rotations
self.lines_2Q = lines_2Q
self.n_qubits = n_qubits
dim_depth, dim_qubits, dim_XY = self.XY_rotations.shape
self.depth = 1+2*len(lines_2Q)
# XY rotations vector does not match the depth
if not((2*dim_depth-1) == self.depth):
raise ValueError('XY rotations vector does not match the depth')
# XY rotations vector does not match the qubit number
if not(dim_qubits == n_qubits):
raise ValueError(
'XY rotations vector does not match the qubit number')
# XY rotations vector does not match the parameter number
if not(dim_XY == 2):
raise ValueError(
'XY rotations vector does not match the parameter number') | [
"def c(inputs, **kwargs):\n qml.templates.AngleEmbedding(inputs, wires=list(range(n_qubits)))\n qml.templates.StronglyEntanglingLayers(kwargs[\"w1\"], wires=list(range(n_qubits)))\n qml.RX(kwargs[\"w2\"][0], wires=0 % n_qubits)\n qml.RX(kwargs[\"w3\"], wires=1 % n_qubits)\n qml.Rot(*kwargs[\"w4\"], wires=2 % n_qubits)\n qml.templates.StronglyEntanglingLayers(kwargs[\"w5\"], wires=list(range(n_qubits)))\n qml.Rot(*kwargs[\"w6\"], wires=3 % n_qubits)\n qml.RX(kwargs[\"w7\"], wires=4 % n_qubits)\n return [qml.expval(qml.PauliZ(i)) for i in range(output_dim)]",
"def two_qubit_rotation(self, bits, symbols):\n circuit = cirq.Circuit()\n circuit += cirq.Circuit(self.one_qubit_rotation(bits[0], symbols[0:3]))\n circuit += cirq.Circuit(self.one_qubit_rotation(bits[1], symbols[3:6]))\n circuit += [cirq.ZZ(*bits)**symbols[6]]\n circuit += [cirq.YY(*bits)**symbols[7]]\n circuit += [cirq.XX(*bits)**symbols[8]]\n circuit += cirq.Circuit(self.one_qubit_rotation(bits[0], symbols[9:12]))\n circuit += cirq.Circuit(self.one_qubit_rotation(bits[1], symbols[12:]))\n return circuit",
"def __repr__(self):\n return _almathswig.Rotation3D___repr__(self)",
"def __repr__(self):\n return _almathswig.Rotation___repr__(self)",
"def __init__(self, rotations_1Q, lines_2Q, n_qubits):\n self.rotations_1Q = rotations_1Q\n self.lines_2Q = lines_2Q\n self.n_qubits = n_qubits\n dim_depth, dim_qubits, dim_rot = self.rotations_1Q.shape\n self.depth = 1+2*len(lines_2Q)\n # 1Q rotations vector does not match the depth\n if not((2*dim_depth-1) == self.depth):\n raise ValueError('1Q rotations vector does not match the depth')\n # 1Q rotations vector does not match the qubit number\n if not(dim_qubits == n_qubits):\n raise ValueError(\n '1Q rotations vector does not match the qubit number')\n # 1Q rotations vector does not match the parameter number\n if not(dim_rot == 4):\n raise ValueError(\n '1Q rotations vector does not match the parameter number')",
"def test_rot_decomposition(self, diff_method):\r\n dev = qml.device(\"default.qubit\", wires=1)\r\n\r\n def circuit(weights):\r\n qml.Rot(weights[0], weights[1], weights[2], wires=0)\r\n return qml.expval(qml.PauliX(0))\r\n\r\n circuit = qml.QNode(circuit, dev, diff_method=diff_method)\r\n params = np.array([1.0, 2.0, 3.0])\r\n tapes = qml.metric_tensor(circuit, only_construct=True)(params)\r\n assert len(tapes) == 3\r\n\r\n # first parameter subcircuit\r\n assert len(tapes[0].operations) == 0\r\n\r\n # Second parameter subcircuit\r\n assert len(tapes[1].operations) == 4\r\n assert isinstance(tapes[1].operations[0], qml.RZ)\r\n assert tapes[1].operations[0].data == [1]\r\n # PauliY decomp\r\n assert isinstance(tapes[1].operations[1], qml.PauliZ)\r\n assert isinstance(tapes[1].operations[2], qml.S)\r\n assert isinstance(tapes[1].operations[3], qml.Hadamard)\r\n\r\n # Third parameter subcircuit\r\n assert len(tapes[2].operations) == 2\r\n assert isinstance(tapes[2].operations[0], qml.RZ)\r\n assert isinstance(tapes[2].operations[1], qml.RY)\r\n assert tapes[2].operations[0].data == [1]\r\n assert tapes[2].operations[1].data == [2]\r\n\r\n result = qml.metric_tensor(circuit)(params)\r\n assert result.shape == (3, 3)",
"def c(inputs, w1, w2, w4, w5, w6, w7, w3=0.5): # pylint: disable=too-many-arguments\n qml.templates.AngleEmbedding(inputs, wires=list(range(n_qubits)))\n qml.templates.StronglyEntanglingLayers(w1, wires=list(range(n_qubits)))\n qml.RX(w2[0], wires=0 % n_qubits)\n qml.RX(w3, wires=1 % n_qubits)\n qml.Rot(*w4, wires=2 % n_qubits)\n qml.templates.StronglyEntanglingLayers(w5, wires=list(range(n_qubits)))\n qml.Rot(*w6, wires=3 % n_qubits)\n qml.RX(w7, wires=4 % n_qubits)\n return [qml.expval(qml.PauliZ(i)) for i in range(output_dim)]",
"def Q_mat(self, angle):\n\n # U_i values for the block multiplication\n U_1 = (1 / 8) * (3 * self.Qxx + 3 * self.Qyy + 2 * self.Qxy + 4 * self.Qss)\n U_2 = (1 / 2) * (self.Qxx - self.Qyy)\n U_3 = (1 / 8) * (self.Qxx + self.Qyy - 2 * self.Qxy - 4 * self.Qss)\n U_4 = (1 / 8) * (self.Qxx + self.Qyy + 6 * self.Qxy - 4 * self.Qss)\n U_5 = (1 / 8) * (self.Qxx + self.Qyy - 2 * self.Qxy + 4 * self.Qss)\n\n # U vector for the vector multiplication\n U_vec = np.array([1, U_2, U_3])\n\n # Creating the off-axis Q matrix for the ply\n\n # U matrix for the vector multiplication\n theta = np.radians(angle)\n U_mat = np.array([[U_1, np.cos(2 * theta), np.cos(4 * theta)],\n [U_1, -np.cos(2 * theta), np.cos(4 * theta)],\n [U_4, 0, -np.cos(4 * theta)],\n [U_5, 0, -np.cos(4 * theta)],\n [0, 0.5 * np.sin(2 * theta), np.sin(4 * theta)],\n [0, 0.5 * np.sin(2 * theta), -np.sin(4 * theta)]])\n\n Q = U_mat @ U_vec\n return np.array([[Q[0], Q[2], Q[4]],\n [Q[2], Q[1], Q[5]],\n [Q[4], Q[5], Q[3]]])",
"def Rotation_EQJ_ECL():\n # ob = mean obliquity of the J2000 ecliptic = 0.40909260059599012 radians.\n c = 0.9174821430670688 # cos(ob)\n s = 0.3977769691083922 # sin(ob)\n return RotationMatrix([\n [ 1, 0, 0],\n [ 0, +c, -s],\n [ 0, +s, +c]\n ])",
"def toMatrix33(self):\n\n # Kraken Euler rotation order\n # 0:\"xyz\",\n # 1:\"xzy\",\n # 2:\"yxz\",\n # 3:\"yzx\",\n # 4:\"zxy\",\n # 5:\"zyx\",\n\n cx = math.cos(self.x)\n sx = math.sin(self.x)\n cy = math.cos(self.y)\n sy = math.sin(self.y)\n cz = math.cos(self.z)\n sz = math.sin(self.z)\n\n \"\"\"\n rx = Matrix33(Vec3(1.0, 0.0, 0.0),\n Vec3(0.0, cx, -sx),\n Vec3(0.0, sx, cx))\n\n ry = Matrix33(Vec3(cy, 0.0, sy),\n Vec3(0.0, 1.0, 0.0),\n Vec3(-sy, 0.0, cy))\n\n rz = Matrix33(Vec3(cz, -sz, 0.0),\n Vec3(sz, cz, 0.0),\n Vec3(0.0, 0.0, 1.0))\n \"\"\"\n # =========================================\n rx = Matrix33(Vec3(1.0, 0.0, 0.0),\n Vec3(0.0, cx, sx),\n Vec3(0.0, -sx, cx))\n\n ry = Matrix33(Vec3(cy, 0.0, -sy),\n Vec3(0.0, 1.0, 0.0),\n Vec3(sy, 0.0, cy))\n\n rz = Matrix33(Vec3(cz, sz, 0.0),\n Vec3(-sz, cz, 0.0),\n Vec3(0.0, 0.0, 1.0))\n\n if self.ro == 0:\n return rx.multiply(ry.multiply(rz))\n elif self.ro == 1:\n return rx.multiply(rz.multiply(ry))\n elif self.ro == 2:\n return ry.multiply(rx.multiply(rz))\n elif self.ro == 3:\n return ry.multiply(rz.multiply(rx))\n elif self.ro == 4:\n return rz.multiply(rx.multiply(ry))\n elif self.ro == 5:\n return rz.multiply(ry.multiply(rx))\n else:\n raise ValueError(\"Euler: 'ro' attribute value is not within 0-5.\")",
"def calculate_abc(self):\n (a,b,c, V) = crystal_calc.make_lattice_vectors(self.lattice_lengths, self.lattice_angles)\n #Now rotate all these vectors by the U matrix\n self.a = np.dot(self.u_matrix, a).reshape(1,3)\n self.b = np.dot(self.u_matrix, b).reshape(1,3)\n self.c = np.dot(self.u_matrix, c).reshape(1,3)",
"def z_rotation(self):\n before = ('R', 'r', 'U', 'u', 'L', 'l', 'D', 'd', 'M', 'E', 'x', 'y')\n after = ('U', 'u', 'L', 'l', 'D', 'd', 'R', 'r', 'E', 'M\\'', \"y\", \"x'\")\n solve = self.solve_helper.maketrans(dict(zip(before, after)))\n solve_trans = self.solve_helper.translate(solve)\n solve_trans = solve_trans.replace(\"\\'\\'\", \"\")\n self.solve_helper = solve_trans",
"def rotorconversion(x):\n return cf.MultiVector(layout, val_rotorconversion(x))",
"def dogeo_V(input):\n input=input.transpose() \n dec, inc, az, pl =input[0],input[1],input[2],input[3] # unpack input array into separate arrays\n Dir=numpy.array([dec,inc]).transpose()\n X=dir2cart(Dir).transpose() # get cartesian coordinates\n N=numpy.size(dec)\n A1=dir2cart(numpy.array([az,pl,numpy.ones(N)]).transpose()).transpose()\n A2=dir2cart(numpy.array([az+90.,numpy.zeros(N),numpy.ones(N)]).transpose()).transpose()\n A3=dir2cart(numpy.array([az-180.,90.-pl,numpy.ones(N)]).transpose()).transpose()\n\n# do rotation\n#\n xp=A1[0]*X[0]+A2[0]*X[1]+A3[0]*X[2]\n yp=A1[1]*X[0]+A2[1]*X[1]+A3[1]*X[2]\n zp=A1[2]*X[0]+A2[2]*X[1]+A3[2]*X[2]\n cart=numpy.array([xp,yp,zp]).transpose()\n#\n# transform back to dec,inc\n#\n Dir_geo=cart2dir(cart).transpose()\n return Dir_geo[0],Dir_geo[1] # send back declination and inclination arrays",
"def zipRotation(\r\n\t\t\t\tx=('FloatPin', [0],{PinSpecifires.ENABLED_OPTIONS: PinOptions.ArraySupported}),\r\n\t\t\t\ty=('FloatPin', [1],{PinSpecifires.ENABLED_OPTIONS: PinOptions.ArraySupported}),\r\n\t\t\t\tz=('FloatPin', [2],{PinSpecifires.ENABLED_OPTIONS: PinOptions.ArraySupported}),\r\n\t\t\t\tangle=('FloatPin', [2],{PinSpecifires.ENABLED_OPTIONS: PinOptions.ArraySupported})\r\n\t\t\t) :\r\n \r\n res=np.array([x,y,z]).swapaxes(0,1)\r\n rots=[FreeCAD.Rotation(FreeCAD.Vector(list(a)),b) for a,b in zip(res,angle)] \r\n return rots",
"def _tk1_to_rotations(a: float, b: float, c: float) -> Circuit:\n circ = Circuit(1)\n circ.Rz(c, 0).Rx(b, 0).Rz(a, 0)\n return circ",
"def pol_cart(c1):\r\n r, angle = c1[0], math.radians(c1[1])\r\n x = r * math.cos(angle)\r\n y = r * math.sin(angle)\r\n return [x, y]",
"def Rotation_ECL_EQJ():\n # ob = mean obliquity of the J2000 ecliptic = 0.40909260059599012 radians.\n c = 0.9174821430670688 # cos(ob)\n s = 0.3977769691083922 # sin(ob)\n return RotationMatrix([\n [ 1, 0, 0],\n [ 0, +c, +s],\n [ 0, -s, +c]\n ])",
"def rotations4(polycube, axis):\r\n for i in range(4):\r\n yield rot90(polycube, i, axis)"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks that X is transposed to [Lat, Lon, Sample, Feature] order | def check_transposed(X, x_lat_dim, x_lon_dim, x_sample_dim, x_feature_dim):
assert list(X.dims).index(x_lat_dim) == 0, 'XCast requires a dataset to be transposed to LAT x LON x SAMPLE x FEATURE'
assert list(X.dims).index(x_lon_dim) == 1, 'XCast requires a dataset to be transposed to LAT x LON x SAMPLE x FEATURE'
assert list(X.dims).index(x_sample_dim) == 2, 'XCast requires a dataset to be transposed to LAT x LON x SAMPLE x FEATURE'
assert list(X.dims).index(x_feature_dim) == 3, 'XCast requires a dataset to be transposed to LAT x LON x SAMPLE x FEATURE' | [
"def check_transform(self, X):\n m = X.shape[1]\n\n if self.ncols != m:\n print(\"Number of Columns in input data of fit function and', \\\n 'transform function are different\")\n return False\n\n for i in range(m):\n ls = np.unique(X[:, i])\n n_unique = len(ls)\n\n if self.arr_nunique[i] != n_unique:\n print('Mismatch in the number of unique values in',\n 'the '+str(i)+'th column')\n return False\n for val in ls:\n if val not in self.arr_dic[i].keys():\n print(str(i)+'th column contain a value which was',\n 'not in the data used to fit data')\n return False\n\n return True",
"def ggml_is_transposed(tensor: ffi.CData) -> bool:\n ...",
"def check_type(X, x_lat_dim, x_lon_dim, x_sample_dim, x_feature_dim):\n\tassert type(X) == xr.DataArray, 'XCast requires a dataset to be of type \"Xarray.DataArray\"'",
"def _validate_X(X):\n return X if not isinstance(X, pd.DataFrame) else X.as_matrix()",
"def test_feature_format(X):\r\n print(\"test_feature_format()...\", end = \"\")\r\n for row in range(len(X)):\r\n for col in range(len(X[0])):\r\n assert (isinstance(X[row][col], float) == True)\r\n print(\"Passed!\")",
"def check_coords(X, x_lat_dim, x_lon_dim, x_sample_dim, x_feature_dim):\n\tassert x_lat_dim in X.coords.keys(), 'XCast requires a dataset_lat_dim to be a coordinate on X'\n\tassert x_lon_dim in X.coords.keys(), 'XCast requires a dataset_lon_dim to be a coordinate on X'\n\tassert x_sample_dim in X.coords.keys(), 'XCast requires a dataset_sample_dim to be a coordinate on X'\n\tassert x_feature_dim in X.coords.keys(), 'XCast requires a dataset_feature_dim to be a coordinate on X'",
"def can_transpose_pass(self):\n raise NotImplementedError(\"This function must be implemented by each op\")",
"def check_conv_transpose(extract):\n call = extract\n if isinstance(call, tvm.relay.expr.TupleGetItem):\n call = call.tuple_value\n elif call.op.name == \"nn.relu\":\n call = call.args[0]\n if isinstance(call, tvm.relay.expr.TupleGetItem):\n call = call.tuple_value\n elif call.op.name == \"clip\":\n if call.attrs[\"a_min\"] != 0.0 or call.attrs[\"a_max\"] != 6.0:\n return False\n call = call.args[0]\n if isinstance(call, tvm.relay.expr.TupleGetItem):\n call = call.tuple_value\n\n while call.op.name != \"nn.conv2d_transpose\":\n call = call.args[0]\n\n attrs = call.attrs\n if attrs.data_layout != \"NCHW\":\n return False\n\n return True",
"def _get_columns_to_encode(\n self,\n X: pd.DataFrame,\n ) -> Tuple[List[str], List[str]]:\n\n if len(self.transformed_columns) > 0 and self.feat_types is not None:\n return self.transformed_columns, self.feat_types\n\n # Register if a column needs encoding\n transformed_columns = []\n\n # Also, register the feature types for the estimator\n feat_types = []\n\n # Make sure each column is a valid type\n for i, column in enumerate(X.columns):\n if X[column].dtype.name in ['category', 'bool']:\n\n transformed_columns.append(column)\n if self.feat_types is not None and self.feat_types[i].lower() == 'numerical':\n raise ValueError(f\"Passed numerical as the feature type for column: {column} \"\n f\"but the column is categorical\")\n feat_types.append('categorical')\n # Move away from np.issubdtype as it causes\n # TypeError: data type not understood in certain pandas types\n elif not is_numeric_dtype(X[column]):\n if X[column].dtype.name == 'object':\n raise ValueError(\n \"Input Column {} has invalid type object. \"\n \"Cast it to a valid dtype before using it in AutoPyTorch. \"\n \"Valid types are numerical, categorical or boolean. \"\n \"You can cast it to a valid dtype using \"\n \"pandas.Series.astype .\"\n \"If working with string objects, the following \"\n \"tutorial illustrates how to work with text data: \"\n \"https://scikit-learn.org/stable/tutorial/text_analytics/working_with_text_data.html\".format(\n # noqa: E501\n column,\n )\n )\n elif pd.core.dtypes.common.is_datetime_or_timedelta_dtype(\n X[column].dtype\n ):\n raise ValueError(\n \"AutoPyTorch does not support time and/or date datatype as given \"\n \"in column {}. Please convert the time information to a numerical value \"\n \"first. One example on how to do this can be found on \"\n \"https://stats.stackexchange.com/questions/311494/\".format(\n column,\n )\n )\n else:\n raise ValueError(\n \"Input Column {} has unsupported dtype {}. \"\n \"Supported column types are categorical/bool/numerical dtypes. \"\n \"Make sure your data is formatted in a correct way, \"\n \"before feeding it to AutoPyTorch.\".format(\n column,\n X[column].dtype.name,\n )\n )\n else:\n feat_types.append('numerical')\n return transformed_columns, feat_types",
"def _need_transpose(expr_matrix, adj_matrix):\n return expr_matrix.shape[1] != adj_matrix.shape[0]",
"def test_AuxiliaryCoordinate_transpose(self):\n f = cfdm.read(self.filename)[0]\n x = f.auxiliary_coordinates(\"longitude\").value()\n\n bounds = cfdm.Bounds(\n data=cfdm.Data(numpy.arange(9 * 10 * 4).reshape(9, 10, 4))\n )\n x.set_bounds(bounds)\n\n self.assertEqual(x.shape, (9, 10))\n self.assertEqual(x.bounds.shape, (9, 10, 4))\n\n y = x.transpose()\n self.assertEqual(y.shape, (10, 9))\n self.assertEqual(y.bounds.shape, (10, 9, 4), y.bounds.shape)\n\n x.transpose([1, 0], inplace=True)\n self.assertEqual(x.shape, (10, 9))\n self.assertEqual(x.bounds.shape, (10, 9, 4), x.bounds.shape)",
"def test_transpose_removes_raw(adata):\n assert adata.T.raw is None",
"def _validate_XY(X, Y):\n try:\n for inp in [X, Y]:\n assert isinstance(inp, torch.Tensor)\n assert inp.dtype is torch.float or inp.dtype is torch.double\n assert len(inp.shape) == 2\n assert X.dtype is Y.dtype\n assert X.shape[0] == Y.shape[0]\n except AssertionError:\n raise AttributeError(\n \"invalid inputs: X and Y should be float/double tensors of shape \"\n \"(n, d) and (n, m) respectively, where n is the number of samples, \"\n \"d is the number of features, and m is the number of outputs\"\n )",
"def get_columns_to_encode(\n self,\n X: pd.DataFrame\n ) -> Tuple[List[str], List[str]]:\n transformed_columns, feat_types = self._get_columns_to_encode(X)\n if self.feat_types is not None:\n self._validate_feat_types(X)\n transformed_columns = [X.columns[i] for i, col in enumerate(self.feat_types)\n if col.lower() == 'categorical']\n return transformed_columns, self.feat_types\n else:\n return transformed_columns, feat_types",
"def check_consistent(X, x_lat_dim, x_lon_dim, x_sample_dim, x_feature_dim):\n\tassert X.shape[list(X.dims).index(x_lat_dim)] == len(X.coords[x_lat_dim].values), \"XCast requires a dataset's x_lat_dim coordinate to be the same length as its x_lat_dim dimension\"\n\tassert X.shape[list(X.dims).index(x_lon_dim)] == len(X.coords[x_lon_dim].values), \"XCast requires a dataset's x_lon_dim coordinate to be the same length as its x_lon_dim dimension\"\n\tassert X.shape[list(X.dims).index(x_sample_dim)] == len(X.coords[x_sample_dim].values), \"XCast requires a dataset's x_sample_dim coordinate to be the same length as its x_sample_dim dimension\"\n\tassert X.shape[list(X.dims).index(x_feature_dim)] == len(X.coords[x_feature_dim].values), \"XCast requires a dataset's x_feature_dim coordinate to be the same length as its x_feature_dim dimension\"",
"def test_run_on_full_dataset(self):\n xtr = CustomTransformer().fit_transform(X=data, y=data['y'])\n \n self.assertEqual(len(data), len(xtr))\n self.assertFalse(xtr.empty)",
"def _maybe_transpose(dataset, model, check_dims, batch_dim):\n strict = check_dims is CheckDimsOption.STRICT\n transpose = check_dims is CheckDimsOption.TRANSPOSE\n\n ds_transposed = dataset.copy()\n\n for var_key in model.input_vars:\n xr_var_name = model.cache[var_key][\"name\"]\n xr_var = dataset.get(xr_var_name)\n\n if xr_var is None:\n continue\n\n # all valid dimensions in the right order\n dims = [list(d) for d in model.cache[var_key][\"metadata\"][\"dims\"]]\n dims += [[dataset.xsimlab.master_clock_dim] + d for d in dims]\n if batch_dim is not None:\n dims += [[batch_dim] + d for d in dims]\n\n dims = [tuple(d) for d in dims]\n\n # unordered -> ordered mapping for all valid dimensions\n valid_dims = {frozenset(d): d for d in dims}\n\n # actual dimensions (not ordered)\n actual_dims = frozenset(xr_var.dims)\n\n if transpose and actual_dims in valid_dims:\n reordered_dims = valid_dims[actual_dims]\n ds_transposed[xr_var_name] = xr_var.transpose(*reordered_dims)\n\n if (strict or transpose) and ds_transposed[xr_var_name].dims not in dims:\n raise ValueError(\n f\"Invalid dimension(s) for variable '{xr_var_name}': \"\n f\"found {xr_var.dims!r}, \"\n f\"must be one of {','.join([str(d) for d in dims])}\"\n )\n\n return ds_transposed",
"def data_as_timesteps(X):\n if isinstance(X, list):\n # Make tabular data from a list of examples\n X = np.vstack(X)\n # Stack data so that features are the 3rd dimension\n return np.dstack([X])",
"def test_transpose(self):\n matrix = ((1, 2), (3, 4), (5, 6))\n matrix_t = ((1, 3, 5), (2, 4, 6))\n self.assertEqual(matrix_t, transpose(matrix))\n\n matrix = ((1,),)\n self.assertEqual(matrix, transpose(matrix))\n\n matrix = ((1, 2), (3, 4))\n matrix_t = ((1, 3), (2, 4))\n self.assertEqual(matrix_t, transpose(matrix))"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks that X is 4D, with Dimension Names as specified by x_lat_dim, x_lon_dim, x_sample_dim, and x_feature_dim | def check_dimensions(X, x_lat_dim, x_lon_dim, x_sample_dim, x_feature_dim):
assert 4 <= len(X.dims) <= 5, 'XCast requires a dataset to be 4-Dimensional'
assert x_lat_dim in X.dims, 'XCast requires a dataset_lat_dim to be a dimension on X'
assert x_lon_dim in X.dims, 'XCast requires a dataset_lon_dim to be a dimension on X'
assert x_sample_dim in X.dims, 'XCast requires a dataset_sample_dim to be a dimension on X'
assert x_feature_dim in X.dims, 'XCast requires a dataset_feature_dim to be a dimension on X' | [
"def check_coords(X, x_lat_dim, x_lon_dim, x_sample_dim, x_feature_dim):\n\tassert x_lat_dim in X.coords.keys(), 'XCast requires a dataset_lat_dim to be a coordinate on X'\n\tassert x_lon_dim in X.coords.keys(), 'XCast requires a dataset_lon_dim to be a coordinate on X'\n\tassert x_sample_dim in X.coords.keys(), 'XCast requires a dataset_sample_dim to be a coordinate on X'\n\tassert x_feature_dim in X.coords.keys(), 'XCast requires a dataset_feature_dim to be a coordinate on X'",
"def dimension_check():\n print(\"### DIMENSION CHECK ###\")\n print(X.shape,\n y.shape,\n X_train.shape,\n y_train.shape,\n X_test.shape,\n y_test.shape,\n weights.shape)\n print(\"### END ###\")",
"def maybe_reshape_4d_to_3d(x):\n x_shape = common_layers.shape_list(x)\n is_4d = False\n if len(x_shape) == 4:\n x = tf.reshape(x, [x_shape[0], x_shape[1]*x_shape[2], x_shape[3]])\n is_4d = True\n return x, x_shape, is_4d",
"def check_consistent(X, x_lat_dim, x_lon_dim, x_sample_dim, x_feature_dim):\n\tassert X.shape[list(X.dims).index(x_lat_dim)] == len(X.coords[x_lat_dim].values), \"XCast requires a dataset's x_lat_dim coordinate to be the same length as its x_lat_dim dimension\"\n\tassert X.shape[list(X.dims).index(x_lon_dim)] == len(X.coords[x_lon_dim].values), \"XCast requires a dataset's x_lon_dim coordinate to be the same length as its x_lon_dim dimension\"\n\tassert X.shape[list(X.dims).index(x_sample_dim)] == len(X.coords[x_sample_dim].values), \"XCast requires a dataset's x_sample_dim coordinate to be the same length as its x_sample_dim dimension\"\n\tassert X.shape[list(X.dims).index(x_feature_dim)] == len(X.coords[x_feature_dim].values), \"XCast requires a dataset's x_feature_dim coordinate to be the same length as its x_feature_dim dimension\"",
"def _check_shape(input_shape):\n msg = ('Input to SpatialExpansion must be 4D with dimensions: '\n '(n_observations, n_spatial_0, n_spatial_1, n_features), '\n 'but received shape: {}'.format(input_shape))\n assert len(input_shape) == 4, msg",
"def check_input_dimension(self, data):\n if len(data[0]) != self.input_dimension:\n raise ValueError(\"Received {} features, expected {}.\".format(self.input_dimension, len(data[0])))",
"def test_shape_data(self):\n self.assert_dim_type_supported({\"x\": \"uniform(0, 5, shape=(3, 2))\"})",
"def check_transposed(X, x_lat_dim, x_lon_dim, x_sample_dim, x_feature_dim):\n\tassert list(X.dims).index(x_lat_dim) == 0, 'XCast requires a dataset to be transposed to LAT x LON x SAMPLE x FEATURE'\n\tassert list(X.dims).index(x_lon_dim) == 1, 'XCast requires a dataset to be transposed to LAT x LON x SAMPLE x FEATURE'\n\tassert list(X.dims).index(x_sample_dim) == 2, 'XCast requires a dataset to be transposed to LAT x LON x SAMPLE x FEATURE'\n\tassert list(X.dims).index(x_feature_dim) == 3, 'XCast requires a dataset to be transposed to LAT x LON x SAMPLE x FEATURE'",
"def check_type(X, x_lat_dim, x_lon_dim, x_sample_dim, x_feature_dim):\n\tassert type(X) == xr.DataArray, 'XCast requires a dataset to be of type \"Xarray.DataArray\"'",
"def _check_x_dimension(x):\n x = np.atleast_1d(x)\n if len(x.shape) > 2 or (len(x.shape) == 2 and x.shape[1] != 1):\n raise ValueError('Wrong dimension in x.')\n return x.reshape((-1, ))",
"def _check_shape(self, X):\n return all([X.shape[i] == self.train_shape[i] for i in range(2)])",
"def _check_input_dimensions(self, obs_dim):\n if obs_dim == self.length_raw_array:\n return True\n else:\n raise ObservationArrayExpectedDimFail()",
"def test_real_data(self):\n self.assert_dim_type_supported({\"x\": \"uniform(0, 5)\"})",
"def _check_shape(input_shape):\n msg = ('Input to FlattenAxis must be 5D with dimensions: '\n '(n_observations, n_spatial_0, n_spatial_1, n_temporal, '\n 'n_features), but received shape: {}'.format(input_shape))\n assert len(input_shape) == 5, msg",
"def generate_feature_dimensions(self):\n pass",
"def has_dims(xobj, dims, kind):\n if isinstance(dims, str):\n dims = [dims]\n\n if not all(dim in xobj.dims for dim in dims):\n raise DimensionError(\n f'Your {kind} object must contain the '\n f'following dimensions at the minimum: {dims}'\n )\n return True",
"def test_check_X_too_many_dims():\n with pytest.raises(ValueError):\n check_X(np.ones((5,4,3)))",
"def validate_dimensions(x: ndarray, expected_dimensionality: int):\n array_dimensions = np.ndim(x)\n\n if array_dimensions != 2:\n raise ValueError(\"Expected a 2-dimensional array, but got a {}-dimensional array.\".format(array_dimensions))\n\n actual_dimensionality = np.size(x, 1)\n\n if actual_dimensionality != expected_dimensionality:\n raise ValueError(\"Expected data in {} dimensions, but got data in {} dimensions.\"\n .format(expected_dimensionality, actual_dimensionality))",
"def check_dimensions(d_real, d_fake, d_real_logits, d_fake_logits):\n def _check_pair(a, b):\n if a != b:\n raise ValueError(\"Shape mismatch: %s vs %s.\" % (a, b))\n if len(a) != 2 or len(b) != 2:\n raise ValueError(\"Rank: expected 2, got %s and %s\" % (len(a), len(b)))\n\n if (d_real is not None) and (d_fake is not None):\n _check_pair(d_real.shape.as_list(), d_fake.shape.as_list())\n if (d_real_logits is not None) and (d_fake_logits is not None):\n _check_pair(d_real_logits.shape.as_list(), d_fake_logits.shape.as_list())\n if (d_real is not None) and (d_real_logits is not None):\n _check_pair(d_real.shape.as_list(), d_real_logits.shape.as_list())"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks that X has coordinates named as specified by x_lat_dim, x_lon_dim, x_sample_dim, and x_feature_dim | def check_coords(X, x_lat_dim, x_lon_dim, x_sample_dim, x_feature_dim):
assert x_lat_dim in X.coords.keys(), 'XCast requires a dataset_lat_dim to be a coordinate on X'
assert x_lon_dim in X.coords.keys(), 'XCast requires a dataset_lon_dim to be a coordinate on X'
assert x_sample_dim in X.coords.keys(), 'XCast requires a dataset_sample_dim to be a coordinate on X'
assert x_feature_dim in X.coords.keys(), 'XCast requires a dataset_feature_dim to be a coordinate on X' | [
"def check_dimensions(X, x_lat_dim, x_lon_dim, x_sample_dim, x_feature_dim):\n\tassert 4 <= len(X.dims) <= 5, 'XCast requires a dataset to be 4-Dimensional'\n\tassert x_lat_dim in X.dims, 'XCast requires a dataset_lat_dim to be a dimension on X'\n\tassert x_lon_dim in X.dims, 'XCast requires a dataset_lon_dim to be a dimension on X'\n\tassert x_sample_dim in X.dims, 'XCast requires a dataset_sample_dim to be a dimension on X'\n\tassert x_feature_dim in X.dims, 'XCast requires a dataset_feature_dim to be a dimension on X'",
"def check_consistent(X, x_lat_dim, x_lon_dim, x_sample_dim, x_feature_dim):\n\tassert X.shape[list(X.dims).index(x_lat_dim)] == len(X.coords[x_lat_dim].values), \"XCast requires a dataset's x_lat_dim coordinate to be the same length as its x_lat_dim dimension\"\n\tassert X.shape[list(X.dims).index(x_lon_dim)] == len(X.coords[x_lon_dim].values), \"XCast requires a dataset's x_lon_dim coordinate to be the same length as its x_lon_dim dimension\"\n\tassert X.shape[list(X.dims).index(x_sample_dim)] == len(X.coords[x_sample_dim].values), \"XCast requires a dataset's x_sample_dim coordinate to be the same length as its x_sample_dim dimension\"\n\tassert X.shape[list(X.dims).index(x_feature_dim)] == len(X.coords[x_feature_dim].values), \"XCast requires a dataset's x_feature_dim coordinate to be the same length as its x_feature_dim dimension\"",
"def check_type(X, x_lat_dim, x_lon_dim, x_sample_dim, x_feature_dim):\n\tassert type(X) == xr.DataArray, 'XCast requires a dataset to be of type \"Xarray.DataArray\"'",
"def check_input_dimension(self, data):\n if len(data[0]) != self.input_dimension:\n raise ValueError(\"Received {} features, expected {}.\".format(self.input_dimension, len(data[0])))",
"def is_x(self, var):\n x_list = ['lon', 'longitude', 'LONGITUDE', 'Longitude', 'x']\n\n if self.get_units(var) == 'degrees_east':\n return True\n if self.get_name(var) in x_list:\n return True\n if self.get_description(var) in x_list:\n return True\n else:\n return False",
"def check_transposed(X, x_lat_dim, x_lon_dim, x_sample_dim, x_feature_dim):\n\tassert list(X.dims).index(x_lat_dim) == 0, 'XCast requires a dataset to be transposed to LAT x LON x SAMPLE x FEATURE'\n\tassert list(X.dims).index(x_lon_dim) == 1, 'XCast requires a dataset to be transposed to LAT x LON x SAMPLE x FEATURE'\n\tassert list(X.dims).index(x_sample_dim) == 2, 'XCast requires a dataset to be transposed to LAT x LON x SAMPLE x FEATURE'\n\tassert list(X.dims).index(x_feature_dim) == 3, 'XCast requires a dataset to be transposed to LAT x LON x SAMPLE x FEATURE'",
"def _check_shape(self, X):\n return all([X.shape[i] == self.train_shape[i] for i in range(2)])",
"def check_has_dims(hdr):\n try:\n return (hdr['startX'], hdr['startY'])\n except KeyError:\n return False",
"def _check_input_dimensions(self, obs_dim):\n if obs_dim == self.length_raw_array:\n return True\n else:\n raise ObservationArrayExpectedDimFail()",
"def _check_x_dimension(x):\n x = np.atleast_1d(x)\n if len(x.shape) > 2 or (len(x.shape) == 2 and x.shape[1] != 1):\n raise ValueError('Wrong dimension in x.')\n return x.reshape((-1, ))",
"def _check_missing_inputs(dataset, model):\n missing_xr_vars = []\n\n for p_name, var_name in model.input_vars:\n xr_var_name = p_name + \"__\" + var_name\n\n if xr_var_name not in dataset:\n missing_xr_vars.append(xr_var_name)\n\n if missing_xr_vars:\n raise KeyError(f\"Missing variables {missing_xr_vars} in Dataset\")",
"def _check_shape(input_shape):\n msg = ('Input to SpatialExpansion must be 4D with dimensions: '\n '(n_observations, n_spatial_0, n_spatial_1, n_features), '\n 'but received shape: {}'.format(input_shape))\n assert len(input_shape) == 4, msg",
"def test_shape_data(self):\n self.assert_dim_type_supported({\"x\": \"uniform(0, 5, shape=(3, 2))\"})",
"def has_dims(xobj, dims, kind):\n if isinstance(dims, str):\n dims = [dims]\n\n if not all(dim in xobj.dims for dim in dims):\n raise DimensionError(\n f'Your {kind} object must contain the '\n f'following dimensions at the minimum: {dims}'\n )\n return True",
"def test_fail_dimension_requirement(self):\n msg = \"The cube does not contain the expected\"\n cube = self.cube[0, :, 0]\n with self.assertRaisesRegex(ValueError, msg):\n check_for_x_and_y_axes(cube, require_dim_coords=True)",
"def test_feature_values(iris, name, x_feature, y_feature, x_vals, y_vals):\n iris.x_feature = x_feature\n iris.y_feature = y_feature\n assert iris.title == \"{} x {}\".format(x_feature, y_feature)\n data = iris.sources[name].data\n np.testing.assert_array_almost_equal(data[\"x\"][:2], x_vals)\n np.testing.assert_array_almost_equal(data[\"y\"][:2], y_vals)",
"def test_check_X_too_many_dims():\n with pytest.raises(ValueError):\n check_X(np.ones((5,4,3)))",
"def validate_xy(x_train, y_train):\n try:\n x_train = x_train.astype('float64')\n except ValueError:\n raise ValueError('x_train should only contain numerical data.')\n\n if len(x_train.shape) < 2:\n raise ValueError('x_train should at least has 2 dimensions.')\n\n if x_train.shape[0] != y_train.shape[0]:\n raise ValueError('x_train and y_train should have the same number of instances.')",
"def _validate_axis_arg(self, axis: List[SpatialAxis]):\n for key in axis:\n if key not in SPATIAL_AXES:\n raise ValueError(\n \"Incorrect `axis` argument value. Supported values include: \"\n f\"{', '.join(SPATIAL_AXES)}.\"\n )\n\n # Check the axis coordinate variable exists in the Dataset.\n get_dim_coords(self._dataset, key)"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks that X's Coordinates are the same length as X's Dimensions | def check_consistent(X, x_lat_dim, x_lon_dim, x_sample_dim, x_feature_dim):
assert X.shape[list(X.dims).index(x_lat_dim)] == len(X.coords[x_lat_dim].values), "XCast requires a dataset's x_lat_dim coordinate to be the same length as its x_lat_dim dimension"
assert X.shape[list(X.dims).index(x_lon_dim)] == len(X.coords[x_lon_dim].values), "XCast requires a dataset's x_lon_dim coordinate to be the same length as its x_lon_dim dimension"
assert X.shape[list(X.dims).index(x_sample_dim)] == len(X.coords[x_sample_dim].values), "XCast requires a dataset's x_sample_dim coordinate to be the same length as its x_sample_dim dimension"
assert X.shape[list(X.dims).index(x_feature_dim)] == len(X.coords[x_feature_dim].values), "XCast requires a dataset's x_feature_dim coordinate to be the same length as its x_feature_dim dimension" | [
"def _check_shape(self, X):\n return all([X.shape[i] == self.train_shape[i] for i in range(2)])",
"def check_dimensions(X, x_lat_dim, x_lon_dim, x_sample_dim, x_feature_dim):\n\tassert 4 <= len(X.dims) <= 5, 'XCast requires a dataset to be 4-Dimensional'\n\tassert x_lat_dim in X.dims, 'XCast requires a dataset_lat_dim to be a dimension on X'\n\tassert x_lon_dim in X.dims, 'XCast requires a dataset_lon_dim to be a dimension on X'\n\tassert x_sample_dim in X.dims, 'XCast requires a dataset_sample_dim to be a dimension on X'\n\tassert x_feature_dim in X.dims, 'XCast requires a dataset_feature_dim to be a dimension on X'",
"def check_coords(X, x_lat_dim, x_lon_dim, x_sample_dim, x_feature_dim):\n\tassert x_lat_dim in X.coords.keys(), 'XCast requires a dataset_lat_dim to be a coordinate on X'\n\tassert x_lon_dim in X.coords.keys(), 'XCast requires a dataset_lon_dim to be a coordinate on X'\n\tassert x_sample_dim in X.coords.keys(), 'XCast requires a dataset_sample_dim to be a coordinate on X'\n\tassert x_feature_dim in X.coords.keys(), 'XCast requires a dataset_feature_dim to be a coordinate on X'",
"def _check_input_dimensions(self, obs_dim):\n if obs_dim == self.length_raw_array:\n return True\n else:\n raise ObservationArrayExpectedDimFail()",
"def _check_dimensions(self, workspace_to_check):\n for i in range(self._raw_ws.getNumDims()):\n if self._raw_ws.getDimension(i).getNBins() != workspace_to_check._raw_ws.getDimension(i).getNBins():\n return False\n return True",
"def _check_size(self, new_shape):\n if self._shape != new_shape:\n if not (self._shape == (1,) and new_shape == ()):\n return True\n return False",
"def nd_shape_checking(x, y, mvaxis, traxis):\n assert x.ndim == y.ndim\n dims = np.delete(np.arange(x.ndim), -2)\n assert all([x.shape[k] == y.shape[k] for k in dims])",
"def _checkSize(X1,X2):\n \n if len(X1) != len(X2):\n raise ValueError, 'Lists are differnt lengths'",
"def test_check_X_too_many_dims():\n with pytest.raises(ValueError):\n check_X(np.ones((5,4,3)))",
"def verify_coords(self, piece_coords):\n if piece_coords[0] >= self.size or piece_coords[0] < 0:\n return False\n if piece_coords[1] >= self.size or piece_coords[1] < 0:\n return False\n return True",
"def _check_x_dimension(x):\n x = np.atleast_1d(x)\n if len(x.shape) > 2 or (len(x.shape) == 2 and x.shape[1] != 1):\n raise ValueError('Wrong dimension in x.')\n return x.reshape((-1, ))",
"def check_ship_correct_size(length, pos1, pos2):\n return pos2[0] - pos1[0] + 1 == length or pos2[1] - pos1[1] + 1 == length",
"def check_rect(df):\n if len(np.unique(df.DISPLAY_COORDS)) == 1:\n print(\"Consistency check: All files have same stimulus size (rect).\") \n return True\n else:\n return False",
"def _shape_check(self, X, y):\n if not len(y.shape) > 1:\n raise RuntimeError(\"The shape of y is incorrect.\")\n if y.shape != X.shape[:-1]:\n raise RuntimeError(\"X and y must have the same number of \" +\n \"samples and microstructure shape.\")\n if X.shape[-1] != 3:\n raise RuntimeError(\"X must have 3 continuous local states \" +\n \"(euler angles)\")",
"def validate_dimensions(x: ndarray, expected_dimensionality: int):\n array_dimensions = np.ndim(x)\n\n if array_dimensions != 2:\n raise ValueError(\"Expected a 2-dimensional array, but got a {}-dimensional array.\".format(array_dimensions))\n\n actual_dimensionality = np.size(x, 1)\n\n if actual_dimensionality != expected_dimensionality:\n raise ValueError(\"Expected data in {} dimensions, but got data in {} dimensions.\"\n .format(expected_dimensionality, actual_dimensionality))",
"def _validate_dimensionality(self):\r\n\r\n if self.time.ndim != 1:\r\n raise ValueError(\"time array must be one-dimensional\")\r\n npoints = self.data.shape[-1]\r\n if npoints != len(self.time):\r\n raise ValueError(\"mismatch of time and data dimensions\")",
"def test_coord_promotion(self):\n result = check_cube_coordinates(self.cube, self.squeezed_cube)\n self.assertEqual(result.dim_coords, self.cube.dim_coords)\n self.assertEqual(\n result.coords(dim_coords=False), self.cube.coords(dim_coords=False)\n )",
"def verifyBlockDims(self):\n return",
"def test_point_within_dimensions_true():\n point = np.array([10, 20])\n image_dimensions = np.array([100, 100])\n assert point_within_dimensions(point, image_dimensions)"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks that X is an Xarray.DataArray | def check_type(X, x_lat_dim, x_lon_dim, x_sample_dim, x_feature_dim):
assert type(X) == xr.DataArray, 'XCast requires a dataset to be of type "Xarray.DataArray"' | [
"def __check_is_xarray(self, data):\n if type(data) is xr.core.dataarray.DataArray or \\\n type(data) is xr.core.dataarray.Dataset:\n\n return True\n else:\n msg = \"Variable {data} is not an xarray DataArray/Dataset\"\n raise Exception(msg)",
"def is_xarray(x):\n return isinstance(x, xr.DataArray)",
"def check_ndarray(data):\n if data.__class__ is not np.ndarray:\n raise TypeError(\"Argument of type numpy.ndarray expected\")",
"def _validate_X(X):\n if not isinstance(X, pd.DataFrame):\n raise ValueError(\"X should be a dataframe.\")",
"def isarray(x):\r\n\r\n try:\r\n return isinstance(x, array)\r\n except:\r\n return False",
"def is_xarray(func, *dec_args):\n\n @wraps(func)\n def wrapper(*args, **kwargs):\n try:\n ds_da_locs = dec_args[0]\n if not isinstance(ds_da_locs, list):\n ds_da_locs = [ds_da_locs]\n\n for loc in ds_da_locs:\n if isinstance(loc, int):\n ds_da = args[loc]\n elif isinstance(loc, str):\n ds_da = kwargs[loc]\n\n is_ds_da = isinstance(ds_da, (xr.Dataset, xr.DataArray))\n if not is_ds_da:\n typecheck = type(ds_da)\n raise IOError(\n f\"\"\"The input data is not an xarray DataArray or\n Dataset. climpred is built to wrap xarray to make\n use of its awesome features. Please input an xarray\n object and retry the function.\n\n Your input was of type: {typecheck}\"\"\"\n )\n except IndexError:\n pass\n # this is outside of the try/except so that the traceback is relevant\n # to the actual function call rather than showing a simple Exception\n # (probably IndexError from trying to subselect an empty dec_args list)\n return func(*args, **kwargs)\n\n return wrapper",
"def _validate_X(X):\n return X if not isinstance(X, pd.DataFrame) else X.as_matrix()",
"def _check_input_data(self, data):\n\n if not isinstance(data, np.ndarray):\n raise TypeError('Input data must be a numpy array.')",
"def test_check_instance():\n assert isinstance(basic_test_result, xr.Dataset)",
"def _is_DataArrays(data):\n if isinstance(data, (Dataset, DataArray)):\n return True\n if isinstance(data, Mapping):\n for da in data.values():\n if not isinstance(da, DataArray):\n raise TypeError(\"Please provide List/Mapping of DataArrays\")\n return True\n if isinstance(data, Iterable):\n for da in data:\n if not isinstance(da, DataArray):\n return False\n # raise TypeError(\"Please provide List/Mapping of DataArrays\")\n return True\n return False",
"def errorchecks_da_or_ds(a):\n\n # Check variable is a xarray.DataArray\n tmp = isinstance(a, xr.core.dataarray.DataArray)\n if tmp == True:\n errorchecks1var(a)\n else:\n tmp2 = isinstance(a, xr.core.dataset.Dataset)\n if tmp2 == True:\n errorchecksvars(a)\n else:\n raise TypeError('a is: ' + str(type(a)) + '. Should be xr.DataArray or xr.Dataset')",
"def is_ndarray(data_to_check):\n flag = False\n if isinstance(data_to_check, np.ndarray):\n flag = True\n return flag",
"def check_is_numpy_or_pd(X):\n if isinstance(X, list):\n return np.asarray(X)\n if isinstance(X, pd.DataFrame):\n return X\n if isinstance(X, np.ndarray):\n return X\n \n raise ValueError(\n \"Expected an pandas DataFrame or numpy array or python list as input \"\n \"but got {}\".format(str(type(X)))\n )",
"def check_array_1D(X):\n X = check_is_numpy(X)\n if X.ndim != 1:\n raise ValueError(\n \"If passed as a np.array, X must be a 1-dimensional \"\n \"array, but found shape: {}\".format(X.shape)\n )\n if X.size == 0:\n raise ValueError(\n \"Input is empty or have a dimension of size 0\"\n \", found shape: {}\".format(X.shape)\n )\n \n return X",
"def check_coords(X, x_lat_dim, x_lon_dim, x_sample_dim, x_feature_dim):\n\tassert x_lat_dim in X.coords.keys(), 'XCast requires a dataset_lat_dim to be a coordinate on X'\n\tassert x_lon_dim in X.coords.keys(), 'XCast requires a dataset_lon_dim to be a coordinate on X'\n\tassert x_sample_dim in X.coords.keys(), 'XCast requires a dataset_sample_dim to be a coordinate on X'\n\tassert x_feature_dim in X.coords.keys(), 'XCast requires a dataset_feature_dim to be a coordinate on X'",
"def _is_array(obj):\r\n return isinstance(obj, np.ndarray)",
"def CheckType(X,module,varname):\r\n \r\n # author: Gary Mamon\r\n \r\n t = type(X)\r\n if t is not float and t is not np.float64 and t is not int and t is not np.ndarray:\r\n raise print('ERROR in ', module, ' ', varname, \r\n ' is of type ', t, \r\n ', but it must be a float or integer')",
"def is_data(data):\n return type(data).__name__ == \"Data\"",
"def check_dimensions(X, x_lat_dim, x_lon_dim, x_sample_dim, x_feature_dim):\n\tassert 4 <= len(X.dims) <= 5, 'XCast requires a dataset to be 4-Dimensional'\n\tassert x_lat_dim in X.dims, 'XCast requires a dataset_lat_dim to be a dimension on X'\n\tassert x_lon_dim in X.dims, 'XCast requires a dataset_lon_dim to be a dimension on X'\n\tassert x_sample_dim in X.dims, 'XCast requires a dataset_sample_dim to be a dimension on X'\n\tassert x_feature_dim in X.dims, 'XCast requires a dataset_feature_dim to be a dimension on X'"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return a new ObjectChange representing a change made to this object. This will typically be called automatically by ChangeLoggingMiddleware. | def to_objectchange(self, action):
return ObjectChange(
changed_object=self,
object_repr=str(self),
action=action,
object_data=serialize_object(self),
) | [
"def log_change(self, request, obj, message):\n from .tasks import create_log\n from django.contrib.admin.models import CHANGE\n defer(create_log, \n user_id = request.user.id,\n user_name = unicode(request.user),\n content_type = obj._meta.verbose_name,\n app_label = obj._meta.app_label,\n object_id = obj.pk,\n object_repr = unicode(obj),\n action_flag = CHANGE,\n change_message = message\n )",
"def change_object(self, new_object):\n raise NotImplementedError",
"def _new_changeset_object(self, changeset_info):\n return Changeset(self, changeset_info)",
"def __call__(self, change: ChangeDict) -> None:\n old = None\n new = None\n ctype = change[\"type\"]\n if ctype == \"create\":\n new = change[\"value\"]\n elif ctype == \"update\":\n old = change[\"oldvalue\"]\n new = change[\"value\"]\n elif ctype == \"delete\":\n old = change[\"value\"]\n attr = self.attr\n owner = change[\"object\"]\n handler = getattr(owner, self.funcname)\n if isinstance(old, Atom):\n old.unobserve(attr, handler)\n if isinstance(new, Atom):\n new.observe(attr, handler)\n elif new is not None:\n msg = \"cannot attach observer '%s' to non-Atom %s\"\n raise TypeError(msg % (attr, new))",
"def log_change(self, request, object, message, data):\n from django.contrib.admin.models import LogEntry, CHANGE\n log_obj = CustomLogEntry.objects.log_action(\n user_id=request.user.pk,\n content_type_id=get_content_type_for_model(object).pk,\n object_id=object.pk,\n object_repr=str(object),\n action_flag=CHANGE,\n change_message=message,\n )\n log_obj.changed_data = data\n log_obj.request_meta = str(request.META)\n log_obj.ip_address = get_client_ip(request)\n log_obj.save()",
"def modified_object(obj, event):\n now = datetime.now(tz=_zone)\n obj.modification_date = now",
"def modified(self, **attributes):\n new_obj = deepcopy(self)\n new_obj.__dict__.update(attributes)\n new_obj.initialize()\n return new_obj",
"def OldValue(self) -> object:",
"def render_changes(self, obj):\n update_fields = []\n for field, (_, new_value) in self.watched_changes.items():\n setattr(obj, field, new_value)\n update_fields.append(field)\n obj.save(skip_moderation=True, update_fields=update_fields)",
"def real_change(self) -> RealChange:\n assert self.kind is TokenKind.CHANGE_REAL\n assert isinstance(self.data, RealChange)\n return self.data",
"def make_eventless_copy(self):\n new_person = copy(self)\n new_person.state_to_events = {}\n new_person.routine_change_multiplicities = {}\n new_person.routine_changes = {}\n return new_person",
"def _get_or_create_moderated_object(self, instance,\r\n unchanged_obj, moderator):\r\n try:\r\n moderated_object = ModeratedObject.objects.\\\r\n get_for_instance(instance)\r\n\r\n except ObjectDoesNotExist:\r\n moderated_object = ModeratedObject(content_object=unchanged_obj)\r\n moderated_object.changed_object = unchanged_obj\r\n\r\n else:\r\n if moderated_object.has_object_been_changed(instance):\r\n if moderator.visible_until_rejected:\r\n moderated_object.changed_object = instance\r\n else:\r\n moderated_object.changed_object = unchanged_obj\r\n\r\n return moderated_object",
"def newChangeSet(self, **info):\n if self._currentChanges is not None:\n raise UndoManagerError(\"there already is an active change set\")\n self._currentChanges = (info, ChangeSet(), InverseChangeSet())",
"def orig_obj(self):\n return self._orig_obj",
"def changedInBackend(self, obj):\n # Assert that all object modifications have been sent\n assert obj._p_changed is not True, obj._p_changed\n # Make sure we'll refetch the object's new values\n obj._p_deactivate()\n # Invalidate on abort\n self._modified.add(obj._p_oid)",
"def make_immutable(self):\n # just set the flag to make object immutable and hashable\n self.immutable = True",
"def _update_model_instance(self, obj_filter_dict, new_data_dict):\n obj = self._get_or_create_model_instance(obj_filter_dict)\n obj.modify(**new_data_dict)",
"def get_change(self, ):\n return self.get_parameter('change')",
"def get_change(self, repository, revision):\n raise NotImplementedError"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Publisher unique service advertise identifier. Getter only | def advertise_id(self):
return self._advertise_id | [
"def advertisement_id(self):\n return uuid.uuid4()",
"def service_id(self) -> str:\n return pulumi.get(self, \"service_id\")",
"def advertised_id(self):\n namespace = '0x' + self.uuid[:8] + self.uuid[-12:]\n major, minor = map(int, (self.major, self.minor))\n temp_instance = self._append_hex(major, minor)\n instance = self._add_padding(temp_instance)\n beacon_id = self._append_hex(int(namespace, 16), instance)\n return base64.b64encode(self.long_to_bytes(beacon_id))",
"def service_id(self):\n return self._service_id",
"def publisher_id(self):\n return self.data['article']['v880'][0]['_']",
"def service_signal(self, service):\n signal = \"{}_{}_{}\".format(DOMAIN, service, self.unique_id.replace(\".\", \"_\"))\n return signal",
"def get_id(self):\n return \"{0} {1}\".format(self.get_issuer(), self.get_serial_number())",
"def service_id_or_name(self) -> str:\n return self._service_id_or_name",
"def sapd_id(self) -> str:\n return self._sapd_id",
"def adafruit_service_uuid(n: int) -> VendorUUID:\n return VendorUUID(\"ADAF{:04x}-C332-42A8-93BD-25E905756CB8\".format(n))",
"def publisher_id(self) -> Optional[str]:\n return pulumi.get(self, \"publisher_id\")",
"def client_id(self) -> str:",
"def service_tag(self) -> str:\n return pulumi.get(self, \"service_tag\")",
"def DeploymentId(self) -> _n_0_t_0:",
"def get_primary_id(self):",
"def get_service_tag():\n serialfile = '/etc/dxmini_serial'\n if os.path.isfile(serialfile):\n logger.info(\"Reading SERVICE_TAG...\")\n with open(serialfile,\"r\") as fi:\n serial = fi.read()\n return int(serial)\n else:\n serial = \"\".join(str(uuid.uuid4()).split('-')[3:]).upper()\n logger.warn(\"Generating new DXMNI service_tag {}\".format(serial))\n serial = str(int(serial, 16))\n with open(serialfile,\"w\") as fi:\n fi.write(serial)\n fi.close()\n return int(serial)",
"def service_number(self):\n return self._service_number",
"def unique_id(self):\n return _mack_sdr_rossi_swig.Demapper_ATSC_sptr_unique_id(self)",
"def unique_id(self):\n return _mack_sdr_rossi_swig.Bit_interleaver_ATSC_sptr_unique_id(self)"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Publishing latch status. Getter only property | def latch(self):
return self._latch | [
"def get_labware_latch_status(self) -> HeaterShakerLabwareLatchStatus:",
"def power_status(self):\n raise NotImplementedError(\"ERROR: Unimplemented function.\")",
"def notify_status(self):\n return self._notify_status",
"def set_On(self):\n if not(self._locked):\n self.__dict__['statusOn']=True\n self._do_action()\n else:\n self._log.info('The JobProperty %s is blocked', self.__name__)",
"def pollable(self):\n raise NotImplementedError()",
"def lock_status(self):\n return self._lock_status",
"def publish_actuator_status(self, reference):\n state, value = self.actuator_status_provider.get_actuator_status(reference)\n actuator_status = ActuatorStatus.ActuatorStatus(reference, state, value)\n outbound_message = self.outbound_message_factory.make_from_actuator_status(actuator_status)\n if not self.connectivity_service.publish(outbound_message):\n self.outbound_message_queue.put(outbound_message)",
"def ConnectionStatus(self, Status):",
"def _ready(cls):\n sync_call(cls.ready)",
"def get_raw_status(self):\n self.__param_lock.acquire()\n status = self.__status\n self.__param_lock.release()\n return status",
"def lock_status(self):\n self._lock_status = True",
"def latch_interrupt(self, latch='on'):\n\n CTRL_REG5 = self.single_access_read(0x24)\n\n if latch == 'off':\n latchBit = 0b0\n else:\n latchBit = 0b1\n\n CTRL_REG5 = CTRL_REG5 & 0b11110111\n CTRL_REG5 = CTRL_REG5 | (latchBit<<3)\n\n #print (bin(CTRL_REG5)) # for testing\n\n self.single_access_write(0x24, CTRL_REG5)\n\n return",
"def __init__(self):\n self.toggle = False\n\t# Object encapsulation: the publisher node is set to be a private member to prevent \n\t# user from directly accessing it\n self.__pub = rospy.Publisher('toggle_led', Bool, queue_size=10)\n\trospy.loginfo(\"Publisher Setup Completed\")",
"def publish_status(client):\n client.publish(config.topic_get, payload=getlight())",
"def state(self):\n return self.status",
"def set(self):\n with self._cond:\n self._flag = True\n self._cond.notify_all()",
"def publish_actuator_state(self):\n msg = \"ON\" if self.current_state else \"OFF\"\n self._publish(msg, self.comm)",
"def poll(self):\n \n data = self.mon.poll()\n if data:\n res = self.model.decode_monitor(data)\n \"\"\"\n with open('/config/wideq/ref_polled_data.json','w', encoding=\"utf-8\") as dumpfile:\n json.dump(res, dumpfile, ensure_ascii=False, indent=\"\\t\")\n \"\"\"\n return RefStatus(self, res)\n \n else:\n return None",
"def register_status(self):\n return self._register_status"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Getter only property. Returns publishing topic name. | def topic(self):
return self._topic_name | [
"def topic(self) -> str:\n return pulumi.get(self, \"topic\")",
"def pubsub_topic(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"pubsub_topic\")",
"def topicName(self):\n\n return internals.blpapi_Message_topicName(self.__handle)",
"def topic(self):\n return self._topic",
"def topic(self):\n return self.config.get('topic', f'{NAMESPACE}/{self.id}')",
"def topic_full_name(self):\n return self._topic_full_name",
"def get_topic(self):\n return self.topic",
"def pubsub_topic(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"pubsub_topic\")",
"def kafka_topic(self) -> str:\n return self._kafka_topic",
"def response_kafka_topic_name(self) -> str:\n return self._response_kafka_topic_name",
"def get_topic(self, topic):\n return self._get(_topic.Topic, topic)",
"def plugin_topic(self) -> str:\n return self._plugin_topic",
"def thing_name(topic):\n return topic.split(\"/\")[2]",
"def original_topic(self) -> str:\n return self._original_topic",
"def base_topic(self):\n return self._base_topic",
"def publisher_name(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"publisher_name\")",
"def topic_urn(self):\n return self._topic_urn",
"def publisher_name(self):\n return self._publisher_name",
"def partner_topic_name(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"partner_topic_name\")"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Transforms single row of pandas `original_tweets_with_lemmas.p` to graph. Suffixes in node names are needed due to intersection between hashtags and user names. | def _transform_single_row(self, hashtag_agg: Dict, row: pd.Series):
user_name = row["username"] + "_user"
tweet_id = str(row["id"]) + "_tweet"
tags = row["hashtags"]
self._users_labels.add(user_name)
self._tweet_labels.add(tweet_id)
if not self.graph.has_node(user_name):
self.graph.add_node(user_name, type="username")
if not self.graph.has_node(tweet_id):
self.graph.add_node(tweet_id, type="tweet_id")
for hashtag_index in tags:
tag = hashtag_index["text"] + "_tag"
hashtag_agg[tag] += row["lemmas"]
if not self.graph.has_node(tag):
self.graph.add_node(tag, type="hashtag")
if not self.graph.has_edge(tag, user_name):
self.graph.add_edge(tag, user_name)
if not self.graph.has_edge(tag, tweet_id):
self.graph.add_edge(tag, tweet_id)
self._hashtag_labels.add(tag) | [
"def transformation(tweets):\r\n tableau = [[] for i in range(len(tweets))]\r\n for i,tweet in enumerate(tweets):\r\n tableau[i].append(tweet.id)\r\n tableau[i].append(tweet.user.screen_name)\r\n tableau[i].append(tweet.text)\r\n tableau[i].append(tweet.created_at)\r\n tableau[i].append(get_hashtags(tweet))\r\n tableau[i].append(tweet.user.location)\r\n tableau[i].append(tweet.favorite_count)\r\n tableau[i].append(tweet.retweet_count)\r\n tableau[i].append(tweet.user.followers_count)\r\n return pd.DataFrame(tableau,[\"Tweet \"+str(i+1) for i in range(len(tweets))],columns = [\"id\",\"Nom\",\"Text\",\"Date\",\"Hashtag\",\"Location\",\"Like\",\"Retweets\",\"Followers\"])",
"def preprocess_tweets(tweet_df):\n stopwords_set = set(stopwords.words('english'))\n wordnet_lemmatizer = WordNetLemmatizer()\n\n tweet_text_col_name = \"tweet\"\n tweet_df['clean_tweets'] = tweet_df[tweet_text_col_name]\n tweet_df['tweet_len'] = None\n\n exclude_items = ['[^a-zA-Z]', 'rt', 'http', 'RT', 'co']\n exclude = '|'.join(exclude_items)\n\n tweet_df['clean_tweets'].replace(\n to_replace=exclude, value=\" \", regex=True, inplace=True)\n\n def normalize(tweet):\n return ' '.join([wordnet_lemmatizer.lemmatize(\n word) for word in tweet.lower().split()\n if not word in stopwords_set and len(word) > 1])\n\n tweet_df['clean_tweets'] = tweet_df['clean_tweets'].apply(normalize)\n tweet_df['tweet_len'] = tweet_df['clean_tweets'].apply(len)\n\n return tweet_df",
"def load_yang_tweets(data_path):\n human_col_names = ['tweet_id', 'user_id', 'tweet creation time', 'favourited', 'in_reply_to_status_id', 'in_reply_to_user_id', 'in_reply_to_screen_name', 'latitude', 'longitude', 'source', 'retweet', 'truncated', 'text']\n bot_col_names = human_col_names + ['retweet_count', 'hash_tag', 'mention_users']\n yang_humans = get_yang_datafile(data_path + \"NormalData/tweets.txt\", human_col_names)\n yang_bots = get_yang_datafile(data_path + \"MalData/tweets.txt\", bot_col_names)\n human_groups = yang_humans[['text', 'user_id']].groupby(['user_id'])\n human_tweets = human_groups['text'].apply(lambda x: \" \".join(x))\n bot_groups = yang_bots[['text', 'user_id']].groupby(['user_id'])\n bot_tweets = bot_groups['text'].apply(lambda x: \" \".join(x))\n df = pd.concat([human_tweets, bot_tweets], join='inner')\n labels = pd.Series([0]*len(human_tweets) + [1]*len(bot_tweets))\n cv_df = tweets_to_countvectorized_df(df)\n return cv_df, pd.Series(labels)",
"def reset_node_ids(df):\n le = LabelEncoder()\n all_node_names = list(set(df['from_name'].values.tolist() + df['to_name'].values.tolist()))\n le.fit(all_node_names)\n df['from_id'] = le.transform(df['from_name'])\n df['to_id'] = le.transform(df['to_name'])\n return df, le",
"def addToGraph(tid,uid,mentions) :\n global G,found\n\n user = r.get(int(uid))\n \n if user == None :\n return\n\n user = re.findall('\"((?:(?!(?:\",\")).)*)\"', user)\n \n # lower the hashtags\n mentions = [t.lower() for t in mentions if t not in [\"\"]]\n \n usern = user[1].lower()\n\n G.add_node(usern)\n\n found = found + 1\n\n # iterate through mentions\n for m in mentions :\n # add hashtag to graph\n G.add_node(m)\n \n # update edge weight for every hashtag 2-permutation of the tweet\n if G.has_edge(usern,m) :\n G[usern][m]['weight'] += 1\n else :\n G.add_edge(usern,m,weight=1)",
"def get_unlabelled_tweets_reannotation():\n conn = get_connection()\n c = conn.cursor()\n #res = c.execute('SELECT * FROM tweets WHERE tweets.is_about_depression is null AND tweets.username IN (SELECT username FROM users WHERE mentions_depr=1)').fetchall()\n res = c.execute('SELECT * FROM tweets WHERE tweets.is_about_depression IN (0, 1, 2) AND tweets.is_about_depression2 IS NULL ORDER BY random()').fetchall()\n conn.close()\n return np.array(res)",
"def process_raw_tweets(tweets):\n tokenizer = TweetTokenizer(preserve_case=False, strip_handles=True)\n\n def process_raw_tweet(tweet):\n \"\"\"Converts a single tweet into cleaned tokenized form\"\"\"\n bad_words = set(stopwords.words('english')) | set(\n string.punctuation) | {'rt', \"’\", '\"', \"'\"}\n\n # Proved to be more difficult than anticipated, replaced with regex for\n # non_standard_character\n \"\"\"emoji = re.compile(\"[\"\n u\"\\U0001F600-\\U0001F64F\" # emoticons\n u\"\\U0001F300-\\U0001F5FF\" # symbols & pictographs\n u\"\\U0001F900-\\U0001F9FF\" # suplemental symbols & pictographs\n u\"\\U00002600-\\U000026FF\" # miscellaneous Symbols\n u\"\\U00002700-\\U000027BF\" # dingbats\n u\"\\U0001F680-\\U0001F6FF\" # transport & map symbols\n u\"\\U0001F1E0-\\U0001F1FF\" # flags\n \"]+\")\"\"\"\n\n non_standard_character = r'[^\\u0020-\\u02FF]'\n\n url = r'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\\(\\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+'\n\n imagefile = r'(?:([^:/?#]+):)?(?://([^/?#]*))?([^?#]*\\.(?:jpg|gif|png))(?:\\?([^#]*))?(?:#(.*))?'\n\n truncated_word = r'.*…'\n\n bad_word_regexes = [non_standard_character,\n url, imagefile, truncated_word]\n return [token for token in tokenizer.tokenize(tweet) if token not in bad_words and not any(re.match(regex, token) for regex in bad_word_regexes)]\n\n return pd.DataFrame({'tokens': list(map(process_raw_tweet, tweets))})",
"def link_lung_neoplasm(mention):\n\n\t\tneoplasm_mention = mention.text\n\t\tassert 'neoplasm' in neoplasm_mention\n\t\treturn [[neoplasm_mention, 'malignant lung neoplasm']]",
"def clean_tweets(df):\n # First we convert everything from html encoding to unicode\n print('html removal')\n df['tweet'] = [*map(html.unescape, df['tweet'])]\n # Then we save a version of the original tweet before processing\n print('url removal')\n df['original_tweet'] = df['tweet']\n df['tweet'] = [*map(replace_url, df['tweet'])]\n # Remvoe certain characters (as per )\n print('cleaning and extracting mentions/hashtags')\n df['tweet'] = [*map(strip_text, df['tweet'])]\n df['tweet'], df['mentions'], df['hashtags'] = \\\n replace_all_mentions(df['tweet'])\n return df",
"def unigram_matrix_df (tweets): \n unigram = tokenize_unigram(tweets)\n return tweet_term_df(unigram)",
"def label_tweets(comp_name):\n # import company tweets\n fpath = 'C:/AI/eh_CNN_twitter/data/comp_tweets/'\n comp_tweets = pd.read_csv(fpath+comp_name+'.tsv', sep='\\t', encoding = 'utf-8', header=None, error_bad_lines=False)#, nrows = 10) \n comp_tweets_original = comp_tweets.copy(deep= True)\n comp_tweets = comp_tweets.iloc[:,5]\n comp_tweets = [str(s).strip() for s in comp_tweets]\n comp_tweets = [data_helpers_neutrals.clean_str(sent) for sent in comp_tweets]\n comp_tweets = [s.split(\" \") for s in comp_tweets]\n comp_tweets = pad_tweets(comp_tweets)\n print(comp_name, ': cleaned and padded')\n comp_tweets = [[vocabulary[word] for word in tweet] for tweet in comp_tweets]\n y = model.predict(np.array(comp_tweets), batch_size=1) \n print(comp_name, ':prediction done!')\n comp_tweets_labeled = pd.DataFrame(y)\n comp_tweets_labeled = comp_tweets_labeled.rename(columns={0:\"prediction\"})\n comp_tweets_labeled['tweet'] = comp_tweets_original.iloc[:,5]\n comp_tweets_labeled['Date'] = comp_tweets_original.iloc[:,2]\n# comp_tweets_labeled['prediction'] = np.round(comp_tweets_labeled['prediction'], 2)\n comp_tweets_labeled.to_csv(fpath+comp_name+'_labeled'+'.tsv', sep='\\t', encoding='utf-8')\n return comp_tweets_labeled",
"def process_tweets (corpus,emotion):\n data=[]\n labels=[]\n for tweet in corpus:\n if tweet['emotion']==emotion:\n try:\n data.append(tweet['text'].decode('utf-8'))\n labels.append(emotion)\n except UnicodeEncodeError:\n continue\n return data,labels",
"def parse_for_adj(df, column, new_column_name):\n prop_noun_parse = []\n for i in range(len(df[column])):\n non_PN = []\n blob = nlp(unicode(df[column][i]))\n for each in blob:\n if each.tag_ in [u'JJ', u'JJR', u'JJS', u'VBZ', u'VBG', u'RB', u'RBR', u'RBS']:\n non_PN.append(str(each))\n prop_noun_parse.append((df['reviewid'][i], \" \".join(non_PN)))\n\n df_new = pd.DataFrame(prop_noun_parse, columns =['reviewid', new_column_name])\n return df.merge(df_new)",
"def draw_was_retweeted_graph():\n grouped_tweets = _group_retweeted_tweets(_get_retweeted_hashtags())\n \n graph.create_boxplot_from_arrays(grouped_tweets['yes'], grouped_tweets['no'], ['Yes', 'No'], xlabel='Retweeted?', ylabel='Hashtags', title='Retweeted vs Hashtags')",
"def simplify_directed_as_dataframe(df: gpd.GeoDataFrame) -> gpd.GeoDataFrame:\n df.reset_index(inplace=True)\n\n g = gt.Graph(directed=True)\n osm_id = g.new_edge_property('string')\n highway = g.new_edge_property('string')\n level = g.new_edge_property('int')\n lanes = g.new_edge_property('int')\n width = g.new_edge_property('float')\n bicycle = g.new_edge_property('bool')\n bicycle_safety = g.new_edge_property('int')\n foot = g.new_edge_property('bool')\n foot_safety = g.new_edge_property('int')\n max_speed = g.new_edge_property('int')\n motorcar = g.new_edge_property('bool')\n linestring = g.new_edge_property('python::object')\n\n edgelist = df[\n ['u', 'v', 'osm_id', 'highway', 'level', 'lanes', 'width', 'bicycle', 'bicycle_safety', 'foot', 'foot_safety',\n 'max_speed', 'motorcar', 'geometry']].values\n\n nodes_id = g.add_edge_list(edgelist, hashed=True,\n eprops=[osm_id, highway, level, lanes, width, bicycle, bicycle_safety, foot, foot_safety,\n max_speed, motorcar, linestring])\n\n # we are gonna replace the original repeated nodes with a linestring\n e_path = g.new_ep('vector<int64_t>')\n for e in g.edges():\n e_path[e] = []\n\n vs = g.get_vertices()\n in_out_deg_2 = (g.get_in_degrees(vs) == 2) & (g.get_out_degrees(vs) == 2)\n\n logging.debug('selecting degree 4 candidates')\n candidates = set()\n for i, v in enumerate(vs):\n if in_out_deg_2[i]:\n ns = list(set(g.get_all_neighbors(v)))\n if len(ns) == 2:\n u, w = ns[0], ns[1]\n uv, vw, wv, vu = g.edge(u, v), g.edge(v, w), g.edge(w, v), g.edge(v, u)\n if highway[uv] == highway[vw] and highway[wv] == highway[vu]:\n candidates.add(v)\n logging.debug('found {} degree 4 candidates to simplify'.format(len(candidates)))\n\n seen = set()\n unregister_candidates = set()\n\n for i, candidate in enumerate(candidates):\n if i == 100000:\n logging.debug('100000 degree 4 candidates')\n if candidate in seen:\n continue\n\n seen.add(candidate)\n\n u, w = g.get_out_neighbors(candidate)\n is_u_fringe, is_w_fringe = u not in candidates, w not in candidates\n\n cu, cw = g.edge(candidate, u), g.edge(candidate, w)\n\n us = []\n ws = []\n\n while not is_u_fringe:\n seen.add(u)\n us.append(u)\n neighbors = set(g.get_out_neighbors(u))\n neighbors -= seen\n if len(neighbors) > 0:\n u = neighbors.pop()\n is_u_fringe = u not in candidates\n elif u == w:\n us.pop(-1)\n u = us.pop(-1)\n unregister_candidates.add(u)\n unregister_candidates.add(w)\n is_u_fringe = True\n is_w_fringe = True\n g.remove_edge(g.edge(s=u, t=w))\n g.remove_edge(g.edge(s=w, t=u))\n else:\n logging.debug('degree 2: we got here somehow {} {} {} {}', candidate, u, v,\n g.get_all_neighbors(candidate))\n break\n\n while not is_w_fringe:\n seen.add(w)\n ws.append(w)\n neighbors = set(g.get_out_neighbors(w))\n neighbors -= seen\n if len(neighbors) > 0:\n w = neighbors.pop()\n is_w_fringe = w not in candidates\n else:\n logging.debug('degree 2: we got here somehow {} {} {} {}', candidate, u, v,\n g.get_all_neighbors(candidate))\n break\n\n if is_u_fringe and is_w_fringe:\n e = g.add_edge(source=u, target=w)\n path = [u] + list(reversed(us)) + [candidate] + ws + [w]\n e_path[e] = [int(nodes_id[node]) for node in path]\n linestrings = [linestring[g.edge(a, b)] for a, b in pairwise(path)]\n linestring[e] = join_linestrings(linestrings)\n osm_id[e], highway[e], level[e], lanes[e], width[e], bicycle[e], bicycle_safety[e], foot[e], foot_safety[e], \\\n max_speed[e], motorcar[e] = osm_id[cw], highway[cw], level[cw], lanes[cw], width[cw], bicycle[cw], \\\n bicycle_safety[cw], \\\n foot[cw], foot_safety[cw], max_speed[cw], motorcar[cw]\n\n e = g.add_edge(source=w, target=u)\n path = [w] + list(reversed(ws)) + [candidate] + us + [u]\n e_path[e] = [int(nodes_id[node]) for node in path]\n linestrings = [linestring[g.edge(a, b)] for a, b in pairwise(path)]\n linestring[e] = join_linestrings(linestrings)\n osm_id[e], highway[e], level[e], lanes[e], width[e], bicycle[e], bicycle_safety[e], foot[e], foot_safety[e], \\\n max_speed[e], motorcar[e] = osm_id[cu], highway[cu], level[cu], lanes[cu], width[cu], bicycle[cu], \\\n bicycle_safety[cu], \\\n foot[cu], foot_safety[cu], max_speed[cu], motorcar[cu]\n\n else:\n logging.debug(\n 'unexpected behavior, source={0}, target={1}, candidate={2}, us={3}, ws={4}'.format(u, w, candidate, us,\n ws))\n\n unseen = candidates - seen\n if len(unseen) > 0:\n logging.debug(\n 'Network scan after degree 4 simplification uncomplete: candidates {0} have not been examined'.format(\n unseen))\n\n candidates -= unregister_candidates\n g.remove_vertex(list(candidates))\n\n vs = g.get_vertices()\n in_out_deg_1 = (g.get_in_degrees(vs) == 1) & (g.get_out_degrees(vs) == 1)\n\n logging.debug('selecting degree 2 candidates')\n candidates = set()\n for i, v in enumerate(vs):\n if in_out_deg_1[i]:\n u = g.get_in_neighbors(v)[0]\n w = g.get_out_neighbors(v)[0]\n\n if u != w:\n uv, vw = g.edge(u, v), g.edge(v, w)\n if highway[uv] == highway[vw]:\n candidates.add(v)\n logging.debug('found {} degree 2 candidates to simplify'.format(len(candidates)))\n\n seen = set()\n unregister_candidates = set()\n\n for candidate in candidates:\n if candidate in seen:\n continue\n\n seen.add(candidate)\n\n u = g.get_in_neighbors(candidate)[0]\n w = g.get_out_neighbors(candidate)[0]\n\n uc = g.edge(u, candidate)\n\n is_u_fringe, is_w_fringe = u not in candidates, w not in candidates\n\n us = []\n ws = []\n\n while not is_u_fringe:\n seen.add(u)\n us.append(u)\n neighbors = set(g.get_in_neighbors(u))\n neighbors -= seen\n if len(neighbors) > 0:\n u = neighbors.pop()\n is_u_fringe = u not in candidates\n elif u == w:\n us.pop(-1)\n u = us.pop(-1)\n unregister_candidates.add(u)\n unregister_candidates.add(w)\n is_u_fringe = True\n is_w_fringe = True\n g.remove_edge(g.edge(s=w, t=u))\n else:\n logging.debug('degree 1: we got here somehow {} {} {} {}', candidate, u, v,\n g.get_all_neighbors(candidate))\n break\n\n while not is_w_fringe:\n seen.add(w)\n ws.append(w)\n neighbors = set(g.get_out_neighbors(w))\n neighbors -= seen\n if len(neighbors) > 0:\n w = neighbors.pop()\n is_w_fringe = w not in candidates\n else:\n logging.debug('degree 1: we got here somehow {} {} {} {}', candidate, u, v,\n g.get_all_neighbors(candidate))\n break\n\n if is_u_fringe and is_w_fringe:\n e = g.add_edge(source=u, target=w)\n path = [u] + list(reversed(us)) + [candidate] + ws + [w]\n e_path[e] = [int(nodes_id[node]) for node in path]\n linestrings = [linestring[g.edge(a, b)] for a, b in pairwise(path)]\n linestring[e] = join_linestrings(linestrings)\n osm_id[e], highway[e], level[e], lanes[e], width[e], bicycle[e], bicycle_safety[e], foot[e], foot_safety[e], \\\n max_speed[e], motorcar[e] = osm_id[uc], highway[uc], level[uc], lanes[uc], width[uc], bicycle[uc], \\\n bicycle_safety[uc], \\\n foot[uc], foot_safety[uc], max_speed[uc], motorcar[uc]\n else:\n logging.error('unexpected behavior, source={0}, target={1}, candidate={2}, us={3}, ws={4}', u, w, us, ws)\n\n unseen = candidates - seen\n if len(unseen) > 0:\n logging.debug(\n 'Network scan after degree 2 simplification not finished: candidates {0} have not been examined'.format(\n unseen))\n\n candidates -= unregister_candidates\n g.remove_vertex(list(candidates))\n\n logging.debug(' linestring path')\n edges_tuples = []\n for e in g.edges():\n source, target, path = nodes_id[e.source()], nodes_id[e.target()], e_path[e]\n if len(path) == 0:\n path = [source, target]\n else:\n path = [int(i) for i in path]\n\n e_tuples = (g.edge_index[e], source, target, path,\n osm_id[e], highway[e], level[e], lanes[e], width[e], bicycle[e], bicycle_safety[e], foot[e],\n foot_safety[e], max_speed[e], motorcar[e], linestring[e])\n edges_tuples.append(e_tuples)\n\n df_edges_simplified = pd.DataFrame.from_records(edges_tuples, index='edge_id',\n columns=['edge_id', 'u', 'v', 'path', 'osm_id', 'highway',\n 'level', 'lanes', 'width', 'bicycle', 'bicycle_safety',\n 'foot', 'foot_safety', 'max_speed', 'motorcar',\n 'geometry'])\n\n df_edges_simplified.osm_id = df_edges_simplified.osm_id.str.split('-').str[0]\n df_edges_simplified = gpd.GeoDataFrame(df_edges_simplified, geometry='geometry')\n df_edges_simplified.crs = df.crs\n return df_edges_simplified",
"def create_lemma_graph(segments):\r\n segments = lemmatize(segments)\r\n g = create_naive_graph(segments)\r\n return g",
"def lemmatization(tweet):\n # https://stackoverflow.com/questions/15586721/wordnet-lemmatization-and-pos-tagging-in-python\n # could do a thing where I figure out if n v a beforehand and check. see ref\n print(\"Beginning lemmatization\")\n wnl = WNL()\n\n tweet\n\n try: \n tokenized_sentence = word_tokenize(tweet)\n pos_tag_sentence = pos_tag(tokenized_sentence)\n\n new_sentence = []\n\n for i in pos_tag_sentence:\n tag = get_wordnet_pos(i[1])\n\n # words like to and and don't need to be lemmatized and return \"\"\n if tag != \"\":\n word = wnl.lemmatize(i[0], tag)\n new_sentence.append(word)\n # and to, and, and other words\n else:\n new_sentence.append(i[0])\n \n new_sentence = \" \".join(new_sentence)\n print(new_sentence,\"\\n\")\n\n except Exception as e:\n print(\"Error: {0}\".format(e))",
"def transform(tweets):\n\n for tweet in tweets:\n tweet['sentiment_score'] = s.polarity_scores(tweet['text'])['compound']\n return tweets # updated tweets list",
"def flatten_row(row):\n # [u'hop_survey.node_id', u'hop_survey.created', u'hop_survey',\n # u'case.node_id', u'case',\n # u'experiment.node_id', u'experiment',\n # u'project.node_id', u'project',\n # u'program.node_id', u'program']\n label_created_col_name = [k for k in row.keys() if 'created' in k][0]\n label_object_col_name = label_created_col_name.split('.')[0]\n label_node_id_col_name = '{}.node_id'.format(label_object_col_name)\n\n flattened = row[label_object_col_name]\n flattened['_created'] = row[label_created_col_name]\n flattened['_node_id'] = row[label_node_id_col_name]\n\n path_members = [k for k in row.keys() if 'node_id' not in k and label_object_col_name not in k]\n for path_member in path_members:\n for k in row[path_member]:\n flattened['{}_{}'.format(path_member, k)] = row[path_member][k]\n flattened['{}_{}'.format(path_member, 'node_id')] = row['{}.node_id'.format(path_member)]\n\n return flattened"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates sparse matrix of preference vectors for each of N samples to recommend which are used to initialize random walk algorithm. If a query hashtag for a particular tweet is given, then it is used to create preference vector. The most similar hashtag is used otherwise. | def _get_preference_vectors(self, tweet_content_similarities: np.ndarray,
query_hashtags: Optional[Tuple[str]]) -> sps.csr_matrix:
def _get_using_similarities(similarity_vector):
query_hashtag_index = np.argmax(similarity_vector)
vec = np.zeros((len(self._hashtag_labels),))
vec[query_hashtag_index] = 1
return vec
preference_vectors = []
for i in range(len(tweet_content_similarities)):
if query_hashtags is None or query_hashtags[i] is None:
preference_vector = _get_using_similarities(tweet_content_similarities[i])
else:
try:
preference_vector = np.asarray(self._hashtag_encoder.transform([query_hashtags[i]]))[0]
except ValueError:
warnings.warn(
"Unknown hashtag: {}. Using the closest hashtag in terms of content similarity".format(
query_hashtags[i]))
preference_vector = _get_using_similarities(tweet_content_similarities[i])
preference_vectors.append(preference_vector)
preference_vectors = np.vstack(preference_vectors)
preference_vectors = sps.csr_matrix(preference_vectors, preference_vectors.shape, dtype=np.float32)
return preference_vectors | [
"def tweet_term (tweets) : \n\n indptr = [0]\n indices = []\n data = []\n vocabulary = {}\n for value in tweets:\n for term in value :\n index = vocabulary.setdefault(term, len(vocabulary))\n indices.append(index)\n data.append(1)\n indptr.append(len(indices))\n \n return csr_matrix((data, indices, indptr), dtype=int)",
"def unigram_matrix_df (tweets): \n unigram = tokenize_unigram(tweets)\n return tweet_term_df(unigram)",
"def _initialize(self):\n for doc_index, doc in enumerate(self.document):\n temp_word_topic_matrix = []\n for word in doc:\n if word in self.word2id.keys():\n start_topic_index = np.random.randint(0, self.K)\n temp_word_topic_matrix.append(start_topic_index)\n self.doc_topic_matrix[doc_index, start_topic_index] += 1\n self.topic_word_matrix[start_topic_index, self.word2id[word]] += 1\n self.topic_matrix[start_topic_index] += 1\n self.current_word_topic_matrix.append(temp_word_topic_matrix)",
"def featurize(movies):\n ###TODO\n \n #print(movies[:5]) \n \n #step 1 -> build a vocab and df(term)\n vocab = {}\n vocab_list = []\n df = {}\n \n for row1 in movies['tokens']:\n row = list(set(row1))\n for term in row:\n if term not in vocab.keys():\n vocab.setdefault(term,-1)\n \n if term not in df.keys(): \n df.setdefault(term,1)\n else :\n df[term] += 1\n \n \n #print('vocab = ', vocab)\n \n vocab_list = sorted(vocab.keys(), key = lambda x:x)\n #print('vocab_list = ', vocab_list)\n \n for i,term in enumerate(vocab_list):\n vocab[term] = i\n \n #print('Sorted vocab = ', sorted(vocab.items()))\n #print('df = ',sorted(df.items(), key=lambda x:x[0]))\n \n # step 2 -> Build a csr_matrix for each row of movies['tokens']\n N = len(movies)\n #print('N = ',N)\n \n #[comedy, comedy, comedy, horror] -> max_k tf(k, d) = 3 \n #[action, comedy,thriller] -> tf(action, d) =1\n # df(i) ->\n #num_features is the total number of unique features across all documents.\n \n csr_array =[]\n \n for row1 in movies['tokens']:\n csr_row = []\n csr_col = []\n csr_data = []\n max_k = 0\n \n max_k = Counter(row1).most_common()[:1][0][1]\n row = list(set(row1))\n\n #print('removed duplicates =',row)\n for term in row: \n csr_row.append(0)\n csr_col.append(vocab[term])\n #tfidf(i, d) := tf(i, d) / max_k tf(k, d) * log10(N/df(i))\n tf = Counter(row1)[term]\n #max_k = max_k.most_common()[:1][0][1]\n \n #print('term = %s ---> tf = %d ---> max_k = %d'%(term,tf,max_k))\n tfidf = (tf / max_k) * math.log10(N/df[term])\n csr_data.append(tfidf)\n \n \n #print('csr_row = ',csr_row) \n #print('csr_col = ',csr_col)\n #print('csr_data=',csr_data)\n X = csr_matrix((csr_data, (csr_row, csr_col)), shape=(1, len(vocab)), dtype=np.float128)\n \n #print('X ->\\n',X.toarray())\n csr_array.append(X)\n \n\n # step 3 -> add column features to movies \n #print('size of csr_array = ',len(csr_array)) \n #print('CSR = ',csr_array[:2]) \n new_movies = movies.assign(features = csr_array)\n #print(new_movies.head(2))\n \n return(new_movies,vocab) \n \n pass",
"def prepare_sampling(num_words, frequent_words, indexes):\n index_table = []\n table_size = len(frequent_words)\n prob = []\n words_list = []\n total_frequences = sum([i**(3/4) for i in list(frequent_words.values())])\n for word in frequent_words:\n proba = frequent_words[word]**(3/4)/total_frequences\n prob.append(proba*table_size)\n index_table += [indexes[word] for i in range(int(proba)+2)]\n return index_table",
"def __init__(self, n, sents, corpus='', gamma=None, addone=True):\n self.n = n\n self.smoothingtechnique = 'Interpolated (Jelinek Mercer) Smoothing'\n self.gamma = gamma\n self.addone = addone\n self.counts = counts = defaultdict(int)\n self.gamma_flag = True\n self.corpus = corpus\n # way more efficient than use set unions\n voc = ['</s>']\n for s in sents:\n voc += s\n self.voc = list(set(voc))\n\n if gamma is None:\n self.gamma_flag = False\n\n # if not gamma given\n if not self.gamma_flag:\n total_sents = len(sents)\n aux = int(total_sents * 90 / 100)\n # 90 per cent for training\n train_sents = sents[:aux]\n # 10 per cent for perplexity (held out data)\n held_out_sents = sents[-total_sents+aux:]\n\n train_sents = list(map((lambda x: ['<s>']*(n-1) + x), train_sents))\n train_sents = list(map((lambda x: x + ['</s>']), train_sents))\n\n for sent in train_sents:\n for j in range(n+1):\n # move along the sent saving all its j-grams\n for i in range(n-j, len(sent) - j + 1):\n ngram = tuple(sent[i: i + j])\n counts[ngram] += 1\n # added by hand\n counts[('</s>',)] = len(train_sents)\n # variable only for tests\n self.tocounts = counts\n # search the gamma that gives lower perplexity\n gamma_candidates = [i*50 for i in range(1, 15)]\n # xs is a list with (gamma, perplexity)\n xs = []\n sents = train_sents\n for aux_gamma in gamma_candidates:\n self.gamma = aux_gamma\n aux_perx = self.perplexity(held_out_sents)\n xs.append((aux_gamma, aux_perx))\n xs.sort(key=lambda x: x[1])\n self.gamma = xs[0][0]\n with open('old-stuff/interpolated_' + str(n) + '_parameters_'+corpus, 'a') as f:\n f.write('Order: {}\\n'.format(self.n))\n f.write('Gamma: {}\\n'.format(self.gamma))\n f.write('AddOne: {}\\n'.format(self.addone))\n f.write('Perplexity observed: {}\\n'.format(xs[0][1]))\n f.write('-------------------------------\\n')\n f.close()\n\n else:\n sents = list(map((lambda x: ['<s>']*(n-1) + x), sents))\n sents = list(map((lambda x: x + ['</s>']), sents))\n\n for sent in sents:\n # counts now holds all k-grams for 0 < k < n + 1\n for j in range(n+1):\n # move along the sent saving all its j-grams\n for i in range(n-j, len(sent) - j + 1):\n ngram = tuple(sent[i: i + j])\n counts[ngram] += 1\n # added by hand\n counts[('</s>',)] = len(sents)",
"def initialise(self):\n sampling_size = 0\n word_counter = {}\n\n for sentence in self.sentences:\n for word in sentence:\n sampling_size += len(sentence)\n word_counter[word] = word_counter.get(word, 0) + 1\n\n true_word_counter = {}\n for word, counter in word_counter.items():\n if counter >= self.minCount:\n self.w2id.setdefault(word, len(self.w2id))\n true_word_counter[self.w2id[word]] = counter\n self.train_set.append(word)\n\n print(f'Number words removed : {len(word_counter) - len(true_word_counter)} on '\n f'{len(word_counter)} words')\n\n nb_unique_words = len(true_word_counter)\n unique_words_idx = list(range(nb_unique_words))\n\n occ = np.array(list(map(lambda w: true_word_counter[w]**self.alpha, unique_words_idx)))\n prob = occ / np.sum(occ)\n self.sampling_matrix = np.random.choice(unique_words_idx,\n size=(sampling_size, self.negativeRate),\n p=prob)\n self.sampling_idx = 0\n\n self.W = np.random.uniform(-1, 1, (nb_unique_words, self.nEmbed))\n self.C = np.random.uniform(-1, 1, (nb_unique_words, self.nEmbed))\n\n if self.mode_OOV:\n full_vocab = self.train_set.copy() # will store words + subwords\n\n # get subwords\n for word in self.train_set:\n word_and_subs = list() # store list of subwords for each word\n word_and_subs.append(word)\n for idx in range(len(word)):\n if (idx + self.n_gram) <= len(word):\n subword = word[idx:(idx + self.n_gram)]\n word_and_subs.append(subword)\n if subword not in full_vocab:\n full_vocab.append(subword) # append to full vocab\n\n # index here are the same as in trainset\n self.words_and_their_ngrams.append(word_and_subs)\n\n N = len(self.train_set)\n N_full = len(full_vocab)\n\n # indexing for W matrice\n self.n_gram_w2id = {w: idx for (idx, w) in enumerate(full_vocab)}\n\n # W includes words and subwords\n self.W = np.random.uniform(-1, 1, (N_full, self.nEmbed))\n # C only includes words\n self.C = np.random.uniform(-1, 1, (N, self.nEmbed))",
"def get_features_train(tweets):\n feats = get_feature_array(tweets)\n tfidf = vectorizer.fit_transform(tweets).toarray()\n M = np.concatenate([tfidf,feats],axis=1)\n return M",
"def construct_matrix(doc_matrix, reviews, num_sent, num_topics):\n\n\t# Create a dictionary of all the topic frequencies\n\ttopic_freq = dict()\n\tfor i in range(0, num_topics):\n\t\ttopic_freq[i] = 0\n\n\t# Construct an empty matrix\n\tfreq_matrix = np.zeros((num_topics, num_topics), dtype=float)\n\n\t# Append values to the matrix\n\tline_no = 0\n\n\t# Iterate over all the sentences - 1\n\tfor i in range(num_sent - 1):\n\n\t\ttry:\n\t\t\tif reviews[i] == reviews[i + 1]:\n\n\t\t\t\t# Create a dictionary of all the probabilities for the two sentences\n\t\t\t\ttopic_dict = [dict(), dict()]\n\t\t\t\tfor j in range(0, num_topics):\n\t\t\t\t\ttopic_dict[0][j] = ast.literal_eval(doc_matrix[i][j])\n\t\t\t\t\ttopic_dict[1][j] = ast.literal_eval(doc_matrix[i + 1][j])\n\n\t\t\t\t# Sort the topics versus the probabilities\n\t\t\t\tsorted_topic_dict = [sorted(topic_dict[0].items(), \\\n\t\t\t\t\tkey=operator.itemgetter(1), reverse=True), \\\n\t\t\t\t\t\tsorted(topic_dict[1].items(), \\\n\t\t\t\t\t\tkey=operator.itemgetter(1), reverse=True)]\n\n\t\t\t\t# Choose the top few topics (ie. till their probabilities add up to one-third)\n\t\t\t\tprob_uptill = [0.0, 0.0]\n\t\t\t\ttmp = [[], []]\n\t\t\t\tfor j in range(num_topics):\n\n\t\t\t\t\t# Threshold\n\t\t\t\t\tif prob_uptill[0] < 0.9:\n\n\t\t\t\t\t\t# Keep track of total probability\n\t\t\t\t\t\tprob_uptill[0] += sorted_topic_dict[0][j][1]\n\n\t\t\t\t\t\t# Save topic chosen\n\t\t\t\t\t\ttmp[0] += [sorted_topic_dict[0][j][0]]\n\n\t\t\t\t\t# Threshold\n\t\t\t\t\tif prob_uptill[1] < 0.9:\n\n\t\t\t\t\t\t# Keep track of total probability\n\t\t\t\t\t\tprob_uptill[1] += sorted_topic_dict[1][j][1]\n\n\t\t\t\t\t\t# Save topic chosen\n\t\t\t\t\t\ttmp[1] += [sorted_topic_dict[1][j][0]]\n\n\t\t\t\tfor x in tmp[0]:\n\t\t\t\t\tfor y in tmp[1]:\n\t\t\t\t\t\tfreq_matrix[x][y] += 1.0\n\t\t\t\t\t\ttopic_freq[x] += 1.0\n\t\texcept:\n\t\t\tprint('Review not found')\n\n\treturn freq_matrix, topic_freq",
"def get_hashtag_df(document,n):\n doc_vocab = pd.DataFrame(token_tuple(document),columns=['Words','Count'])\n topwords = pd.DataFrame(topn(document,n),columns=['Words','Count'])['Words'].tolist()\n #topwords_count = pd.DataFrame(topn(texts['doc1'],5),columns=['Words','Count'])['Count'].tolist()\n\n print ('building dataframe of hashtags...')\n checkwords = pd.DataFrame(token_tuple(document),columns=['Word','Count'])['Word'][n:].tolist()\n combo_topwords = pd.DataFrame([(topwords[i],most_similar(nlp.vocab[topwords[i]])) for i in range(len(topwords))],columns=['baseword','compword'])\n combo_topwords['Count'] = pd.DataFrame(topn(document,n),columns=['Words','Count'])['Count'].tolist()\n combo_topwords['multiword'] =[combo_topwords['compword'].tolist()[i] in checkwords for i in range(len(combo_topwords))]\n combo_topwords['compword_count'] = pd.Series([doc_vocab[doc_vocab['Words'] == combo_topwords['compword'].tolist()[i]]['Count'].values for i in range(len(combo_topwords))]).map(lambda x:x[0] if len(x) > 0 else 0)\n combo_topwords['total_count'] = combo_topwords['Count'].astype(int) + combo_topwords['compword_count'].astype(int)\n combo_topwords = combo_topwords.sort_values(by='total_count',ascending=False)\n return (combo_topwords)",
"def bigram_matrix_df (tweets):\n bigram = tokenize_bigram(tweets)\n return tweet_term_df(bigram)",
"def __init__(self, n, sents, corpus='', beta=None, addone=True):\n self.n = n\n self.beta = beta\n self.corpus = corpus\n self.beta_flag = True\n self.addone = addone\n self.smoothingtechnique = 'Back Off (Katz) with Discounting Smoothing'\n self.counts = counts = defaultdict(int)\n self.A_set = defaultdict(set)\n voc = ['</s>']\n for s in sents:\n voc += s\n self.voc = set(voc)\n if beta is None:\n self.beta_flag = False\n\n # if no beta given, we compute it\n if not self.beta_flag:\n total_sents = len(sents)\n aux = int(total_sents * 90 / 100)\n # 90 per cent por training\n train_sents = sents[:aux]\n # 10 per cent for perplexity (held out data)\n held_out_sents = sents[-total_sents+aux:]\n\n train_sents = list(map((lambda x: ['<s>']*(n-1) + x), train_sents))\n train_sents = list(map((lambda x: x + ['</s>']), train_sents))\n for sent in train_sents:\n for j in range(n+1):\n for i in range(n-j, len(sent) - j + 1):\n ngram = tuple(sent[i: i + j])\n counts[ngram] += 1\n # for efficiency, we save the A set as a dict of sets\n if j:\n self.A_set[ngram[:-1]].add(ngram[-1])\n for i in range(1, n):\n counts[('<s>',)*i] += len(train_sents)\n counts[('</s>',)] = len(train_sents)\n\n self.tocounts = counts\n # search for the beta that gives lower perplexity\n beta_candidates = [i*0.1 for i in range(1, 10)]\n # xs is a list with (beta, perplexity)\n xs = []\n self.sents = train_sents\n for aux_beta in beta_candidates:\n self.beta = aux_beta\n aux_perx = self.perplexity(held_out_sents)\n xs.append((aux_beta, aux_perx))\n xs.sort(key=lambda x: x[1])\n self.beta = xs[0][0]\n with open('old-stuff/backoff_'+str(n)+'_parameters_'+corpus, 'a') as f:\n f.write('Order: {}\\n'.format(self.n))\n f.write('Beta: {}\\n'.format(self.beta))\n f.write('AddOne: {}\\n'.format(self.addone))\n f.write('Perplexity observed: {}\\n'.format(xs[0][1]))\n f.write('-------------------------------\\n')\n f.close()\n else:\n sents = list(map((lambda x: x + ['</s>']), sents))\n sents = list(map((lambda x: ['<s>']*(n-1) + x), sents))\n\n for sent in sents:\n for j in range(n+1):\n for i in range(n-j, len(sent) - j + 1):\n ngram = tuple(sent[i: i + j])\n counts[ngram] += 1\n # for efficiency, we save the A set as a dict of sets\n if j:\n self.A_set[ngram[:-1]].add(ngram[-1])\n for i in range(1, n):\n counts[('<s>',)*i] += len(sents)\n counts[('</s>',)] = len(sents)",
"def process_data_for_pseudolabel(random_seed=10191994, num_samples=1000):\n tmp_df = select_random_reviews(random_seed, num_samples)\n\n tmp_df = tmp_df[tmp_df[\"review_id\"].apply(\n lambda x: x not in handlabeled_set)].reset_index(\n ).drop(\"index\", axis=1)\n\n # I think without the drop here, when producing the feature\n # matrix, because it takes into account index when doing\n # parallel processing, it will create the full number of \n # indices and replace missing ones with NA rows... or something...\n \n feature_matrix_n = produce_feature_matrix(tmp_df[[\"text\"]])\n feature_matrix_n = feature_matrix_n.fillna(0)\n new_X_train_func = feature_matrix_n.iloc[:, 1:]\n\n return tmp_df, feature_matrix_n, new_X_train_func",
"def unigram_evaluation(lines):\n\n random.shuffle(lines)\n\n hashtag_list = PatternsFeatures().get_most_frequent_pattern(PatternsFeatures().pattern_classifier(lines, '#'))\n name_list = PatternsFeatures().get_most_frequent_pattern(PatternsFeatures().pattern_classifier(lines, '@'))\n train_set_rate = int(len(lines)*0.75)\n train_set, test_set = lines[:train_set_rate], lines[train_set_rate:]\n all_tweets = [\" \".join(line[1]) for line in train_set]\n\n tfidf_accuracy_list_nb = []\n tfidf_f_measure_list_nb = []\n tfidf_accuracy_list_svm = []\n tfidf_f_measure_list_svm = []\n tfidf_accuracy_list_maxent = []\n tfidf_f_measure_list_maxent = []\n\n\n fd_accuracy_list_nb = []\n fd_f_measure_list_nb = []\n fd_accuracy_list_svm = []\n fd_f_measure_list_svm = []\n fd_accuracy_list_maxent = []\n fd_f_measure_list_maxent = []\n\n for i in range(10, 200, 20):\n\n unigram_tfdf_ftr = FeatureExtraction(i)\n unigram_fd_ftr = FeatureExtraction(i)\n\n unigram_tfdf_ftr.tf_idf_features(all_tweets, n_grams=1)\n unigram_fd_ftr.most_frequent_unigrams(\" \".join(all_tweets))\n\n for hashtag in hashtag_list:\n unigram_tfdf_ftr.set_unigram_features_list(hashtag)\n unigram_fd_ftr.set_unigram_features_list(hashtag)\n\n for name in name_list:\n unigram_tfdf_ftr.set_unigram_features_list(name)\n unigram_fd_ftr.set_unigram_features_list(name)\n\n tfidf_unigram_featuresets_test = [(unigram_tfdf_ftr.unigram_features(line[1]), line[0]) for line in test_set]\n tfidf_unigram_featuresets_train = [(unigram_tfdf_ftr.unigram_features(line[1]), line[0]) for line in train_set]\n\n fd_unigram_featuresets_test = [(unigram_fd_ftr.unigram_features(line[1]), line[0]) for line in test_set]\n fd_unigram_featuresets_train = [(unigram_fd_ftr.unigram_features(line[1]), line[0]) for line in train_set]\n\n\n###############################################################################################\n\n classifier1 = NaiveBayesClassifier.train(tfidf_unigram_featuresets_train)\n classifier2 = MaxentClassifier.train(tfidf_unigram_featuresets_train)\n classifier3 = nltk.classify.SklearnClassifier(LinearSVC())\n classifier3.train(tfidf_unigram_featuresets_train)\n\n\n\n refsets = collections.defaultdict(set)\n testsets1 = collections.defaultdict(set)\n testsets2 = collections.defaultdict(set)\n testsets3 = collections.defaultdict(set)\n\n for i, (feats, label) in enumerate(tfidf_unigram_featuresets_test):\n refsets[label].add(i)\n observed1 = classifier1.classify(feats)\n observed2 = classifier2.classify(feats)\n observed3 = classifier3.classify(feats)\n testsets1[observed1].add(i)\n testsets2[observed2].add(i)\n testsets3[observed3].add(i)\n\n tfidf_accuracy_list_nb.append(nltk.classify.accuracy(classifier1, tfidf_unigram_featuresets_test))\n tfidf_f_measure_list_nb.append(nltk.metrics.f_measure(refsets['not'], testsets1['not']))\n tfidf_accuracy_list_svm.append(nltk.classify.accuracy(classifier3, tfidf_unigram_featuresets_test))\n tfidf_f_measure_list_svm.append(nltk.metrics.f_measure(refsets['not'], testsets3['not']))\n tfidf_accuracy_list_maxent.append(nltk.classify.accuracy(classifier2, tfidf_unigram_featuresets_test))\n tfidf_f_measure_list_maxent.append(nltk.metrics.f_measure(refsets['not'], testsets2['not']))\n\n#########################################################################################################################\n\n\n\n classifier1 = NaiveBayesClassifier.train(tfidf_unigram_featuresets_train)\n classifier2 = MaxentClassifier.train(fd_unigram_featuresets_train)\n classifier3 = nltk.classify.SklearnClassifier(LinearSVC())\n classifier3.train(fd_unigram_featuresets_train)\n\n\n refsets = collections.defaultdict(set)\n testsets1 = collections.defaultdict(set)\n testsets2 = collections.defaultdict(set)\n testsets3 = collections.defaultdict(set)\n\n for i, (feats, label) in enumerate(fd_unigram_featuresets_test):\n refsets[label].add(i)\n observed1 = classifier1.classify(feats)\n observed2 = classifier2.classify(feats)\n observed3 = classifier3.classify(feats)\n testsets1[observed1].add(i)\n testsets2[observed2].add(i)\n testsets3[observed3].add(i)\n\n fd_accuracy_list_nb.append(nltk.classify.accuracy(classifier1, fd_unigram_featuresets_test))\n fd_f_measure_list_nb.append(nltk.metrics.f_measure(refsets['not'], testsets1['not']))\n fd_accuracy_list_svm.append(nltk.classify.accuracy(classifier3, fd_unigram_featuresets_test))\n fd_f_measure_list_svm.append(nltk.metrics.f_measure(refsets['not'], testsets3['not']))\n fd_accuracy_list_maxent.append(nltk.classify.accuracy(classifier2, fd_unigram_featuresets_test))\n fd_f_measure_list_maxent.append(nltk.metrics.f_measure(refsets['not'], testsets2['not']))\n\n\n ################################################################################\n print \"+-----------------------------------------------------------------+\"\n print \"\\t\\t\\t\\t\\tfrequency distribution classification measurements\"\n print \"+-----------------------------------------------------------------+\"\n print \"Naive Bayes\\t\\t\\t\\t\\t %f \\t\\t\\t\\t%d\" % (max(fd_accuracy_list_nb), (fd_accuracy_list_nb.index(max(fd_accuracy_list_nb))*20)+10)\n print \"Maximum entropy\\t\\t\\t\\t %f \\t\\t\\t\\t%d\" % (max(fd_accuracy_list_maxent), (fd_accuracy_list_maxent.index(max(fd_accuracy_list_maxent))*20)+10)\n print \"Support Vector Machine\\t\\t %f \\t\\t\\t\\t%d\" % (max(fd_accuracy_list_svm), (fd_accuracy_list_svm.index(max(fd_accuracy_list_svm))*20)+10)\n print \"+-----------------------------------------------------------------+\"\n print \"+-----------------------------------------------------------------+\"\n print \"\\t\\t\\t\\t\\t\\t\\tmax f-measure \\t number of features \"\n print \"Naive Bayes\\t\\t\\t\\t\\t %f \\t\\t\\t\\t%d\" % (max(fd_f_measure_list_nb), (fd_f_measure_list_nb.index(max(fd_f_measure_list_nb))*20)+10)\n print \"Maximum entropy\\t\\t\\t\\t %f \\t\\t\\t\\t%d\" % (max(fd_f_measure_list_maxent), (fd_f_measure_list_maxent.index(max(fd_f_measure_list_maxent))*20)+10)\n print \"Support Vector Machine\\t\\t %f \\t\\t\\t\\t%d\" % (max(fd_f_measure_list_svm), (fd_f_measure_list_svm.index(max(fd_f_measure_list_svm))*20)+10)\n print \"+-----------------------------------------------------------------+\"\n\n ################################################################################\n print \"+-----------------------------------------------------------------+\"\n print \"\\t\\t\\t\\t\\ttf-idf classification measurements\"\n print \"+-----------------------------------------------------------------+\"\n print \"Naive Bayes\\t\\t\\t\\t\\t %f \\t\\t\\t\\t%d\" % (max(tfidf_accuracy_list_nb), (tfidf_accuracy_list_nb.index(max(tfidf_accuracy_list_nb))*20)+10)\n print \"Maximum entropy\\t\\t\\t\\t %f \\t\\t\\t\\t%d\" % (max(tfidf_accuracy_list_maxent), (tfidf_accuracy_list_maxent.index(max(tfidf_accuracy_list_maxent))*20)+10)\n print \"Support Vector Machine\\t\\t %f \\t\\t\\t\\t%d\" % (max(tfidf_accuracy_list_svm), (tfidf_accuracy_list_svm.index(max(tfidf_accuracy_list_svm))*20)+10)\n print \"+-----------------------------------------------------------------+\"\n print \"+-----------------------------------------------------------------+\"\n print \"\\t\\t\\t\\t\\t\\t\\tmax f-measure \\t number of features \"\n print \"Naive Bayes\\t\\t\\t\\t\\t %f \\t\\t\\t\\t%d\" % (max(tfidf_f_measure_list_nb), (tfidf_f_measure_list_nb.index(max(tfidf_f_measure_list_nb))*20)+10)\n print \"Maximum entropy\\t\\t\\t\\t %f \\t\\t\\t\\t%d\" % (max(tfidf_f_measure_list_maxent), (tfidf_f_measure_list_maxent.index(max(tfidf_f_measure_list_maxent))*20)+10)\n print \"Support Vector Machine\\t\\t %f \\t\\t\\t\\t%d\" % (max(tfidf_f_measure_list_svm), (tfidf_f_measure_list_svm.index(max(tfidf_f_measure_list_svm))*20)+10)\n print \"+-----------------------------------------------------------------+\"\n################################################################################\n\n print \" time taken for the classification process %f sec \" % (time() - t0)\n######################################################################################################\n\n\n x_axis = [i for i in range(10, 200, 20)]\n plt.figure(facecolor='white')\n # fig1, = plt.plot(x_axis, tfidf_accuracy_list_nb, 'go-', label='Naive bayes accuracy')\n fig2, = plt.plot(x_axis, tfidf_f_measure_list_nb, 'ro-', label='Naive bayes f-measure')\n # fig3, = plt.plot(x_axis, tfidf_accuracy_list_svm, 'g*-', label='SVM accuracy')\n fig4, = plt.plot(x_axis, tfidf_f_measure_list_svm, 'go-', label='SVM f-measure')\n # fig5, = plt.plot(x_axis, tfidf_accuracy_list_maxent, 'g^-', label='max Entropy accuracy')\n fig6, = plt.plot(x_axis, tfidf_f_measure_list_maxent, 'o-', label='max Entropy f-measure')\n\n plt.xlabel('Number of features')\n plt.ylabel('Results')\n plt.title('Results of the classification using tf-idf')\n plt.legend(handles=[ fig2, fig4, fig6], loc=4)\n\n\n\n##################################################################################\n plt.figure(facecolor='white')\n # fig1, = plt.plot(x_axis, fd_accuracy_list_nb, 'go-', label='Naive bayes accuracy')\n fig2, = plt.plot(x_axis, fd_f_measure_list_nb, 'ro-', label='Naive bayes f-measure')\n # fig3, = plt.plot(x_axis, fd_accuracy_list_svm, 'g*-', label='SVM accuracy')\n fig4, = plt.plot(x_axis, fd_f_measure_list_svm, 'go-', label='SVM f-measure')\n # fig5, = plt.plot(x_axis, fd_accuracy_list_maxent, 'g^-', label='max Entropy accuracy')\n fig6, = plt.plot(x_axis, fd_f_measure_list_maxent, 'o-', label='max Entropy f-measure')\n\n plt.xlabel('Number of features')\n plt.ylabel('Results')\n plt.title('Results of the classification using frequency distribution')\n plt.legend(handles=[fig2, fig4, fig6], loc=4)\n plt.show()",
"def __init__(self, n_recommendations):\n self.recommendations_values = []\n self.recommendations_indices = []\n self.n_recommendations = n_recommendations",
"def initialize(self):\n # Initializing the counter and distribution.\n for k in range(0, self.topic_number,1):\n self.topic_term_count_matrix[k]= [0.0] * self.term_number\n self.topic_distribution_over_term[k] = [0.0] * self.term_number\n self.sum_topic_by_term_count[k] = 0.0\n for m in range(0, self.document_number,1):\n self.document_topic_count_matrix[m] = [0.0] * self.topic_number\n self.document_distribution_over_topic[m] = [0.0] * self.topic_number\n self.sum_document_by_topic_count[m] = 0.0\n\n # Initializing topics assigned to all words of all documents.\n for m in range(0, self.document_number, 1):\n N = len(self.documents[m])\n self.word_topic_assignment[m] = [-1] * N\n for n in range(0, N,1):\n topic = int(random.uniform(0,1) * self.topic_number)\n self.document_topic_count_matrix[m][topic] += 1.0\n self.topic_term_count_matrix[topic][self.documents[m][n]] += 1.0\n self.sum_topic_by_term_count[topic] += 1.0\n self.word_topic_assignment[m][n] = topic\n self.sum_document_by_topic_count[m] = N",
"def init_sample_table(vocab_counts):\r\n count = [ele for ele in vocab_counts]\r\n pow_frequency = np.array(count)**0.75\r\n power = sum(pow_frequency)\r\n ratio = pow_frequency / power\r\n table_size = 1e8\r\n count = np.round(ratio*table_size)\r\n sample_table = []\r\n for idx, x in enumerate(count):\r\n sample_table += [idx]*int(x)\r\n return np.array(sample_table)",
"def initialize(self):\n self.n_words = len(self.vocab)\n self.n_docs = len(self.documents)\n\n # Initialize the three count matrices.\n # The (i,j) entry of self.nmz is the number of words in document i assigned to topic j.\n self.nmz = np.zeros((self.n_docs, self.n_topics))\n # The (i,j) entry of self.nzw is the number of times term j is assigned to topic i.\n self.nzw = np.zeros((self.n_topics, self.n_words))\n # The (i)-th entry is the number of times topic i is assigned in the corpus.\n self.nz = np.zeros(self.n_topics)\n\n # Initialize the topic assignment dictionary.\n self.topics = {} # key-value pairs of form (m,i):z\n\n for m in range(self.n_docs):\n for i in self.documents[m]:\n # Get random topic assignment, i.e. z is a random integer in the range of topics\n z = np.random.randint(self.n_topics)\n # Increment count matrices\n self.nmz[m,z] += 1\n self.nzw[z,self.documents[m][i]] += 1\n self.nz[z] += 1\n # Store topic assignment\n self.topics[(m,i)] = z",
"def construct_train_set(tweet_pos, tweet_neg):\n tweet_pos['pred'] = 1\n tweet_neg['pred'] = 0\n tweet_pos.columns = ['tweet', 'pred']\n tweet_neg.columns = ['tweet', 'pred']\n all_tweets = tweet_neg.append(tweet_pos)\n tweet_TR = all_tweets.reset_index().drop(['index'], axis = 1)\n return tweet_TR"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
activates mujoco with license at `file_path` this does not check the return code, per usage example at simulate.cpp and test.cpp. | def register_license(file_path):
result = mjlib.mj_activate(file_path)
return result | [
"def license_(value, overwrite):\n response = requests.get(\"https://api.github.com/repos/github/choosealicense.com/contents/_licenses?ref=gh-pages\")\n ensure_ok_response(response, \"Fetching license files failed.\")\n\n contents = response.json()\n\n if value == \"list\":\n licenses = []\n for element in contents:\n filename_split = element[\"name\"].split(\".\")\n if filename_split[-1] == \"txt\":\n licenses.append(filename_split[0].lower())\n return \" * \" + \"\\n * \".join(licenses)\n\n download_url = None\n for element in contents:\n if value.lower() == element[\"name\"].split(\".\")[0].lower():\n download_url = element[\"download_url\"]\n\n if download_url is None:\n raise click.ClickException(\"License \" + value + \" could not be found.\")\n\n response = requests.get(download_url)\n ensure_ok_response(response, \"Fetching LICENSE file failed.\")\n\n file_exists = os.path.isfile(LICENSE_FILE)\n\n if file_exists and overwrite is False:\n raise click.ClickException(LICENSE_FILE + \" file already exists. Delete it or use -o to overwrite.\")\n\n with open(LICENSE_FILE, \"w\") as f:\n # files have metadata in header with --- separators\n f.write(response.text.split(\"---\")[-1].strip())\n\n return \"File \" + LICENSE_FILE + \" was created.\"",
"def test_03_license(self):\n\n self.image_create(self.rurl)\n self.pkg(\"install --accept licensed@1.3\")\n\n victim = \"lib/libc.so.1\"\n\n # Initial size\n size1 = self.file_size(victim)\n\n # Corrupt the file\n self.file_append(victim, \"foobar\")\n\n # Make sure the size actually changed\n size2 = self.file_size(victim)\n self.assertNotEqual(size1, size2)\n\n # Verify that the fix will fail if the license file needs fixing\n # since the license action requires acceptance.\n img = self.get_img_api_obj().img\n shutil.rmtree(os.path.join(img.imgdir, \"license\"))\n self.pkg(\"fix licensed\", exit=6)\n\n # Verify that when the fix failed, it displayed the license\n # that required display.\n self.pkg(\"fix licensed | grep 'copyright.licensed'\")\n self.pkg(\"fix licensed | grep -v 'license.licensed'\")\n\n # Verify that fix will display all licenses when it fails,\n # if provided the --licenses option.\n self.pkg(\"fix --licenses licensed | grep 'license.licensed'\")\n\n # Finally, verify that fix will succeed when a package requires\n # license acceptance if provided the --accept option.\n self.pkg(\"fix --accept licensed\")\n\n # Make sure it's the same size as the original\n size2 = self.file_size(victim)\n self.assertEqual(size1, size2)",
"def upload_license(self):\n param = self.module.params[\"param\"]\n license_file_path = param['license_file_path']\n if license_file_path and os.access(license_file_path, os.F_OK) and os.access(license_file_path, os.R_OK):\n self.client.upload_license(license_file_path)\n self.module.exit_json(msg=\"Import license file Success.\", changed=True, status='success')\n else:\n self.module.fail_json(msg=\"Import license file Fail.Please add 'hw_license_file_path' \"\n \"and make sure it can be read.\",\n changed=True, status='fail')",
"def activate_license(self):\n response = self.client.activate_license()\n if str(response[\"result\"][\"code\"]) == \"0\" and str(response[\"data\"][\"LicenseActiveResult\"]) == \"0\":\n self.module.exit_json(msg=\"Activate license file Success.\", changed=True, status='success')\n else:\n self.module.fail_json(msg=\"Activate license file fail.{0}\".format(response['result']['description']),\n status='fail', changed=False)",
"def main(target, from_license, to_license, style):\n\n if to_license is None:\n to_license = \"LICENSE\"\n\n if from_license is None:\n from_license = \"LICENSE\"\n\n if not pathlib.Path(to_license).exists():\n logging.error(\"License file \\\"%s\\\" not found!\" % to_license)\n return -1\n\n source_file_path = target\n\n from_license_lines, from_license_charset = load_file(from_license)\n to_license_lines, to_license_charset = load_file(to_license)\n source_lines, source_charset = load_file(source_file_path)\n\n if len(source_lines) <= 0:\n logging.warn(\n \"Source file does not have any content : \\\"%s\\\" !\" % source_file_path)\n return 0\n\n licenser = licensers.create_licenser(\n style, source_lines, from_license_lines, to_license_lines)\n\n parsed_source_lines = licenser.parse()\n\n if parsed_source_lines is not None:\n # Check if there have empty at last line, append one if there does not\n # have one.\n if len(parsed_source_lines) > 0:\n if len(parsed_source_lines[len(parsed_source_lines) - 1]) > 0:\n parsed_source_lines.append(\"\")\n\n # Output generated file with original encodings\n parsed_source_content = \"\\n\".join(parsed_source_lines)\n\n # Before write to specific file, we backup it first\n shutil.copyfile(source_file_path, \"%s.bak\" % source_file_path)\n\n try:\n with open(source_file_path, \"wb\") as f:\n f.write(parsed_source_content.encode(\n source_charset[\"encoding\"]))\n except:\n # If any exception happened, we restore old backup\n shutil.copyfile(\"%s.bak\" % source_file_path, source_file_path)\n raise\n\n return 0",
"def write_license_file_impl(file):\n file.write(license_text)",
"def test_copyright_year_compute_in_license_file(cookies):\n with bake(cookies) as result:\n assert result.project.isdir()\n assert result.exit_code == 0\n assert result.exception is None\n\n license_file_path = result.project.join('LICENSE')\n now = datetime.datetime.now()\n assert str(now.year) in license_file_path.read()\n\n with bake(cookies, extra_context={'copyright_year': '2018-2019'}) as result:\n assert result.project.isdir()\n assert result.exit_code == 0\n assert result.exception is None\n\n license_file_path = result.project.join('LICENSE')\n assert '2018-2019' in license_file_path.read()",
"def license(self, plexus, **kwds):\n # make some space\n plexus.info.log({project.name}.meta.license)\n # all done\n return",
"def install_license_file(self, context, contents):\n\n LOG.info(\"Install license file.\")\n license_file = os.path.join(tsc.PLATFORM_CONF_PATH,\n constants.LICENSE_FILE)\n temp_license_file = license_file + '.temp'\n with open(temp_license_file, 'w') as f:\n f.write(contents)\n f.close()\n\n # Verify license\n try:\n license.verify_license(temp_license_file)\n except Exception as e:\n raise exception.SysinvException(str(e))\n\n os.rename(temp_license_file, license_file)\n\n try:\n subprocess.check_output([\"cp\", license_file,\n os.path.join(tsc.CONFIG_PATH, constants.LICENSE_FILE)])\n except subprocess.CalledProcessError as e:\n LOG.error(\"Fail to install license to redundant \"\n \"storage, output: %s\" % e.output)\n os.remove(license_file)\n raise exception.SysinvException(_(\n \"ERROR: Failed to install license to redundant storage.\"))\n\n hostname = subprocess.check_output([\"hostname\"]).rstrip()\n validHostnames = [constants.CONTROLLER_0_HOSTNAME,\n constants.CONTROLLER_1_HOSTNAME]\n if hostname == 'localhost':\n raise exception.SysinvException(_(\n \"ERROR: Host undefined. Unable to install license\"))\n elif hostname not in validHostnames:\n raise exception.SysinvException(_(\n \"ERROR: Invalid hostname for controller node: %s\") % hostname)\n\n personalities = [constants.CONTROLLER]\n config_uuid = self._config_update_hosts(context, personalities)\n config_dict = {\n 'personalities': personalities,\n 'file_names': [license_file],\n 'file_content': contents,\n }\n self._config_update_file(context, config_uuid, config_dict)",
"def request_license():\n licenserepo = _get_argv(\"licenserepo\").replace(\"\\\\\", \"/\")\n\n print(\"Requesting a license...\")\n _dashingLine()\n\n # check if a used license with current hostname may exist\n used_hostname_lic = check_if_hostname_in_use()\n if used_hostname_lic:\n print(\"Found a used license for this computer, using the same license instead...\")\n use_license(used_hostname_lic)\n \n # set a lock environ so this session wont rename the lic back but ethe original will do that\n os.environ[\"SLM_MULTIPLE_SESSIONS\"] = \"True\"\n\n else:\n lic = get_free_license_list()[0]\n ext = None\n if \".\" in lic:\n ext = lic.split(\".\")[-1]\n\n # rename lic file to .inuse.hostname\n lic_path = os.path.join(licenserepo, lic)\n\n if ext:\n rlic = lic.split(\".\"+ext)[0]\n rlic = rlic+\".inuse.\"+_get_hostname()+\".\"+ext\n else:\n rlic = lic+\".inuse.\"+_get_hostname()\n rlic_path = os.path.join(licenserepo, rlic)\n\n # rename\n os.rename(lic_path, rlic_path)\n\n # use license and start app\n use_license(rlic_path)",
"def write_license(content):\n with open(\"LICENSE\", \"w\") as f:\n print(\"Creating the LICENSE file...\")\n f.write(content)",
"def license(self, plexus, **kwds):\n # grab a channel\n channel = plexus.info\n # log the copyright note\n channel.log(flo.meta.license)\n # all done\n return",
"def query_active_license(self):\n response = self.client.query_active_license()\n if str(response[\"result\"][\"code\"]) == \"0\":\n if str(response[\"data\"][\"FileExist\"]) == \"0\":\n self.module.exit_json(msg=\"License file exists.\", changed=True, status='success')\n else:\n self.module.fail_json(msg=\"License file not exists.You should add the License file first.Your License \"\n \"Serial No is: {0}\".format(response[\"data\"][\"LicenseSerialNo\"]),\n changed=False, status='fail')\n else:\n self.module.fail_json(msg=\"Query active licenses in batches has an error.\"\n \"{0}\".format(response['result']['description']),\n status='fail', changed=False)",
"def show_license():\n\n logger.info('Function show_license was initialized.')\n messagebox.showinfo('License', \"\"\"\nMIT License\n\nCopyright (c) 2020 RIDERIUS\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n\"\"\")\n logger.info('Function show_license was closed.')",
"def show_license(ctx, param, value):\n if not value or ctx.resilient_parsing:\n return\n click.echo(lic)\n ctx.exit()",
"def checkLicense():\n if exists(license_location):\n return True\n else:\n print 'Freesurfer .license file not found!'\n print 'If you don\\'t already have one, check out'\n print 'http://surfer.nmr.mgh.harvard.edu/fswiki/Registration'\n line1 = prompt('enter first line (of 3) of freesurfer .license file',\n validate='.*[@].*')\n line2 = prompt('enter second line of freesurfer .license file',\n validate='\\d+')\n line3 = prompt('enter first line of freesurfer .license file',\n validate='.*')\n append(license_location, '\\n'.join([line1, line2, line3]))",
"def checkoutlicense(self,feature_):\n res = __library__.MSK_XX_checkoutlicense(self.__nativep,feature_)\n if res != 0:\n raise Error(rescode(res),Env.getcodedesc(rescode(res))[1])",
"def display_license() -> None:\n license_file = get_path_to_license()\n\n subprocess.run(\n ['less', '-P Please read the license. Up/Down/Space - scroll, q - finish reading. ',\n license_file], check=False)\n\n accept = click.prompt('This software includes components licensed under GPLv2+CPE. '\n 'Do you accept this license? [y/n]', type=BOOL)\n\n if not accept:\n click.echo('The license was not accepted, exiting...')\n sys.exit(2)",
"def create_license(self) -> None:\n # copy the license file from the template to the package folder\n # option : append other license files\n shutil.copy(CONFIG.template_path / \"LICENSE.md\", self.package_path)"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return (qposadr, qveladr, dof) for the given joint name. If dof is 4 or 7, then the last 4 degrees of freedom in qpos represent a unit quaternion. | def joint_adr(self, joint_name):
jntadr = mjlib.mj_name2id(self.ptr, C.mjOBJ_JOINT, joint_name)
assert (jntadr >= 0)
dofmap = {C.mjJNT_FREE: 7,
C.mjJNT_BALL: 4,
C.mjJNT_SLIDE: 1,
C.mjJNT_HINGE: 1}
qposadr = self.jnt_qposadr[jntadr][0]
qveladr = self.jnt_dofadr[jntadr][0]
dof = dofmap[self.jnt_type[jntadr][0]]
return (qposadr, qveladr, dof) | [
"def quat_from_pose(pose):\n return pose[1]",
"def _get_joint_info(self):\n info = p.getJointStates(\n self.robot,\n jointIndices=self.robot_arm_joint_indices,\n physicsClientId=self.id)\n\n pos, vel, rf, t = [], [], [], []\n\n for joint_info in info:\n pos.append(joint_info[0])\n vel.append(joint_info[1])\n rf.append(joint_info[2])\n t.append(joint_info[3])\n\n return np.array(pos), np.array(vel), np.array(rf), np.array(t)",
"def get_joint_states(self, joints: List[str]) -> Tuple[List[float], List[float], List[str]]:\n assert all([j in self.joints.names for j in joints]), 'All joints requested must be in self.joints'\n \n rospy.wait_for_service('/' + self.model_name + '/get_joint_states', timeout=2.0)\n try:\n resp = self.__get_joint_states(joint_names=joints)\n except rospy.ServiceException as e:\n print('Service did not process request:' + str(e))\n \n joint_positions = resp.joint_states.position\n joint_velocities = resp.joint_states.velocity\n joint_order = resp.joint_states.name\n \n return joint_positions, joint_velocities, joint_order",
"def DQT(fp):\n # length is 2 + sum(t=1, N) of (65 + 64 * Pq(t))\n length = unpack('>H', fp.read(2))[0]\n _remaining = length - 2\n\n _pq, _tq, _qk = [], [], []\n while _remaining > 0:\n precision, table_id = _split_byte(fp.read(1))\n _remaining -= 1\n _pq.append(precision)\n _tq.append(table_id)\n\n # If Pq is 0, Qk is 8-bit, if Pq is 1, Qk is 16-bit\n Q_k = []\n for ii in range(64):\n if precision == 0:\n Q_k.append(unpack('>B', fp.read(1))[0])\n _remaining -= 1\n elif precision == 1:\n Q_k.append(unpack('>H', fp.read(2))[0])\n _remaining -= 2\n\n _qk.append(Q_k)\n\n info = {\n 'Lq' : length,\n 'Pq' : _pq,\n 'Tq' : _tq,\n 'Qk' : _qk\n }\n\n return info",
"def get_joint_index_by_name(self, joint_name):\n if joint_name in self._all_joint_dict:\n return self._all_joint_dict[joint_name]\n else:\n raise Exception(\"[PyBulletRobotDescription::get_link_index_by_name] Joint name does not exist!\")",
"def jointName(self, joint_idx: int) -> str:\n raise NotImplementedError()",
"def getNametagJoints(self):\n # Not sure what the name is right now.\n return []",
"def _get_kdl_joint_names(self):\n num_links = self._urdf_chain.getNrOfSegments()\n num_joints = self._urdf_chain.getNrOfJoints()\n joint_names = []\n for i in range(num_links):\n link = self._urdf_chain.getSegment(i)\n joint = link.getJoint()\n joint_type = joint.getType()\n # JointType definition: [RotAxis,RotX,RotY,RotZ,TransAxis,\n # TransX,TransY,TransZ,None]\n if joint_type > 1:\n continue\n joint_names.append(joint.getName())\n assert num_joints == len(joint_names)\n return copy.deepcopy(joint_names)",
"def _get_joint_info(self):\n attribute_list = ['jointIndex', 'jointName', 'jointType',\n 'qIndex', 'uIndex', 'flags',\n 'jointDamping', 'jointFriction', 'jointLowerLimit',\n 'jointUpperLimit', 'jointMaxForce', 'jointMaxVelocity', 'linkName',\n 'jointAxis', 'parentFramePos', 'parentFrameOrn', 'parentIndex']\n\n joint_information = []\n for idx in range(pb.getNumJoints(self._id, physicsClientId=self._uid)):\n info = pb.getJointInfo(self._id, idx, physicsClientId=self._uid)\n joint_information.append(dict(zip(attribute_list, info)))\n return joint_information",
"def _joint_positions(self):\n return self.sim.data.qpos[self._ref_joint_pos_indexes]",
"def check_qdof(base, q_dof):\n if base == 'linear_helix' or base == 'pure_helix':\n if q_dof != 2:\n raise ValueError(f'{base} should have 2 degrees of freedom, not {q_dof}.')\n elif base == 'quadratic' or base == 'linear':\n if q_dof < 2 or q_dof > 3:\n raise ValueError(f'{base} should have 2 or 3 degrees of freedom, not {q_dof}.')\n elif base == 'constant':\n if q_dof != 1:\n raise ValueError(f'{base} should have 1 degrees of freedom, not {q_dof}.')\n elif base == 'torsion_helix' or base == 'torsion_linear_helix':\n if q_dof != 3:\n raise ValueError(f'{base} should have 3 degrees of freedom, not {q_dof}.')\n elif base == 'full':\n if q_dof < 5 or q_dof > 8:\n raise ValueError(f'{base} should have 5-8 degrees of freedom, not {q_dof}.')\n else:\n print(f'{base} is not a defined strain base.')",
"def get_joint_positions(limb):\n return np.array([limb.joint_angles()[joint_name] for joint_name in limb.joint_names()])",
"def joint_names(self):\n return self._joint_names[self.name]",
"def GetDhForJoint(angle, joint): \n\n dhArray = np.empty([4])\n \n #get dh parameters from dh table\n \n dhArray[2] = angle\n\n dhArray[0] = dhParameter[joint,0]\n dhArray[1] = dhParameter[joint,1]\n dhArray[2] += dhParameter[joint,2] \n dhArray[3] = dhParameter[joint,3]\n \n return dhArray",
"def joint_angle(self, joint):\n return self._joint_angle[joint]",
"def get_joint_data(bagFile, joint_name, duration=True):\n # INITIALIZATION\n x = np.array([])\n y = np.array([])\n theta = np.array([])\n all_t = np.array([])\n bag = rosbag.Bag(bagFile) # Initialize rosbag object\n first = True # True on first iteration to take first timestamp\n\n # Add message values to collections\n for topic, msg, t in bag.read_messages(topics=['/tf']):\n\n joint = msg.transforms[0].child_frame_id\n translation = msg.transforms[0].transform.translation\n orientation = msg.transforms[0].transform.rotation\n euler = euler_from_quaternion(\n [orientation.x, orientation.y, orientation.z, orientation.w])\n\n if joint == joint_name:\n\n # Get timestamp in seconds\n t = msg.transforms[0].header.stamp\n t_sec = t.to_sec()\n if duration:\n if first:\n t_0 = t_sec\n first = False\n\n all_t = np.append(all_t, t_sec - t_0)\n\n else:\n all_t = np.append(all_t, t_sec)\n\n # Get x, y and z coordinates\n\n x = np.append(x, translation.x)\n y = np.append(y, translation.y)\n theta = np.append(theta, euler[2])\n\n pose = [x, y, theta]\n\n return pose, all_t",
"def getName(self):\n return self.joint_name",
"def quat2rod(qu):\r\n\r\n \"\"\"Step 1: Quaternion to Rodrigues-Frank vector.\"\"\"\r\n\r\n s = torch.linalg.norm(qu[..., 1:4], dim=-1, keepdim=True)\r\n ro = torch.where(torch.lt(torch.abs(qu[..., 0:1]), 1.0e-12).expand(qu.shape),\r\n torch.cat((qu[..., 1:2], qu[..., 2:3], qu[..., 3:4],\r\n _precision_check(float('inf'), qu.dtype, qu.device).expand(qu.shape[:-1] + (1,))), dim=-1),\r\n torch.cat((qu[..., 1:2] / s, qu[..., 2:3] / s, qu[..., 3:4] / s,\r\n torch.tan(torch.acos(torch.clip(qu[..., 0:1], -1.0, 1.0)))), dim=-1)\r\n )\r\n ro[torch.lt(torch.squeeze(torch.abs(s), dim=-1), 1.0e-12)] = _precision_check([0.0, 0.0, P, 0.0], s.dtype, s.device)\r\n return ro",
"def joint_angle(self, joint):\n return self.joint_traj_controller.get_joint_positions()[joint]"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Reencode phylogeny_df to facilitate efficient analysis and transformation operations. The returned phylogeny dataframe will be topologically sorted (i.e., organisms appear after all ancestors), have contiguous ids (i.e., organisms' ids correspond to row number), contain an integer datatype `ancestor_id` column if the phylogeny is asexual (i.e., a more performant representation of `ancestor_list`). Input dataframe is not mutated by this operation unless `mutate` set True. If mutate set True, operation does not occur in place; still use return value to get transformed phylogeny dataframe. | def alifestd_to_working_format(
phylogeny_df: pd.DataFrame,
mutate: bool = False,
) -> pd.DataFrame:
if not mutate:
phylogeny_df = phylogeny_df.copy()
phylogeny_df = alifestd_try_add_ancestor_id_col(phylogeny_df, mutate=True)
if not alifestd_is_topologically_sorted(phylogeny_df):
phylogeny_df = alifestd_topological_sort(phylogeny_df, mutate=True)
if not alifestd_has_contiguous_ids(phylogeny_df):
phylogeny_df = alifestd_assign_contiguous_ids(
phylogeny_df, mutate=True
)
return phylogeny_df | [
"def alifestd_topological_sort(\n phylogeny_df: pd.DataFrame,\n mutate: bool = False,\n) -> pd.DataFrame:\n\n if not mutate:\n phylogeny_df = phylogeny_df.copy()\n\n phylogeny_df.set_index(\"id\", drop=False, inplace=True)\n\n unsorted_ids = set(phylogeny_df[\"id\"])\n internal_ids_refcounts = Counter(\n id\n for ancestor_list_str in phylogeny_df[\"ancestor_list\"]\n for id in alifestd_parse_ancestor_ids(ancestor_list_str)\n )\n internal_ids_set = set(internal_ids_refcounts.keys())\n\n reverse_sorted_ids = []\n while unsorted_ids:\n leaf_ids = unsorted_ids - internal_ids_set\n reverse_sorted_ids.extend(leaf_ids)\n unsorted_ids -= leaf_ids\n\n leaf_parent_counts = Counter(\n id\n for ancestor_list_str in phylogeny_df.loc[[*leaf_ids]][\n \"ancestor_list\"\n ]\n for id in alifestd_parse_ancestor_ids(ancestor_list_str)\n )\n internal_ids_refcounts.subtract(leaf_parent_counts)\n\n for leaf_parent_id in leaf_parent_counts.keys():\n refcount = internal_ids_refcounts[leaf_parent_id]\n assert refcount >= 0\n if refcount == 0:\n internal_ids_set.remove(leaf_parent_id)\n del internal_ids_refcounts[leaf_parent_id]\n\n return phylogeny_df.loc[reverse_sorted_ids[::-1], :].reset_index(drop=True)",
"def append_genesis_organism(\n alifestd_df: pd.DataFrame,\n mutate: bool = False,\n) -> pd.DataFrame:\n\n if not mutate:\n alifestd_df = alifestd_df.copy()\n\n if len(alifestd_df):\n assert alifestd_df[\"origin_time\"].min() >= 0\n if alifestd_df[\"origin_time\"].min() == 0:\n return alifestd_df\n\n genesis_id = alifestd_df[\"id\"].max() + 1\n for old_root_id in alifestd_find_root_ids(alifestd_df):\n if \"ancestor_id\" in alifestd_df:\n alifestd_df.loc[\n alifestd_df[\"id\"] == old_root_id, \"ancestor_id\"\n ] = genesis_id\n alifestd_df.loc[\n alifestd_df[\"id\"] == old_root_id, \"ancestor_list\"\n ] = f\"[{genesis_id}]\"\n else:\n genesis_id = 0\n\n alifestd_df = pd.concat(\n [\n alifestd_df,\n pd.DataFrame(\n {\n \"id\": [genesis_id],\n \"ancestor_id\": [genesis_id],\n \"origin_time\": [0],\n \"ancestor_list\": [\"[none]\"],\n \"name\": \"genesis\",\n \"taxon_label\": \"genesis\",\n }\n ),\n ],\n ignore_index=True,\n join=\"inner\",\n )\n\n alifestd_df.reset_index(drop=True, inplace=True)\n\n return alifestd_df",
"def map_taxon_content_ids(target_taxon_df, nodes_df):\n\n column_list = ['content_id', 'title', 'base_path', 'level', 'parents', 'level1_parent']\n taxon_level_df = pd.DataFrame(columns=column_list)\n\n taxon_set = build_taxon_set(nodes_df.Node_Taxon)\n\n for content_id in taxon_set:\n if target_taxon_df[target_taxon_df.content_id == content_id].shape[0] > 0:\n title = target_taxon_df[target_taxon_df.content_id == content_id].iloc[0].title\n base_path = target_taxon_df[target_taxon_df.content_id == content_id].iloc[0].base_path\n parent_list = pd.Series(recursive_parenting(target_taxon_df, content_id,\n target_taxon_df[\n target_taxon_df.content_id == content_id].parent_content_id.values[\n 0], []))\n current_level = len(parent_list) + 1\n level1_par = title\n if len(parent_list.values) > 0:\n level1_par = parent_list.values[0][0][2]\n taxon_level_df = pd.concat([taxon_level_df, pd.DataFrame([[content_id,\n title,\n base_path,\n current_level,\n parent_list.values,\n level1_par]], columns=column_list)])\n taxon_level_df.reset_index(drop=True, inplace=True)\n taxon_level_df.drop_duplicates(subset=\"content_id\", keep=\"first\", inplace=True)\n return taxon_level_df",
"def as_phyloxml(self, **kwargs):\n from Bio.Phylo.PhyloXML import Phylogeny\n\n return Phylogeny.from_tree(self, **kwargs)",
"def make_dendrogram_tree(df):\n ZZZ = calculate_linkage_matrix_in_python_format(df)\n\n # set idx to the index of the root node (= the one with the largest number of descendants)\n root_node_idx = int(ZZZ[:, 3].argmax())\n\n N = len(df)\n return make_dendrogram_subtree(df, root_node_idx + N, ZZZ, N)",
"def as_dict(self):\n\n def _rec_phylogeny(node):\n res = {'name': node['Name'].decode(), 'id': int(node['NCBITaxonId'])}\n children = []\n for child in self._direct_children_taxa(node['NCBITaxonId']):\n children.append(_rec_phylogeny(child))\n if len(children) > 0:\n res['children'] = children\n else:\n try:\n g = self.genomes[res['id']]\n res['code'] = g.uniprot_species_code\n except KeyError:\n pass\n return res\n\n return _rec_phylogeny(self._get_root_taxon())",
"def build_anchor_df(df):\n df_columns = df.columns\n forward_df = (df\n .rename({df_columns[0]: 'anchor_guide', df_columns[1]: 'target_guide',\n df_columns[2]: 'anchor_gene', df_columns[3]: 'target_gene'}, axis=1))\n reverse_df = (df\n .rename({df_columns[1]: 'anchor_guide', df_columns[0]: 'target_guide',\n df_columns[3]: 'anchor_gene', df_columns[2]: 'target_gene'}, axis=1))\n anchor_df = (pd.concat([forward_df, reverse_df])\n .drop_duplicates() # in case where guide1==guide2\n .reset_index(drop=True))\n return anchor_df",
"def add_taxon_basepath_to_df(node_df, taxon_level_df):\n content_basepath_dict = dict(zip(taxon_level_df.content_id, taxon_level_df.base_path))\n taxon_name_list = []\n for tup in node_df.itertuples():\n taxon_basepath = []\n for taxon in tup.Node_Taxon:\n if taxon in content_basepath_dict.keys():\n taxon_basepath.append(content_basepath_dict[taxon])\n taxon_name_list.append(taxon_basepath)\n node_df['Node_Taxon_basepath'] = taxon_name_list\n return node_df",
"def simplify_undirected_as_dataframe(df: gpd.GeoDataFrame) -> gpd.GeoDataFrame:\n df.reset_index(inplace=True)\n\n g = gt.Graph(directed=False)\n osm_id = g.new_edge_property('string')\n highway = g.new_edge_property('string')\n level = g.new_edge_property('int')\n lanes = g.new_edge_property('int')\n width = g.new_edge_property('float')\n bicycle = g.new_edge_property('bool')\n bicycle_safety = g.new_edge_property('int')\n foot = g.new_edge_property('bool')\n foot_safety = g.new_edge_property('int')\n max_speed = g.new_edge_property('int')\n motorcar = g.new_edge_property('bool')\n linestring = g.new_edge_property('python::object')\n\n edgelist = df[\n ['u', 'v', 'osm_id', 'highway', 'level', 'lanes', 'width', 'bicycle', 'bicycle_safety', 'foot', 'foot_safety',\n 'max_speed', 'motorcar', 'geometry']].values\n\n nodes_id = g.add_edge_list(edgelist, hashed=True,\n eprops=[osm_id, highway, level, lanes, width, bicycle, bicycle_safety, foot, foot_safety,\n max_speed, motorcar, linestring])\n\n # we are gonna replace the original repeated nodes with a linestring\n e_path = g.new_ep('vector<int64_t>')\n for e in g.edges():\n e_path[e] = []\n\n vs = g.get_vertices()\n deg_2 = g.get_out_degrees(vs) == 2\n\n logging.debug('selecting degree 2 candidates')\n candidates = set()\n for i, v in enumerate(vs):\n if deg_2[i]:\n u = g.get_out_neighbors(v)[0]\n w = g.get_out_neighbors(v)[1]\n\n if u != w:\n vu, vw = g.edge(v, u), g.edge(v, w)\n if highway[vu] == highway[vw]:\n candidates.add(v)\n logging.debug('found {} degree 2 candidates to simplify'.format(len(candidates)))\n\n seen = set()\n unregister_candidates = set()\n\n for candidate in candidates:\n if candidate in seen:\n continue\n\n seen.add(candidate)\n\n u = g.get_out_neighbors(candidate)[0]\n w = g.get_out_neighbors(candidate)[1]\n\n uc = g.edge(u, candidate)\n\n is_u_fringe, is_w_fringe = u not in candidates, w not in candidates\n\n us = []\n ws = []\n\n while not is_u_fringe:\n seen.add(u)\n us.append(u)\n neighbors = set(g.get_out_neighbors(u))\n neighbors -= seen\n if len(neighbors) > 0:\n u = neighbors.pop()\n is_u_fringe = u not in candidates\n elif u == w:\n us.pop(-1)\n u = us.pop(-1)\n unregister_candidates.add(u)\n unregister_candidates.add(w)\n is_u_fringe = True\n is_w_fringe = True\n g.remove_edge(g.edge(s=w, t=u))\n else:\n logging.debug('degree 1: we got here somehow {} {} {} {}', candidate, u, v,\n g.get_all_neighbors(candidate))\n break\n\n while not is_w_fringe:\n seen.add(w)\n ws.append(w)\n neighbors = set(g.get_out_neighbors(w))\n neighbors -= seen\n if len(neighbors) > 0:\n w = neighbors.pop()\n is_w_fringe = w not in candidates\n else:\n logging.debug('degree 1: we got here somehow {} {} {} {}', candidate, u, v,\n g.get_all_neighbors(candidate))\n break\n\n if is_u_fringe and is_w_fringe:\n path = [u] + list(reversed(us)) + [candidate] + ws + [w]\n linestrings = [linestring[g.edge(a, b)] for a, b in pairwise(path)]\n joined_linestring = join_linestrings(linestrings)\n if joined_linestring is None:\n path = list(reversed(path))\n linestrings = [linestring[g.edge(a, b)] for a, b in pairwise(path)]\n joined_linestring = join_linestrings(linestrings)\n\n e = g.add_edge(source=path[0], target=path[-1])\n linestring[e] = joined_linestring\n e_path[e] = [int(nodes_id[node]) for node in path]\n osm_id[e], highway[e], level[e], lanes[e], width[e], bicycle[e], bicycle_safety[e], foot[e], foot_safety[e], \\\n max_speed[e], motorcar[e] = osm_id[uc], highway[uc], level[uc], lanes[uc], width[uc], bicycle[uc], \\\n bicycle_safety[uc], \\\n foot[uc], foot_safety[uc], max_speed[uc], motorcar[uc]\n else:\n logging.error('unexpected behavior, source={0}, target={1}, candidate={2}, us={3}, ws={4}', u, w, us, ws)\n\n unseen = candidates - seen\n if len(unseen) > 0:\n logging.debug(\n 'Network scan after degree 2 simplification not finished: candidates {0} have not been examined'.format(\n unseen))\n\n candidates -= unregister_candidates\n g.remove_vertex(list(candidates))\n\n logging.debug(' linestring path')\n edges_tuples = []\n for e in g.edges():\n source, target, path = nodes_id[e.source()], nodes_id[e.target()], e_path[e]\n if len(path) == 0:\n path = [source, target]\n else:\n path = [int(i) for i in path]\n\n e_tuples = (g.edge_index[e], source, target, path,\n osm_id[e], highway[e], level[e], lanes[e], width[e], bicycle[e], bicycle_safety[e], foot[e],\n foot_safety[e], max_speed[e], motorcar[e], linestring[e])\n edges_tuples.append(e_tuples)\n\n df_edges_simplified = pd.DataFrame.from_records(edges_tuples, index='edge_id',\n columns=['edge_id', 'u', 'v', 'path', 'osm_id', 'highway',\n 'level', 'lanes', 'width', 'bicycle', 'bicycle_safety',\n 'foot', 'foot_safety', 'max_speed', 'motorcar',\n 'geometry'])\n\n df_edges_simplified.osm_id = df_edges_simplified.osm_id.str.split('-').str[0]\n df_edges_simplified = gpd.GeoDataFrame(df_edges_simplified, geometry='geometry')\n df_edges_simplified.crs = df.crs\n return df_edges_simplified",
"def simplify_directed_as_dataframe(df: gpd.GeoDataFrame) -> gpd.GeoDataFrame:\n df.reset_index(inplace=True)\n\n g = gt.Graph(directed=True)\n osm_id = g.new_edge_property('string')\n highway = g.new_edge_property('string')\n level = g.new_edge_property('int')\n lanes = g.new_edge_property('int')\n width = g.new_edge_property('float')\n bicycle = g.new_edge_property('bool')\n bicycle_safety = g.new_edge_property('int')\n foot = g.new_edge_property('bool')\n foot_safety = g.new_edge_property('int')\n max_speed = g.new_edge_property('int')\n motorcar = g.new_edge_property('bool')\n linestring = g.new_edge_property('python::object')\n\n edgelist = df[\n ['u', 'v', 'osm_id', 'highway', 'level', 'lanes', 'width', 'bicycle', 'bicycle_safety', 'foot', 'foot_safety',\n 'max_speed', 'motorcar', 'geometry']].values\n\n nodes_id = g.add_edge_list(edgelist, hashed=True,\n eprops=[osm_id, highway, level, lanes, width, bicycle, bicycle_safety, foot, foot_safety,\n max_speed, motorcar, linestring])\n\n # we are gonna replace the original repeated nodes with a linestring\n e_path = g.new_ep('vector<int64_t>')\n for e in g.edges():\n e_path[e] = []\n\n vs = g.get_vertices()\n in_out_deg_2 = (g.get_in_degrees(vs) == 2) & (g.get_out_degrees(vs) == 2)\n\n logging.debug('selecting degree 4 candidates')\n candidates = set()\n for i, v in enumerate(vs):\n if in_out_deg_2[i]:\n ns = list(set(g.get_all_neighbors(v)))\n if len(ns) == 2:\n u, w = ns[0], ns[1]\n uv, vw, wv, vu = g.edge(u, v), g.edge(v, w), g.edge(w, v), g.edge(v, u)\n if highway[uv] == highway[vw] and highway[wv] == highway[vu]:\n candidates.add(v)\n logging.debug('found {} degree 4 candidates to simplify'.format(len(candidates)))\n\n seen = set()\n unregister_candidates = set()\n\n for i, candidate in enumerate(candidates):\n if i == 100000:\n logging.debug('100000 degree 4 candidates')\n if candidate in seen:\n continue\n\n seen.add(candidate)\n\n u, w = g.get_out_neighbors(candidate)\n is_u_fringe, is_w_fringe = u not in candidates, w not in candidates\n\n cu, cw = g.edge(candidate, u), g.edge(candidate, w)\n\n us = []\n ws = []\n\n while not is_u_fringe:\n seen.add(u)\n us.append(u)\n neighbors = set(g.get_out_neighbors(u))\n neighbors -= seen\n if len(neighbors) > 0:\n u = neighbors.pop()\n is_u_fringe = u not in candidates\n elif u == w:\n us.pop(-1)\n u = us.pop(-1)\n unregister_candidates.add(u)\n unregister_candidates.add(w)\n is_u_fringe = True\n is_w_fringe = True\n g.remove_edge(g.edge(s=u, t=w))\n g.remove_edge(g.edge(s=w, t=u))\n else:\n logging.debug('degree 2: we got here somehow {} {} {} {}', candidate, u, v,\n g.get_all_neighbors(candidate))\n break\n\n while not is_w_fringe:\n seen.add(w)\n ws.append(w)\n neighbors = set(g.get_out_neighbors(w))\n neighbors -= seen\n if len(neighbors) > 0:\n w = neighbors.pop()\n is_w_fringe = w not in candidates\n else:\n logging.debug('degree 2: we got here somehow {} {} {} {}', candidate, u, v,\n g.get_all_neighbors(candidate))\n break\n\n if is_u_fringe and is_w_fringe:\n e = g.add_edge(source=u, target=w)\n path = [u] + list(reversed(us)) + [candidate] + ws + [w]\n e_path[e] = [int(nodes_id[node]) for node in path]\n linestrings = [linestring[g.edge(a, b)] for a, b in pairwise(path)]\n linestring[e] = join_linestrings(linestrings)\n osm_id[e], highway[e], level[e], lanes[e], width[e], bicycle[e], bicycle_safety[e], foot[e], foot_safety[e], \\\n max_speed[e], motorcar[e] = osm_id[cw], highway[cw], level[cw], lanes[cw], width[cw], bicycle[cw], \\\n bicycle_safety[cw], \\\n foot[cw], foot_safety[cw], max_speed[cw], motorcar[cw]\n\n e = g.add_edge(source=w, target=u)\n path = [w] + list(reversed(ws)) + [candidate] + us + [u]\n e_path[e] = [int(nodes_id[node]) for node in path]\n linestrings = [linestring[g.edge(a, b)] for a, b in pairwise(path)]\n linestring[e] = join_linestrings(linestrings)\n osm_id[e], highway[e], level[e], lanes[e], width[e], bicycle[e], bicycle_safety[e], foot[e], foot_safety[e], \\\n max_speed[e], motorcar[e] = osm_id[cu], highway[cu], level[cu], lanes[cu], width[cu], bicycle[cu], \\\n bicycle_safety[cu], \\\n foot[cu], foot_safety[cu], max_speed[cu], motorcar[cu]\n\n else:\n logging.debug(\n 'unexpected behavior, source={0}, target={1}, candidate={2}, us={3}, ws={4}'.format(u, w, candidate, us,\n ws))\n\n unseen = candidates - seen\n if len(unseen) > 0:\n logging.debug(\n 'Network scan after degree 4 simplification uncomplete: candidates {0} have not been examined'.format(\n unseen))\n\n candidates -= unregister_candidates\n g.remove_vertex(list(candidates))\n\n vs = g.get_vertices()\n in_out_deg_1 = (g.get_in_degrees(vs) == 1) & (g.get_out_degrees(vs) == 1)\n\n logging.debug('selecting degree 2 candidates')\n candidates = set()\n for i, v in enumerate(vs):\n if in_out_deg_1[i]:\n u = g.get_in_neighbors(v)[0]\n w = g.get_out_neighbors(v)[0]\n\n if u != w:\n uv, vw = g.edge(u, v), g.edge(v, w)\n if highway[uv] == highway[vw]:\n candidates.add(v)\n logging.debug('found {} degree 2 candidates to simplify'.format(len(candidates)))\n\n seen = set()\n unregister_candidates = set()\n\n for candidate in candidates:\n if candidate in seen:\n continue\n\n seen.add(candidate)\n\n u = g.get_in_neighbors(candidate)[0]\n w = g.get_out_neighbors(candidate)[0]\n\n uc = g.edge(u, candidate)\n\n is_u_fringe, is_w_fringe = u not in candidates, w not in candidates\n\n us = []\n ws = []\n\n while not is_u_fringe:\n seen.add(u)\n us.append(u)\n neighbors = set(g.get_in_neighbors(u))\n neighbors -= seen\n if len(neighbors) > 0:\n u = neighbors.pop()\n is_u_fringe = u not in candidates\n elif u == w:\n us.pop(-1)\n u = us.pop(-1)\n unregister_candidates.add(u)\n unregister_candidates.add(w)\n is_u_fringe = True\n is_w_fringe = True\n g.remove_edge(g.edge(s=w, t=u))\n else:\n logging.debug('degree 1: we got here somehow {} {} {} {}', candidate, u, v,\n g.get_all_neighbors(candidate))\n break\n\n while not is_w_fringe:\n seen.add(w)\n ws.append(w)\n neighbors = set(g.get_out_neighbors(w))\n neighbors -= seen\n if len(neighbors) > 0:\n w = neighbors.pop()\n is_w_fringe = w not in candidates\n else:\n logging.debug('degree 1: we got here somehow {} {} {} {}', candidate, u, v,\n g.get_all_neighbors(candidate))\n break\n\n if is_u_fringe and is_w_fringe:\n e = g.add_edge(source=u, target=w)\n path = [u] + list(reversed(us)) + [candidate] + ws + [w]\n e_path[e] = [int(nodes_id[node]) for node in path]\n linestrings = [linestring[g.edge(a, b)] for a, b in pairwise(path)]\n linestring[e] = join_linestrings(linestrings)\n osm_id[e], highway[e], level[e], lanes[e], width[e], bicycle[e], bicycle_safety[e], foot[e], foot_safety[e], \\\n max_speed[e], motorcar[e] = osm_id[uc], highway[uc], level[uc], lanes[uc], width[uc], bicycle[uc], \\\n bicycle_safety[uc], \\\n foot[uc], foot_safety[uc], max_speed[uc], motorcar[uc]\n else:\n logging.error('unexpected behavior, source={0}, target={1}, candidate={2}, us={3}, ws={4}', u, w, us, ws)\n\n unseen = candidates - seen\n if len(unseen) > 0:\n logging.debug(\n 'Network scan after degree 2 simplification not finished: candidates {0} have not been examined'.format(\n unseen))\n\n candidates -= unregister_candidates\n g.remove_vertex(list(candidates))\n\n logging.debug(' linestring path')\n edges_tuples = []\n for e in g.edges():\n source, target, path = nodes_id[e.source()], nodes_id[e.target()], e_path[e]\n if len(path) == 0:\n path = [source, target]\n else:\n path = [int(i) for i in path]\n\n e_tuples = (g.edge_index[e], source, target, path,\n osm_id[e], highway[e], level[e], lanes[e], width[e], bicycle[e], bicycle_safety[e], foot[e],\n foot_safety[e], max_speed[e], motorcar[e], linestring[e])\n edges_tuples.append(e_tuples)\n\n df_edges_simplified = pd.DataFrame.from_records(edges_tuples, index='edge_id',\n columns=['edge_id', 'u', 'v', 'path', 'osm_id', 'highway',\n 'level', 'lanes', 'width', 'bicycle', 'bicycle_safety',\n 'foot', 'foot_safety', 'max_speed', 'motorcar',\n 'geometry'])\n\n df_edges_simplified.osm_id = df_edges_simplified.osm_id.str.split('-').str[0]\n df_edges_simplified = gpd.GeoDataFrame(df_edges_simplified, geometry='geometry')\n df_edges_simplified.crs = df.crs\n return df_edges_simplified",
"def build_tree_biopython_distance(\n algo: str,\n population: typing.Sequence[HereditaryStratigraphicColumn],\n estimator: str,\n prior: typing.Union[str, typing.Any],\n taxon_labels: typing.Optional[typing.Iterable],\n force_common_ancestry: bool,\n negative_origin_time_correction_method: typing.Optional[str],\n) -> pd.DataFrame:\n\n # biopython doesn't represent empty tree elegantly\n # for simplicity, return early for this special case\n if len(population) == 0:\n return alifestd_make_empty()\n\n taxon_labels = list(\n opyt.or_value(\n taxon_labels,\n map(str, range(len(population))),\n )\n )\n\n distance_matrix = build_distance_matrix_biopython(\n population,\n estimator,\n prior,\n taxon_labels,\n force_common_ancestry or None,\n )\n constructor = getattr(BioPhyloTree.DistanceTreeConstructor(), algo)\n biopython_tree = (\n BioPhyloTree.BaseTree.Tree()\n if not distance_matrix\n else constructor(distance_matrix)\n )\n\n # convert, calibrate, and return\n alifestd_df = apc.biopython_tree_to_alife_dataframe(biopython_tree)\n alifestd_df[\"taxon_label\"] = alifestd_df[\"name\"]\n\n min_edge_length = alifestd_df[\"branch_length\"].min()\n if min_edge_length < -1e-12: # why? pytest approx absolute tolerance\n warnings.warn(\n f\"\"\"Negative branch length(s) estimated with minimum {\n min_edge_length\n }; returning estimated tree without further rerooting \"\"\"\n \"or origin time estimation. \"\n )\n return alifestd_df\n\n # set near-zero negative branch lengths to zero\n alifestd_df[\"branch_length\"] = alifestd_df[\"branch_length\"].clip(lower=0)\n\n id_lookup = dict(zip(alifestd_df[\"taxon_label\"], alifestd_df[\"id\"]))\n col_lookup = dict(zip(taxon_labels, population))\n\n leaf_origin_times = {\n id_lookup[taxon_label]: col_lookup[taxon_label].GetNumStrataDeposited()\n - 1\n for taxon_label in taxon_labels\n }\n alifestd_df = time_calibrate_tree(\n alifestd_df, leaf_origin_times, negative_origin_time_correction_method\n )\n\n alifestd_df = append_genesis_organism(alifestd_df, mutate=True)\n\n assert alifestd_validate(alifestd_df)\n assert len(alifestd_find_root_ids(alifestd_df))\n\n return alifestd_df",
"def expand(df,dict,onto_df):\n # Create an empty output dataframe\n \n #########\n # ORGAN #\n #########\n if 'organs' in dict:\n\n organs_dict = {}\n all_organs = set()\n onto_anatomy = onto_df[(onto_df.ontology == 'anatomy')]\n\n # get for each organ get all its childs and crate a dict\n for organ in dict['organs']:\n all_organs.union([organ])\n related_organs = onto_anatomy[(onto_anatomy.parent_term == organ)]\n all_organs = all_organs.union(related_organs.child_term)\n organs_dict.update({n: organ for n in related_organs.child_term})\n\n df = df[df['organ_normalised'].isin(all_organs)]\n df.loc[:, 'organ_normalised'] = df['organ_normalised'].map(organs_dict)\n\n\n ###############\n # OBSERVATION #\n ###############\n if 'observations' not in dict:\n\n onto_histopatho = onto_df[(onto_df['ontology'] == 'histopathology')\n & (onto_df['parent_term'] != \"morphologic change\")]\n\n findings_out = pd.merge(df, onto_histopatho, how='left',\n left_on='observation_normalised',\n right_on='child_term')\n\n findings_out = findings_out[['study_id', 'relevance', 'parent_term',\n 'organ_normalised', 'dose', 'subst_id', 'report_number']]\n\n findings_out=findings_out.rename(index=str, columns={\"parent_term\": \"observation_normalised\"})\n findings_out.drop_duplicates(inplace=True)\n\n else:\n\n observation_dict = {}\n all_observations = set()\n onto_histopatho = onto_df[(onto_df.ontology == 'histopathology')]\n\n # get for each observation all its childs and crate a dict\n for observation in dict['observations']:\n\n all_observations.union([observation])\n related_observation = onto_histopatho[(onto_histopatho.parent_term == observation)]\n all_observations = all_observations.union(related_observation.child_term)\n observation_dict.update({n: observation for n in related_observation.child_term})\n\n findings_out = df[df['observation_normalised'].isin(all_observations)]\n findings_out.loc[:, 'observation_normalised'] = df['observation_normalised'].map(observation_dict)\n\n\n return findings_out",
"def as_phyloxml(self):\n\n def _rec_phyloxml(node):\n n = et.Element(\"clade\")\n tax = et.SubElement(n, \"taxonomy\")\n id_ = et.SubElement(tax, \"id\", provider=\"uniprot\")\n id_.text = str(node['NCBITaxonId'])\n\n children = []\n for child in self._direct_children_taxa(node['NCBITaxonId']):\n children.append(_rec_phyloxml(child))\n if len(children) == 0:\n try:\n g = self.genomes[int(node['NCBITaxonId'])]\n code = et.SubElement(tax, 'code')\n code.text = g.uniprot_species_code\n except ValueError:\n pass\n sci = et.SubElement(tax, 'scientific_name')\n sci.text = node['Name'].decode()\n n.extend(children)\n return n\n\n root = et.Element('phyloxml', xmlns=\"http://www.phyloxml.org\")\n phylo = et.SubElement(root, \"phylogeny\", rooted=\"true\", rerootable=\"false\")\n name = et.SubElement(phylo, \"name\")\n name.text = \"(Partial) species phylogeny from OMA Browser\"\n phylo.append(_rec_phyloxml(self._get_root_taxon()))\n\n return et.tostring(root, encoding='utf-8')",
"def build_subtrees(self, df, subtree_kwargs):\n raise NotImplementedError",
"def reset_node_ids(df):\n le = LabelEncoder()\n all_node_names = list(set(df['from_name'].values.tolist() + df['to_name'].values.tolist()))\n le.fit(all_node_names)\n df['from_id'] = le.transform(df['from_name'])\n df['to_id'] = le.transform(df['to_name'])\n return df, le",
"def assign_major_category_branches(nodes_df: pd.DataFrame):\n # Grab the map of categories --> major branches\n logging.info(f\"Grabbing major branch info from tree-viz-biolink..\")\n res = requests.get(\"https://tree-viz-biolink.herokuapp.com/major_branches/er/3.0.3\")\n categories_to_major_branch = res.json()[\"category_to_major_branch\"]\n\n # Assign each node its category branch\n logging.info(f\"Assigning nodes to their major category branches..\")\n nodes_df[\"major_branch\"] = nodes_df.category.map(categories_to_major_branch)\n logging.info(f\"After preliminary assignment, nodes DataFrame is: \\n{nodes_df}\")\n\n logging.info(f\"For nodes whose major branch couldn't be determined, we'll consider their category \"\n f\"(NamedThing or BiologicalEntity) to be their major branch..\")\n # Note: NaN value is not equal to itself..\n nodes_df.major_branch = np.where(nodes_df.major_branch != nodes_df.major_branch, nodes_df.category, nodes_df.major_branch)\n\n logging.info(f\"Nodes DataFrame after assigning major branches is: \\n{nodes_df}\")",
"def __retrieve_phylogeny_by_identifier(self, docker, **kwargs):\n id_array = docker.to_array(exclude_missing=True)\n if (\n self.configs[\"phy_refrep\"] == \"tid\"\n and self.configs[\"phy_method\"] == \"infer\"\n ):\n tmp_tree = self.client.infer_topology_by_tid(\n ids=id_array, subreps=self.configs[\"phy_sub_nodes\"], include_rid=False\n )\n elif (\n self.configs[\"phy_refrep\"] == \"rid\"\n and self.configs[\"phy_method\"] == \"infer\"\n ):\n tmp_tree = self.client.infer_topology_by_rid(ids=id_array)\n elif (\n self.configs[\"phy_refrep\"] == \"tid\"\n and self.configs[\"phy_method\"] == \"prune\"\n ):\n tmp_tree = self.client.prune_tree_by_tid(\n ids=id_array, subreps=self.configs[\"phy_sub_nodes\"], include_rid=False\n )\n elif (\n self.configs[\"phy_refrep\"] == \"rid\"\n and self.configs[\"phy_method\"] == \"prune\"\n ):\n tmp_tree = self.client.prune_tree_by_rid(ids=id_array)\n else:\n raise ValueError(\"`phy_refrep` or `phy_method` is invalid.\")\n\n tmp_identifier_valids = docker.get_subset(exclude_missing=True)\n id_rev_map = {str(v): str(k) for k, v in tmp_identifier_valids.data.items()}\n tmp_tree.replace_nodes_by_map(id_rev_map, only_tips=True)\n new_metadata = {\n \"configs\": self.configs,\n \"id-map\": tmp_identifier_valids.data,\n \"master\": docker.wrap_meta(),\n }\n return DockerPhylogenyMedium(\n tmp_tree,\n ignore_tips=self.configs[\"phy_ignore_tips\"],\n name=docker.name,\n metadata=new_metadata,\n )",
"def descend_template_phylogeny_networkx(\n tree: nx.DiGraph,\n seed_column: HereditaryStratigraphicColumn,\n extant_nodes: typing.Optional[typing.Iterable[typing.Any]] = None,\n progress_wrap: typing.Callable = lambda x: x,\n) -> typing.List[HereditaryStratigraphicColumn]:\n\n # handle empty case\n if len(tree) == 0:\n return []\n\n reversed_tree = tree.reverse(copy=False)\n root_node = ip.popsingleton(\n node for node in tree.nodes if tree.in_degree(node) == 0\n )\n leaf_nodes = [node for node in tree.nodes if tree.out_degree(node) == 0]\n\n return descend_template_phylogeny(\n ascending_lineage_iterables=(\n unpairwise(nx.dfs_edges(reversed_tree, extant_node))\n if len(tree) > 1\n else (extant_node,)\n for extant_node in opyt.or_value(extant_nodes, leaf_nodes)\n ),\n descending_tree_iterable=(\n unpairwise(nx.dfs_edges(tree, root_node))\n if len(tree) > 1\n else (root_node,)\n ),\n get_parent=lambda node: ip.poursingleton(reversed_tree[node]),\n get_stem_length=lambda node: 1,\n seed_column=seed_column,\n demark=lambda x: x,\n progress_wrap=progress_wrap,\n )",
"def edge_list_build(input_path, output_path):\n\n start_time = time.time()\n\n df = pd.read_csv(input_path, sep='\\t', header=None)\n\n for col in range(1, len(df.columns)):\n df.iloc[:, col] = df.iloc[:, col-1] + '_' + df.iloc[:, col]\n\n n_divs = len(df.columns) - 1\n\n\n dict_node_names = {}\n\n for id, node_name in enumerate(np.unique(df.values.flatten())):\n dict_node_names[node_name] = id + 1\n\n tmp_df = pd.DataFrame.from_dict(dict_node_names, orient='index')\n tmp_df.reset_index(inplace=True)\n tmp_df.rename({'index': 'nodes', 0: 'hash'}, inplace=True, axis=1)\n\n hash_df = tmp_df['nodes'].str.split('_', n=n_divs, expand=True)\n hash_df = pd.concat([hash_df, tmp_df['hash']], axis=1)\n\n for col_name in df.columns:\n df[col_name] = df[col_name].map(dict_node_names)\n\n df['root'] = 0\n colnames = df.columns.values\n colnames = list(colnames[-1:]) + list(colnames[:-1])\n df = df[colnames]\n\n df_tuples = pd.DataFrame()\n\n for i in range(len(df.columns) - 1):\n df_tuples[i] = list(df[df.columns[i:i + 2]].itertuples(index=False, name=None))\n del df\n gc.collect()\n\n nodes_list = []\n\n for col_id in range(0, df_tuples.shape[1]):\n father_child = df_tuples.iloc[:, col_id].drop_duplicates().values\n nodes_list.extend(father_child)\n\n graph = nx.DiGraph(nodes_list)\n graph_bfs = nx.bfs_tree(graph, 0)\n \n path = output_path + '.hashmap'\n hash_df.to_csv(path, index=False, sep='\\t')\n end_time = time.time()\n print(\"Time spent creating tree from csv file:\", end_time - start_time)\n return graph_bfs"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Provides list of github organization urls based on authenticated user. | def get_orgs():
url = "https://api.github.com/user/orgs"
org_urls = []
orgs = utils.get_json(url)
for org in orgs:
org_urls.append(org["url"])
return org_urls | [
"def urls(gh, user):\n return [repo.url for repo in getuserrepos(gh, user)]",
"def organizations():\n page = int(flask.request.args.get('page', 0))\n gh_api = flask.current_app.container.get(\n 'gh_api', token=flask.session['github_token']\n )\n\n gh_orgs = gh_api.get('/user/orgs', page=page)\n orgs_link = gh_api.app_connections_link\n\n return flask.render_template(\n 'manage/orgs.html', orgs=gh_orgs.data,\n actual_page=gh_orgs.actual_page, total_pages=gh_orgs.total_pages,\n orgs_link=orgs_link,\n\n )",
"def repositories():\n return user.repos()",
"def _get_orgs(self):\n return self.api.get('/v2/organizations')",
"def list_repos(self):\n user = Github(self.token).get_user()\n repos= {user.login: user.get_repos()}\n for org in user.get_orgs():\n repos[org.login] = org.get_repos()\n return repos",
"def organizations(self):\n return self.get('{}/orgs'.format(ApiVersion.A1.value))",
"def get(self):\n return {'url': self._generate_github_auth_uri(g.user)}",
"def user_repositories(self, request, *args, **kwargs):\n owner_username: str = kwargs.get('login')\n user: GithubUser = get_object_or_404(GithubUser.objects.all(), login=owner_username)\n queryset: QuerySet = user.repositories.all()\n\n page = self.paginate_queryset(queryset)\n if page is not None:\n serializer = self.get_serializer(page, many=True)\n return self.get_paginated_response(serializer.data)\n\n serializer = self.get_serializer(queryset, many=True)\n return Response(serializer.data)",
"def get_organization_links_by_page(self):\n return self.get_resource_by_page(\"/orgs\")",
"def repositories():\n page = int(flask.request.args.get('page', 0))\n gh_api = flask.current_app.container.get(\n 'gh_api', token=flask.session['github_token']\n )\n\n gh_repos = gh_api.get('/user/repos', page=page)\n user = flask_login.current_user.github_user\n active_ids = [repo.github_id for repo in user.repositories]\n return flask.render_template(\n 'manage/repos.html', repos=gh_repos.data,\n actual_page=gh_repos.actual_page, total_pages=gh_repos.total_pages,\n Repository=Repository, active_ids=active_ids\n )",
"def list_public_repos():\n return Collaborator.objects.filter(user__username=settings.PUBLIC_ROLE)",
"def get_repo_options(account, **kwargs):\n client = AsyncHTTPClient()\n uri = \"https://api.github.com/user/repos?per_page=100\"\n data = []\n while uri is not None:\n req = account.get_request(uri, headers={\"Accept\": \"application/vnd.github.moondragon+json\"})\n response = yield client.fetch(req)\n response_object = json.loads(response.body.decode('utf-8'))\n data += response_object\n links = parse_link_header(response.headers.get('Link', ''))\n uri = links.get('next', None)\n return [{\"title\": repo['full_name'], \"value\": repo['full_name']}\n for repo in data]",
"def get_user_repo_id_list(self, request):\n repo_ids = []\n\n email = request.user.username\n org_id = None\n if is_org_context(request):\n org_id = request.user.org.org_id\n\n # owned_repos\n if org_id:\n repo_ids.extend(r.id for r in syncwerk_api.get_org_owned_repo_list(\n org_id, email, ret_corrupted=True))\n else:\n repo_ids.extend(r.id for r in syncwerk_api.get_owned_repo_list(email,\n ret_corrupted=True))\n\n # shared repos\n shared_repos = []\n if org_id:\n shared_repos = syncwerk_api.get_org_share_in_repo_list(org_id,email, -1, -1)\n else:\n shared_repos = syncwerk_api.get_share_in_repo_list(email, -1, -1)\n\n for repo in shared_repos:\n # This mean not sub repo\n if not repo.origin_repo_id:\n repo_ids.append(repo.repo_id)\n\n # Group repos\n groups = get_groups_by_user(email, None)\n repo_ids.extend(rid for rid in get_group_repos(email, None, groups))\n\n # org repos\n if request.user.permissions.can_view_org():\n repo_ids.extend(r.repo_id for r in list_inner_pub_repos(request))\n \n return list(set(repo_ids))",
"def n_public_repos(gh, user):\n return getuser(gh, user).public_repos",
"def _urls(repository, commit, mirrors):\n return [\n x.format(\n repository = repository,\n commit = commit,\n )\n for x in mirrors.get(\"github\")\n ]",
"def get_collaborator_repos() -> Any:\n params = {\"affiliation\": \"collaborator\"}\n url = USER_ENDPOINT.copy()\n url.path /= \"repos\"\n response = safe_request(requests.get, url, headers, params)\n return response.json()",
"def get_org_list():\r\n\r\n resp = requests.get(''.join([Kegg.BASE_URL, 'list/organism']))\r\n return resp.text",
"async def All_orgs():\n\n links_13 = []\n links_14 = []\n valid_url = \"/?archive/?gsoc/\\d+[0-9]/orgs/[a-zA-Z]+\"\n for year in range(2009, 2016):\n year_url = melange + \"/archive/gsoc/{}\".format(year)\n soup = await get_page(year_url)\n\n for url in soup.find_all('a'):\n if re.match(valid_url, url.get(\"href\")):\n if year <= 2013:\n links_13.append(join(melange, url.get(\"href\")[1:]))\n else:\n links_14.append(join(melange, url.get(\"href\")[1:]))\n return links_13, links_14",
"def _get_organizations(self):\n return self.__organizations"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Provides a list of Member urls per organizations. param orgs either a list of urls pointing to organizations or a single org name return list of member urls | def list_members(orgs):
members =[]
if isinstance(orgs, list):
#if list of orgs for each org get members list
for url in orgs:
#append /member to url - member_url is not valid canidate without a member list
url = url + "/members"
print("Checking " + url)
members_data = utils.get_json(url)
for member in members_data:
members.append(member["url"])
return members
else:
#build url from input org name and return member list
url = "https://api.github.com/orgs/" + orgs + "/members"
members_data = utils.get_json(url)
#check for invalid GitHub credentials or invalid github org name
try:
for member in members_data:
members.append(member["url"])
return members
except TypeError:
if(members_data["message"] == "Not Found"):
print("That organization doesn't exist try again\n")
raise SystemExit
elif(members_data["message"] == "Bad credentials"):
print("Please verify GitHub credentials are correct in config.py")
raise SystemExit
else:
print (members_data)
raise SystemExit | [
"def get_orgs():\n \n url = \"https://api.github.com/user/orgs\"\n \n org_urls = []\n orgs = utils.get_json(url)\n \n for org in orgs:\n org_urls.append(org[\"url\"])\n \n return org_urls",
"def organizations(self):\n return self.get('{}/orgs'.format(ApiVersion.A1.value))",
"def _get_org_members(self):\n url = f\"{BASE_URL}/orgs/{ORG}/members\"\n return self.fetch_all_pages(url, flatten=True, query_params={\"per_page\": 100})",
"def collect_org_members(self):\n log.info(\"GHUB\", \"Collecting org members.\")\n member_urls = [member[\"url\"] for member in self._get_org_members()]\n members = []\n for member_url in member_urls:\n log.info(\"GHUB\", f\"Fetching member '{member_url}'.\")\n _, member_raw, _ = self.get(member_url)\n member_parsed = json_reducer.reduce(PERSON_SCHEMA, member_raw)\n members.append(member_parsed)\n return members",
"def _get_orgs(self):\n return self.api.get('/v2/organizations')",
"def get_org_list():\r\n\r\n resp = requests.get(''.join([Kegg.BASE_URL, 'list/organism']))\r\n return resp.text",
"def get_members_repos(org_list):\n print(\"\\nGetting repositories of all members.\")\n jsonMembersRepo_list = []\n columns_list = [\n 'organization',\n 'user',\n 'full_name',\n 'fork',\n 'stargazers_count',\n 'forks_count',\n 'language',\n 'description'\n ]\n for org in org_list:\n print('\\nGetting members of', org)\n jsonMembers = load_json(\"https://api.github.com/orgs/\" + org +\n \"/members?per_page=100\")\n for member in jsonMembers:\n print('Getting repositories of', member['login'])\n jsonMembersRepos = load_json(\"https://api.github.com/users/\" +\n member['login'] +\n \"/repos?per_page=100\")\n for repo in jsonMembersRepos:\n # Add fields to make CSV file more usable\n repo['organization'] = org\n repo['user'] = member['login']\n # Python 2: Using smart_str to deal with encodings\n repo['description'] = smart_str(repo['description'])\n jsonMembersRepo_list.append(repo)\n generate_csv(\"members-list\", jsonMembersRepo_list, columns_list)",
"def get_organization_links_by_page(self):\n return self.get_resource_by_page(\"/orgs\")",
"def get_organizations():\n orgs = set()\n data = modules_data().get('module', {})\n for module in data:\n if module['organization'] != 'example' and module['organization'] != 'missing element':\n orgs.add(module['organization'])\n orgs = list(orgs)\n return {'contributors': orgs}",
"def organizations():\n page = int(flask.request.args.get('page', 0))\n gh_api = flask.current_app.container.get(\n 'gh_api', token=flask.session['github_token']\n )\n\n gh_orgs = gh_api.get('/user/orgs', page=page)\n orgs_link = gh_api.app_connections_link\n\n return flask.render_template(\n 'manage/orgs.html', orgs=gh_orgs.data,\n actual_page=gh_orgs.actual_page, total_pages=gh_orgs.total_pages,\n orgs_link=orgs_link,\n\n )",
"def list_all_organizations(ctx):\n pprint(ctx.obj.orgs.get().data)",
"async def All_orgs():\n\n links_13 = []\n links_14 = []\n valid_url = \"/?archive/?gsoc/\\d+[0-9]/orgs/[a-zA-Z]+\"\n for year in range(2009, 2016):\n year_url = melange + \"/archive/gsoc/{}\".format(year)\n soup = await get_page(year_url)\n\n for url in soup.find_all('a'):\n if re.match(valid_url, url.get(\"href\")):\n if year <= 2013:\n links_13.append(join(melange, url.get(\"href\")[1:]))\n else:\n links_14.append(join(melange, url.get(\"href\")[1:]))\n return links_13, links_14",
"def test_getorgs(self):\n pass",
"def organizations(self):\n self.elements('organizations')",
"def _get_organizations(self):\n return self.__organizations",
"def list_orgs(self):\n orgs = list(self.orgs.keys())\n orgs.sort()\n return orgs",
"def get_members_info(org_list):\n print(\"\\nGetting user information of all members.\")\n jsonMembersInfo_list = []\n columns_list = [\n 'organization',\n 'login',\n 'name',\n 'url',\n 'type',\n 'company',\n 'blog',\n 'location',\n 'email'\n ]\n for org in org_list:\n print('\\nGetting members of', org)\n jsonMembers = load_json(\"https://api.github.com/orgs/\" + org +\n \"/members?per_page=100\")\n for member in jsonMembers:\n print(\"Getting user information for\", member[\"login\"])\n jsonMember = load_json(\"https://api.github.com/users/\" +\n member[\"login\"] + \"?per_page=100\",\n memberscrape=True)\n # Add field to make CSV file more usable\n jsonMember[\"organization\"] = org\n # Python 2: Using smart_str to deal with encodings\n jsonMember[\"location\"] = smart_str(jsonMember['location'])\n jsonMember[\"name\"] = smart_str(jsonMember['name'])\n jsonMember[\"company\"] = smart_str(jsonMember['company'])\n jsonMember[\"email\"] = smart_str(jsonMember['email'])\n jsonMembersInfo_list.append(jsonMember)\n generate_csv(\"members-info\", jsonMembersInfo_list, columns_list)",
"def organizations(self) -> pulumi.Output[Optional[Sequence[str]]]:\n return pulumi.get(self, \"organizations\")",
"def urls(gh, user):\n return [repo.url for repo in getuserrepos(gh, user)]"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Provides a list of Member urls that have [attribute] is null. param attribute to check for null value params memberUrls List of member urls to check return list of member urls with null [attribute] field | def check_for_null(attribute, memberUrls):
attributeNotFound =[]
for url in memberUrls:
member_data = utils.get_json(url)
if member_data[attribute] is None:
#TODO: TBD Could grab email here if speed was an issue
attributeNotFound.append(url)
return attributeNotFound | [
"def list_filter_field_null(list_data, target, source):\n result = []\n for i in list_data:\n if (i[target] and i[source] ) is not None:\n result.append(i)\n return result",
"def get_parliament_members_urls(self) -> list:\n directory = self.read_html(self.url)\n return [\n a.attrs[\"href\"]\n for a in directory.select(\".single-mp a\")\n if a.attrs[\"href\"].startswith(\"https\")\n ]",
"def all_urls(self):\r\n return [url for url in\r\n [\r\n self.thumbnail_url,\r\n self.video_ogv_url,\r\n self.video_mp4_url,\r\n self.video_webm_url,\r\n self.video_flv_url,\r\n self.source_url,\r\n ]\r\n if url is not None and url != ''\r\n ]",
"def every_non_existing_owner_should_not_have_profile_link(context):\n items = context.response.json()['items']\n for item in items:\n owner = item['owner']\n if not owner['user_type'] == 'does_not_exist':\n continue\n assert 'link' not in owner\n logging.debug(\n 'Not existing Owner %s does not have a valid profile link',\n owner['display_name'])",
"def _urls(*, repository, commit, mirrors):\n result_with_nulls = [\n _format_url(\n pattern = x,\n repository = repository,\n commit = commit,\n )\n for x in mirrors.get(\"github\")\n ]\n return [\n url\n for url in result_with_nulls\n if url != None\n ]",
"def every_non_existing_owner_should_not_have_profile_image_link(context):\n items = context.response.json()['items']\n for item in items:\n owner = item['owner']\n if not owner['user_type'] == 'does_not_exist':\n continue\n assert 'profile_image' not in owner\n logging.debug(\n 'Not existing Owner %s does not have a valid profile image link',\n owner['display_name'])",
"def listingURLs(soup):\n\n #Get URLs\n itemListing = soup.find_all(class_=\"user-ad-row link link--base-color-inherit link--hover-color-none link--no-underline\")\n itemListing += soup.find_all(class_=\"user-ad-row user-ad-row--featured-or-premium link link--base-color-inherit link--hover-color-none link--no-underline\")\n itemListing += soup.find_all(class_=\"user-ad-row user-ad-row--premium user-ad-row--featured-or-premium link link--base-color-inherit link--hover-color-none link--no-underline\")\n #Create list\n urlList = [i['href'] for i in itemListing]\n return urlList",
"def _getMemberList(self,member_exp):\n\t\t# check if there are multiple groups of host names\n\t\tsemicolonindex = member_exp.find(\";\")\n\t\tif semicolonindex > -1:\n\t\t\tgroupList = member_exp.split(\";\")\n\t\telse:\n\t\t\tgroupList = [member_exp]\n\t\t\n\t\tmemberList = []\n\t\tfor group in groupList:\n\t\t\ttry: \n\t\t\t\trawlist = group.split(\",\")\n\t\t\t\tnodelist = []\n\t\t\t\tnodetype = rawlist[0]\n\t\t\t\tstart = int(rawlist[1])\n\t\t\t\t# Check if the end number is a number or n\n\t\t\t\tif rawlist[2] == \"n\":\n\t\t\t\t\tend = len(self.vnodes)\n\t\t\t\telse:\n\t\t\t\t\tend = int(rawlist[2])\n\t\t\t\t#Generate full hostnames, e.g. sca06cn01\n\t\t\t\tfor num in range(start,end+1):\n\t\t\t\t\tif (num < 10):\n\t\t\t\t\t\tnodename = self.rackName+nodetype+\"0\"+str(num)\n\t\t\t\t\telse:\n\t\t\t\t\t\tnodename = self.rackName+nodetype+str(num)\n\t\t\t\t\t\t\n\t\t\t\t\tnodelist.append(nodename)\n\t\t\t\tmemberList += nodelist\n\t\t\texcept:\n\t\t\t\t#Catches any format error\n\t\t\t\tself.logger.error(\"ibswitch test config file access type invalid format\")\n\t\t\t\tbreak\n\t\t\n\t\treturn memberList",
"def not_empty(self, attrList):\n return (not attrList == [])",
"def _find_list_member(member_email, fields):\n # TODO: Some day MailChimp will add support for filtering, and this can be\n # made less brute-force.\n\n if not member_email:\n logging.error('mailchimp._find_list_member called with empty member_email')\n flask.abort(500, description='bad data in sheet')\n\n # We may need to page through results to find the member we want.\n offset = 0\n while True:\n url = 'members?count=100&offset=%d' % (offset,)\n res = _make_request(url, 'GET')\n\n for member in res['members']:\n if member[_EMAIL_ADDRESS] == member_email:\n return member\n\n offset += len(res['members'])\n total = res['total_items']\n\n if offset >= total or not res['members']:\n # We paged all the way through\n break\n\n return None",
"def __fetch_url(self):\n with get(self.url) as r:\n urls = html.fromstring(r.text).xpath(\"//a/@href\")\n\n return [url for url in urls \n if url.startswith('http') and not any(url.endswith(s) for s in self.blacklist) \n and not ':8' in url]",
"def _getMembers(self, elem):\n res = []\n for mem in elem.iter(\"member\"):\n res.append((mem.attrib[\"type\"], mem.attrib[\"ref\"], mem.attrib[\"role\"]))\n return res",
"def get_urls():\n return get_unique_values('url')",
"def testMatchUrlEmptyUrl(self):\n self.assertFalse(cb_url_lib.MatchUrl([], self.token_list))",
"def add_memberlist(self,member_list):\n #ml = [m.strip(string.whitespace) for m in member_list.replace(';',',').split(',') if len(m) > 4]\n if isinstance(member_list,(list)):\n ml_temp = member_list\n elif isinstance(member_list,(str,unicode)):\n ml_temp = member_list.replace(';',',').lower().split(',')\n else:\n raise Exception(\"Memberlist must be list, or comma delimited string\")\n cl = [ e.strip(string.whitespace) for e in ml_temp if len(e) > 5]\n \n ml = ['%s' % m.member.email.strip(string.whitespace).lower() for m in self.members]\n \n newlist = [e for e in cl if not ml.__contains__(e.strip(string.whitespace))]\n \n removelist = [e for e in ml if not cl.__contains__(e.strip())]\n [self.remove_member(e) for e in removelist]\n addedusers = [self.add_member(e) for e in newlist]\n newtosite = [e for e in addedusers if e != None]\n newtogroup = [e for e in newlist if not addedusers.__contains__(e)]\n #self.contacts = ','.join(self.__members)\n return newtogroup, newtosite",
"def _filter_url_list(self, regex_pattern: str) -> None:\n matcher = re.compile(regex_pattern)\n filtered_list = []\n if self.url_list:\n for url in self.url_list:\n if matcher.search(url.url):\n filtered_list.append(url)\n self.url_list = filtered_list",
"def get_member(self, filter_, attrlist=None):\n result = self.search('o=com,dc=mozilla', filter_, attrlist)\n if result == False:\n raise self.SearchError\n elif result == []:\n return []\n return result[1]",
"def test_rolodex_urls_no_ids(self):\n r = Recipient(email='a@example.com')\n self.assertEqual(r.rolodex_person_url, None)\n self.assertEqual(r.rolodex_organization_url, None)\n self.assertEqual(r.rolodex_contact_url, None)",
"def links_processor(self,links):\n ret_links = list()\n if links:\n for link in links:\n if not link.nofollow:\n ret_links.append(link)\n return ret_links"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get loan originations for a given lender, county combination. This ignores year for the moment. | def loan_originations(request_dict):
state_fips = request_dict.get('state_fips', '')
county_fips = request_dict.get('county_fips', '')
lender = request_dict.get('lender', '')
if state_fips and county_fips and lender:
records = HMDARecord.objects.filter(
countyfp=county_fips, lender=lender, statefp=state_fips,
action_taken__lte=6) # actions 7-8 are preapprovals to ignore
query = records.values(
'geoid', 'geoid__census2010households__total'
).annotate(volume=Count('geoid'))
data = {}
for row in query:
data[row['geoid']] = {
'volume': row['volume'],
'num_households': row['geoid__census2010households__total'],
'volume_per_100_households': volume_per_100_households(
row['volume'], row['geoid__census2010households__total'])
}
return data
else:
return HttpResponseBadRequest(
"Missing one of state_fips, county_fips, lender") | [
"def get_land_conso_per_year(self, level, group_name=None):\n fields = Cerema.get_art_field(self.analyse_start_date, self.analyse_end_date)\n qs = self.get_cerema_cities(group_name=group_name)\n qs = qs.values(level)\n qs = qs.annotate(**{f\"20{field[3:5]}\": Sum(field) / 10000 for field in fields})\n return {row[level]: {year: row[year] for year in self.years} for row in qs}",
"def get_origins(self, account_id, **kwargs):\r\n\r\n return self.account.getOriginPullMappingInformation(id=account_id,\r\n **kwargs)",
"def _fetch_laus_data(year=None):\n global _SIMPLECOUNT_COLUMNS\n\n try:\n if year is None:\n year = _get_max_year([27]) + 1\n url = f'http://www.ides.illinois.gov/LMI/Local%20Area%20Unemployment%20Statistics%20LAUS/historical/{year}-moaa.xls'\n\n raw = pd.read_excel(url, skiprows=6)\n raw.columns = ['fips', 'area', 'year', 'month', 'force', 'employed', 'unemployed', 'rate']\n \n filtered = raw[(~raw.fips.isna()) & (raw.month == 13)].drop(columns=['area', 'month', 'rate'])\n filtered.columns = ['fips', 'year', '1030', '1551', '1550']\n\n pivoted = pd.melt(\n filtered,\n id_vars = ['fips', 'year'],\n value_vars=['1030', '1550', '1551'],\n var_name = 'fk_simplecount_indicator'\n )\n \n pivoted['fk_simplecount_county'] = (pivoted['fips'] + 1) / 2\n\n return pivoted[_SIMPLECOUNT_COLUMNS]\n except HTTPError as e:\n if e.code == 404:\n raise ValueError(\"WARNING: Employment data is up to date.\")\n except:\n raise",
"def get_coordinates(films_by_year: list) -> list:\n locations = []\n for i, film in enumerate(films_by_year):\n try:\n location = geolocator.geocode(film[1])\n except GeocoderUnavailable:\n continue\n if location is None:\n continue\n locations.append(\n [films_by_year[i][0], (location.latitude, location.longitude)])\n return locations",
"def ret_lYM(iYM, eYM):\n iYear, iMon = iYM\n eYear, eMon = eYM\n lYM = []\n for Year in range(iYear, eYear+1):\n if iYear == eYear:\n lMon = list(range(iMon,eMon+1))\n elif Year == iYear:\n lMon = list(range(iMon,12+1))\n elif Year == eYear:\n lMon = list(range(1,eMon+1))\n else:\n lMon = list(range(1,12+1)) \n\n for Mon in lMon:\n lYM.append([Year,Mon])\n return lYM",
"def get_years(env, comp):\n\n # define component-year mapping for model\n comp_lookup = {'atm' : {'start_year':'ATMDIAG_test_first_yr', 'num_years':'ATMDIAG_test_nyrs'},\n 'ice' : {'start_year':'ICEDIAG_BEGYR_CONT', 'stop_year':'ICEDIAG_ENDYR_CONT'},\n 'lnd' : {'start_year':'LNDDIAG_clim_first_yr_1', 'num_years':'LNDDIAG_clim_num_yrs_1'},\n 'ocn' : {'start_year':'OCNDIAG_YEAR0', 'stop_year':'OCNDIAG_YEAR1'}}\n\n # define component-year mapping for control\n comp_lookup_control = {'atm' : {'start_year':'ATMDIAG_cntl_first_yr', 'num_years':'ATMDIAG_cntl_nyrs'},\n 'ice' : {'start_year':'ICEDIAG_BEGYR_DIFF', 'stop_year':'ICEDIAG_ENDYR_DIFF'},\n 'lnd' : {'start_year':'LNDDIAG_clim_first_yr_2', 'num_years':'LNDDIAG_clim_num_yrs_2'},\n 'ocn' : {'start_year':'OCNDIAG_CNTRLYEAR0', 'stop_year':'OCNDIAG_CNTRLYEAR1'}}\n\n # define component-year mapping for trends and timeseries\n comp_lookup_trends = {'atm' : {},\n 'ice' : {},\n 'lnd' : {'start_year1':'LNDDIAG_trends_first_yr_1', 'num_years1':'LNDDIAG_trends_num_yrs_1',\n 'start_year2':'LNDDIAG_trends_first_yr_2', 'num_years2':'LNDDIAG_trends_num_yrs_2'},\n 'ocn' : {'start_year':'OCNDIAG_TSERIES_YEAR0', 'stop_year':'OCNDIAG_TSERIES_YEAR1'}}\n\n # get the model years\n comp_data = comp_lookup[comp]\n model_start_year = '{0}'.format(env[comp_data['start_year']])\n if comp_data.has_key('num_years'):\n model_stop_year = '{0}'.format(int(model_start_year) + int(env[comp_data['num_years']]))\n else:\n model_stop_year = '{0}'.format(env[comp_data['stop_year']])\n\n # get the control years\n comp_data = comp_lookup_control[comp]\n control_start_year = '{0}'.format(env[comp_data['start_year']])\n control_stop_year = None\n if comp_data.has_key('num_years'):\n # check that the strings are not empty\n if len(control_start_year) > 0 and len(env[comp_data['num_years']]) > 0:\n control_stop_year = '{0}'.format(int(control_start_year) + int(env[comp_data['num_years']]))\n else:\n control_stop_year = '{0}'.format(env[comp_data['stop_year']])\n\n # get the trends years\n comp_data = comp_lookup_trends[comp]\n trends_start_year1 = trends_stop_year1 = trends_start_year2 = trends_stop_year2 = None\n if comp == 'ocn':\n trends_start_year1 = '{0}'.format(env[comp_data['start_year']])\n trends_stop_year1 = '{0}'.format(env[comp_data['stop_year']])\n elif comp == 'lnd':\n trends_start_year1 = '{0}'.format(env[comp_data['start_year1']])\n if len(trends_start_year1) > 0 and len(env[comp_data['num_years1']]) > 0:\n trends_stop_year1 = '{0}'.format(int(trends_start_year1) + int(env[comp_data['num_years1']]))\n trends_start_year2 = '{0}'.format(env[comp_data['start_year2']])\n if len(trends_start_year2) > 0 and len(env[comp_data['num_years2']]) > 0:\n trends_stop_year2 = '{0}'.format(int(trends_start_year2) + int(env[comp_data['num_years2']]))\n\n return model_start_year, model_stop_year, control_start_year, control_stop_year, \\\n trends_start_year1, trends_stop_year1, trends_start_year2, trends_stop_year2",
"def get_ly(self):\n return int(self.settlement[\"lantern_year\"])",
"def get_incidents(year):\n print 'Downloading year: %s' % year\n \n # Build URL from year.\n # If the year is 2007-2011, download the XML straight from ... my S3 account.\n if year in range(2007, 2011):\n url = 'http://wapo-projects.s3.amazonaws.com/techathon/scraperwiki/xml/crime_incidents_%s_plain.xml' % year\n \n # If the year is 2012, get it from the DC government. This is NOT the whole year.\n if year == 2012:\n url = 'http://data.octo.dc.gov/feeds/crime_incidents/crime_incidents_current.xml' \n \n # Request the data using the Requests library.\n request = requests.get(url)\n unzipped_request = request.content\n \n # Parse the XML using lxml's BeautifulSoup parser.\n crime_xml_parsed = fromstring(unzipped_request)\n\n # Return the parsed Element() objects by grabbing the xpath for <entry> tags.\n return crime_xml_parsed.xpath('//entry')",
"def get_start_end_years(df: pd.DataFrame) -> Tuple[int, int]:\n return df.iloc[0].year, df.iloc[-1].year",
"def get_avail_years(self):\n years = []\n resp = self._bucket.meta.client.list_objects(Bucket='noaa-nexrad-level2',Delimiter='/')\n\n for each in resp.get('CommonPrefixes', []):\n match = self._year_re.match(each.get('Prefix'))\n if match is not None:\n years.append(match.group(1))\n return years",
"def get_lending_interest_history(self, **params):\n return self._request_margin_api('get', 'lending/union/interestHistory', signed=True, data=params)",
"async def _fetch_originations(self) -> None:\n key = OperationFetcherChannel.originations\n if not self._origination_addresses:\n self._fetched[key] = True\n self._heads[key] = self._last_level\n if self._fetched[key]:\n return\n\n self._logger.debug('Fetching originations of %s', self._origination_addresses)\n\n originations = await self._datasource.get_originations(\n addresses=self._origination_addresses,\n offset=self._offsets[key],\n first_level=self._first_level,\n last_level=self._last_level,\n cache=self._cache,\n )\n\n for op in originations:\n level = op.level\n if level not in self._operations:\n self._operations[level] = []\n self._operations[level].append(op)\n\n self._logger.debug('Got %s', len(originations))\n\n if len(originations) < self._datasource.request_limit:\n self._fetched[key] = True\n self._heads[key] = self._last_level\n else:\n self._offsets[key] += self._datasource.request_limit\n self._heads[key] = self._get_operations_head(originations)",
"def __get_birth_years_at_year(self, sampling_year):\n\t\treturn [birth_year for i in range(1, s.NUMBER_OF_HUMANS + 1) for birth_year in self.column_dict if self.__satisfy_cbat_condition(i, sampling_year, birth_year)]",
"def get_cohort_info_from_age_year(age_group_ids, years):\n\n LOGGER.info(\"In get_cohort_info_from_age_year\")\n age_meta_df = db.get_ages()[[\n 'age_group_id', 'age_group_years_start']]\n\n all_age_year_df = pd.MultiIndex.from_product(\n [age_group_ids, years.years],\n names=['age_group_id', 'year_id']\n ).to_frame().reset_index(drop=True)\n\n cohort_age_df = all_age_year_df.merge(\n age_meta_df, on='age_group_id').astype({'age_group_years_start': int})\n\n # Finding the cohort from year and lower bound of age_group as described\n # above.\n cohort_age_df['cohort_year'] = (\n cohort_age_df['year_id'] - (\n cohort_age_df['age_group_years_start'] - 5))\n\n # All cohorts don't need correction.Only those that extend into the future.\n correction_cohorts_years = cohort_age_df[\n cohort_age_df['year_id'] > years.past_end]['cohort_year'].unique()\n cohort_age_df['need_correction'] = \\\n cohort_age_df['cohort_year'].isin(correction_cohorts_years)\n\n cohort_age_df.drop('age_group_years_start', axis=1, inplace=True)\n\n return cohort_age_df",
"def get_lending_account(self, **params):\n return self._request_margin_api('get', 'lending/union/account', signed=True, data=params)",
"def get_age_fields():\n under_18_fields = CensusFields.get_under_18_fields()\n\n age_18_to_29_fields = [ \n 'B01001_007E', # Male:!!18 and 19 years\n 'B01001_008E', # Male:!!20 years\n 'B01001_009E', # Male:!!21 years\n 'B01001_010E', # Male:!!22 to 24 years\n 'B01001_011E', # Male:!!25 to 29 years\n 'B01001_031E', # Female:!!18 and 19 years\n 'B01001_032E', # Female:!!20 years\n 'B01001_033E', # Female:!!21 years\n 'B01001_034E', # Female:!!22 to 24 years\n 'B01001_035E', # Female:!!25 to 29 years\n ]\n age_30_to_39_fields = [\n 'B01001_012E', # Male:!!30 to 34 years\n 'B01001_013E', # Male:!!35 to 39 years\n 'B01001_036E', # Female:!!30 to 34 years\n 'B01001_037E', # Female:!!35 to 39 years\n ]\n age_40_to_49_fields = [\n 'B01001_014E', # Male:!!40 to 44 years\n 'B01001_038E', # Female:!!40 to 44 years\n 'B01001_015E', # Male:!!45 to 49 years\n 'B01001_039E', # Female:!!45 to 49 years\n\n ]\n age_50_to_59_fields = [\n 'B01001_016E', # Male:!!50 to 54 years\n 'B01001_017E', # Male:!!55 to 59 years\n 'B01001_040E', # Female:!!50 to 54 years\n 'B01001_041E', # Female:!!55 to 59 years\n\n ]\n age_60_to_69_fields = [\n 'B01001_018E', # Male:!!60 and 61 years\n 'B01001_019E', # Male:!!62 to 64 years\n 'B01001_020E', # Male:!!65 and 66 years\n 'B01001_021E', # Male:!!67 to 69 years\n 'B01001_042E', # Female:!!60 and 61 years\n 'B01001_043E', # Female:!!62 to 64 years\n 'B01001_044E', # Female:!!65 and 66 years\n 'B01001_045E', # Female:!!67 to 69 years\n ]\n age_70_to_79_fields = [\n 'B01001_022E', # Male:!!70 to 74 years\n 'B01001_023E', # Male:!!75 to 79 years\n 'B01001_046E', # Female:!!70 to 74 years\n 'B01001_047E', # Female:!!75 to 79 years\n ]\n age_81_plus_fields = [\n 'B01001_024E', # Male:!!80 to 84 years\n 'B01001_025E', # Male:!!85 years and over\n 'B01001_048E', # Female:!!80 to 84 years\n 'B01001_049E', # Female:!!85 years and over\n ]\n \n age_fields = OrderedDict()\n age_fields[ 'age_18_to_29' ] = { 'label': '18-29', 'fields': age_18_to_29_fields }\n age_fields[ 'age_30_to_39' ] = { 'label': '30s', 'fields': age_30_to_39_fields }\n age_fields[ 'age_40_to_49' ] = { 'label': '40s', 'fields': age_40_to_49_fields }\n age_fields[ 'age_50_to_59' ] = { 'label': '50s', 'fields': age_50_to_59_fields }\n age_fields[ 'age_60_to_69' ] = { 'label': '60s', 'fields': age_60_to_69_fields } \n age_fields[ 'age_70_to_79' ] = { 'label': '70s', 'fields': age_70_to_79_fields }\n age_fields[ 'age_81_plus' ] = { 'label': '80+', 'fields': age_81_plus_fields }\n\n return age_fields",
"def state_years(state, start_year, end_year):\n years = range(start_year, end_year + 1, 1)\n df_list = []\n for year in years:\n xx = all_stations_for_state_year(state, year)\n df_list.append(xx[['MEAN_T']])\n df = df_list[0]\n for frame in df_list[1:]:\n df = df.append(frame)\n return df",
"def lons(self):\n lons = []\n quads = self.getQuadrilaterals()\n groups = self._getGroupIndex()\n u_groups = np.unique(groups)\n ng = len(u_groups)\n for i in range(ng):\n q_ind = np.where(groups == u_groups[i])[0]\n nq = len(q_ind)\n top_lons = []\n bot_lons = []\n for j in range(nq):\n if j == 0:\n top0 = [quads[q_ind[j]][0].longitude]\n bot0 = [quads[q_ind[j]][3].longitude]\n top_lons = top_lons + top0\n bot_lons = bot_lons + bot0\n top_lons = top_lons + [quads[q_ind[j]][1].longitude]\n bot_lons = bot_lons + [quads[q_ind[j]][2].longitude]\n lons = lons + top_lons + bot_lons[::-1] + top0 + [np.nan]\n return np.array(lons)",
"def _enumerate_years(self, preprocessed_data, disjoint):\n pass"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Loads branch data from Derek. | def _load(self):
context = {
"username": self.username,
"reponame": self.reponame,
"name": self.name
}
LOG.debug("Loading %s" % self.branch_id)
doc = self._client.getjson(path="/users/%(username)s/repos/%(reponame)s"
"/branches/%(name)s" % context)
LOG.debug("doc loaded: %r" % doc)
slice_id = "%(username)s/%(reponame)s/%(slice_id)s" % {
"username": self.username,
"reponame": self.reponame,
"slice_id": doc["slice_id"]
}
self._slice = self._client.slice(slice_id)
self._packages = doc["packages"] | [
"async def fetch_branch_data( self, results_holder_dct ):\n log.debug( 'fetch_branch_data' )\n original_directory = os.getcwd()\n git_dir = settings.BASE_DIR\n os.chdir( git_dir )\n output_obj: subprocess.CompletedProcess = await trio.run_process( ['git', 'branch'], capture_stdout=True )\n output: str = output_obj.stdout.decode( 'utf-8' )\n os.chdir( original_directory )\n lines = output.split( '\\n' )\n branch = 'init'\n for line in lines:\n if line[0:1] == '*':\n branch = line[2:]\n break\n results_holder_dct['branch'] = branch\n return",
"def load_librarybranches():\n\n print \"Loading Library Branches!\"\n\n LibraryBranch.query.delete()\n\n with open(\"data/libdata.txt\") as libdatafile:\n for line in libdatafile:\n line = line.rstrip()\n sys_id, branch_name, branch_zipcode, branch_public_access, branch_card_policy, branch_overdrive_status, branch_address, branch_geo, branch_phone = line.split(\"|\")\n\n librarybranch = LibraryBranch(sys_id=int(sys_id),\n branch_name=branch_name,\n branch_zipcode=branch_zipcode,\n branch_public_access=branch_public_access,\n branch_card_policy=branch_card_policy,\n branch_overdrive_status=branch_overdrive_status,\n branch_address=branch_address,\n branch_geo=branch_geo,\n branch_phone=branch_phone)\n\n db.session.add(librarybranch)\n\n db.session.commit()",
"def load_data(self) -> None:",
"def loadBranches(self, isSingleFile=True):\n \n if isSingleFile:\n # branches\n self.l_jetPt = uproot.tree.TBranchMethods.array(self.delphesTree['Jet']['Jet.PT']).tolist()\n self.l_jetEta = uproot.tree.TBranchMethods.array(self.delphesTree['Jet']['Jet.Eta']).tolist()\n self.l_jetPhi = uproot.tree.TBranchMethods.array(self.delphesTree['Jet']['Jet.Phi']).tolist()\n self.l_jetMass = uproot.tree.TBranchMethods.array(self.delphesTree['Jet']['Jet.Mass']).tolist()\n \n self.l_elPt = uproot.tree.TBranchMethods.array(self.delphesTree['Electron']['Electron.PT']).tolist()\n self.l_elEta = uproot.tree.TBranchMethods.array(self.delphesTree['Electron']['Electron.Eta']).tolist()\n self.l_elPhi = uproot.tree.TBranchMethods.array(self.delphesTree['Electron']['Electron.Phi']).tolist()\n self.l_elCharge = uproot.tree.TBranchMethods.array(self.delphesTree['Electron']['Electron.Charge']).tolist()\n \n self.l_muPt = uproot.tree.TBranchMethods.array(self.delphesTree['Muon']['Muon.PT']).tolist()\n self.l_muEta = uproot.tree.TBranchMethods.array(self.delphesTree['Muon']['Muon.Eta']).tolist()\n self.l_muPhi = uproot.tree.TBranchMethods.array(self.delphesTree['Muon']['Muon.Phi']).tolist()\n self.l_muCharge = uproot.tree.TBranchMethods.array(self.delphesTree['Muon']['Muon.Charge']).tolist()\n \n self.l_missingET_met = uproot.tree.TBranchMethods.array(self.delphesTree['MissingET']['MissingET.MET']).tolist()\n self.l_missingET_phi = uproot.tree.TBranchMethods.array(self.delphesTree['MissingET']['MissingET.Phi']).tolist()\n self.l_scalarHT = uproot.tree.TBranchMethods.array(self.delphesTree['ScalarHT']['ScalarHT.HT']).tolist()\n \n else: # multi-file\n self.l_jetPt = self.delphesTree['Jet.PT'].tolist()\n self.l_jetEta = self.delphesTree['Jet.Eta'].tolist()\n self.l_jetPhi = self.delphesTree['Jet.Phi'].tolist()\n self.l_jetMass = self.delphesTree['Jet.Mass'].tolist()\n \n self.l_elPt = self.delphesTree['Electron.PT'].tolist()\n self.l_elEta = self.delphesTree['Electron.Eta'].tolist()\n self.l_elPhi = self.delphesTree['Electron.Phi'].tolist()\n self.l_elCharge = self.delphesTree['Electron.Charge'].tolist()\n \n self.l_muPt = self.delphesTree['Muon.PT'].tolist()\n self.l_muEta = self.delphesTree['Muon.Eta'].tolist()\n self.l_muPhi = self.delphesTree['Muon.Phi'].tolist()\n self.l_muCharge = self.delphesTree['Muon.Charge'].tolist()\n \n self.l_missingET_met = self.delphesTree['MissingET.MET'].tolist()\n self.l_missingET_phi = self.delphesTree['MissingET.Phi'].tolist()\n self.l_scalarHT = self.delphesTree['ScalarHT.HT'].tolist()\n \n print(\"...Finished loading branches\")",
"def load_data(self):",
"def _tree_load_sub_branch(self, traj_node, branch_name,\n load_data=pypetconstants.LOAD_DATA,\n with_links=True, recursive=False,\n max_depth=None, _trajectory=None,\n _as_new=False, _hdf5_group=None):\n if load_data == pypetconstants.LOAD_NOTHING:\n return\n\n if max_depth is None:\n max_depth = float('inf')\n\n if _trajectory is None:\n _trajectory = traj_node.v_root\n\n if _hdf5_group is None:\n hdf5_group_name = traj_node.v_full_name.replace('.', '/')\n\n # Get child node to load\n if hdf5_group_name == '':\n _hdf5_group = self._trajectory_group\n else:\n try:\n _hdf5_group = self._hdf5file.get_node(where=self._trajectory_group,\n name=hdf5_group_name)\n except pt.NoSuchNodeError:\n self._logger.error('Cannot find `%s` the hdf5 node `%s` does not exist!'\n % (traj_node.v_full_name, hdf5_group_name))\n raise\n\n split_names = branch_name.split('.')\n\n final_group_name = split_names.pop()\n\n current_depth = 1\n\n for name in split_names:\n if current_depth > max_depth:\n return\n # First load along the branch\n _hdf5_group = getattr(_hdf5_group, name)\n\n self._tree_load_nodes_dfs(traj_node, load_data=load_data, with_links=with_links,\n recursive=False, max_depth=max_depth, current_depth=current_depth,\n trajectory=_trajectory, as_new=_as_new,\n hdf5_group=_hdf5_group)\n\n current_depth += 1\n\n traj_node = traj_node._children[name]\n\n if current_depth <= max_depth:\n # Then load recursively all data in the last group and below\n _hdf5_group = getattr(_hdf5_group, final_group_name)\n self._tree_load_nodes_dfs(traj_node, load_data=load_data, with_links=with_links,\n recursive=recursive, max_depth=max_depth,\n current_depth=current_depth, trajectory=_trajectory,\n as_new=_as_new, hdf5_group=_hdf5_group)",
"def loadData(self):\r\n\r\n # Read label history\r\n if os.path.isfile(self.labelhistory_file):\r\n if sys.version_info.major == 3:\r\n try:\r\n with open(self.labelhistory_file, 'rb') as f:\r\n labelhistory = pickle.load(f)\r\n except:\r\n print(\"---- Cannot read a pkl file version for \" +\r\n \"Python 2. Trying to load a json file.\")\r\n print(\"---- An ERROR will arise if json file does \" +\r\n \"not exist.\")\r\n print(\"---- IF THIS IS THE CASE, YOU SHOULD DO \\n\" +\r\n \" python run_pkl2json.py [path to \"\r\n \"labelhistory]\\n\" +\r\n \" FROM PYTHON 2 BEFORE RUNNING THIS SCRIPT.\")\r\n fname = self.labelhistory_file.replace('.pkl', '.json')\r\n with open(fname, 'r', encoding='latin1') as f:\r\n labelhistory = json.load(f)\r\n\r\n # Convert date field, which is in string format, to\r\n # datetime format.\r\n for url, events in labelhistory.items():\r\n for idx, record in events.items():\r\n labelhistory[url][idx]['date'] = (\r\n datetime.strptime(\r\n labelhistory[url][idx]['date'],\r\n \"%Y-%m-%dT%H:%M:%S.%f\"))\r\n else:\r\n with open(self.labelhistory_file, 'r') as f:\r\n labelhistory = pickle.load(f)\r\n\r\n else:\r\n labelhistory = {}\r\n\r\n # Load dataset files.\r\n if (os.path.isfile(self.datalabels_file) and\r\n os.path.isfile(self.datapreds_file)):\r\n # Load label and prediction dataframes stored in pickle files\r\n df_labels = pd.read_pickle(self.datalabels_file)\r\n df_preds = pd.read_pickle(self.datapreds_file)\r\n elif os.path.isfile(self.dataset_file):\r\n # If there is an old dataset structure, read data there and\r\n # convert it into the label and preds dataframes\r\n with open(self.dataset_file, 'r') as handle:\r\n data = pickle.load(handle)\r\n df_labels, df_preds = self.get_df(data, labelhistory)\r\n else:\r\n # Warning: the next 4 commands are duplicated in importData.\r\n # Make sure taht any changes here are also done there\r\n # (I know, this is not a good programming style..)\r\n info = ['marker', 'relabel', 'weight', 'userId', 'date']\r\n arrays = [len(info)*['info'] + len(self.categories)*['label'],\r\n info + self.categories]\r\n tuples = list(zip(*arrays))\r\n mindex = pd.MultiIndex.from_tuples(tuples)\r\n # Create empty pandas dataframe\r\n df_labels = pd.DataFrame(self._unknown, index=[],\r\n columns=mindex)\r\n # df_labels = None\r\n # df_preds = None\r\n cols = ['url'] + self.categories\r\n df_preds = pd.DataFrame(index=[], columns=cols)\r\n print(df_preds)\r\n\r\n return df_labels, df_preds, labelhistory",
"def load(self):\n if self.repository in data.tracked:\n self.hashes = data.tracked[self.repository][\"hashes\"]\n self.parsed = data.tracked[self.repository][\"parsed\"]",
"def load_tree(self, name='tree'):\n handle = self.target_connector.get_handle()\n handle.setContext(self.target_connector)\n fname = fs.path.join('.', name + '.json')\n with handle.open(fname, 'rb') as fp:\n data = fp.read()\n self.request.response.setHeader('content-type', 'application/json')\n return data",
"def load_from_disk(self, file_name = \"vehicle_classifier.pkl\"):\n self.classifier.load_from_disk(file_name)",
"def test_load(self):\n tree = dcl.construct_tree(self.dataset, self.k,\n prune_threshold=self.gamma)\n\n with tempfile.NamedTemporaryFile() as f:\n tree.save(f.name)\n tree2 = dcl.load_tree(f.name)\n\n self._check_tree_viability(tree2)\n self._check_tree_correctness(tree)",
"def fetch_branches(self):\n for jrepo in self.json_repos['repos']:\n title = str(jrepo[\"title\"])\n self.branches[title] = str(jrepo['current'])",
"def loadBank(cls):\n pass",
"def load_data(self) -> None:\n with open('WDLD.txt', 'rb') as f:\n self.base_layer = pickle.load(f)\n self.seem_layer = pickle.load(f)\n self.keyboard_layer = pickle.load(f)\n self.pronunciation_layer = pickle.load(f)\n return None",
"def _read_shp_branches(self):\n geoms = {}\n with fiona.open(self.files['branches'], 'r') as src:\n emh_field = list(src.schema['properties'])[0]\n for obj in src:\n nom_branche = obj['properties'][emh_field]\n coords = [coord[:2] for coord in obj['geometry']['coordinates']] # Ignore Z\n geoms[nom_branche] = LineString(coords)\n for branche in self.get_liste_branches():\n try:\n branche.set_geom(geoms[branche.id])\n except KeyError:\n raise ExceptionCrue10GeometryNotFound(branche)",
"def _load_tree(tree_pickle):\n try:\n with open(tree_pickle, 'rb') as f:\n tree = pickle.load(f)\n except Exception as e:\n logger.warning('Could not extract tree from {}: {}'\n .format(tree_pickle, e))\n tree = None\n\n return tree",
"def get_branch(self, branch_name: str) -> Reference:\n pass",
"def testLoadIntegratedDrugBankData(self):\n try:\n crw = ChemRefEtlWorker(self.__cfgOb, self.__cachePath)\n crExt = ChemRefExtractor(self.__cfgOb)\n\n idD = crExt.getChemCompAccessionMapping(referenceResourceName=\"DrugBank\")\n logger.info(\"Mapping dictionary %r\", len(idD))\n #\n ok = crw.load(self.__updateId, extResource=\"DrugBank\", loadType=\"full\")\n #\n self.assertTrue(ok)\n except Exception as e:\n logger.exception(\"Failing with %s\", str(e))\n self.fail()",
"def fetch(self, remote: str, branch: str) -> str:\n self.__verify_repo_initialized()\n address = heads.get_remote_address(self._env.branchenv, name=remote)\n self._client = HangarClient(envs=self._env, address=address)\n CW = ContentWriter(self._env)\n\n with closing(self._client) as client:\n client: HangarClient\n\n # ----------------- setup / validate operations -------------------\n\n try:\n cHEAD = heads.get_branch_head_commit(self._env.branchenv, branch)\n except ValueError:\n # branch does not exist on local client\n try:\n s_branch = client.fetch_branch_record(branch)\n sHEAD = s_branch.rec.commit\n except grpc.RpcError as rpc_error:\n if rpc_error.code() == grpc.StatusCode.NOT_FOUND:\n # branch does not exist on remote\n logger.error(rpc_error.details())\n raise rpc_error\n else:\n c_bhistory = summarize.list_history(\n self._env.refenv, self._env.branchenv, branch_name=branch)\n try:\n s_branch = client.fetch_branch_record(branch)\n sHEAD = s_branch.rec.commit\n except grpc.RpcError as rpc_error:\n if rpc_error.code() == grpc.StatusCode.NOT_FOUND:\n # branch does not exist on remote\n logger.error(rpc_error.details())\n raise rpc_error\n\n # verify histories are intact and should be synced\n if sHEAD == cHEAD:\n warnings.warn(f'NoOp: {sHEAD} == client HEAD {cHEAD}', UserWarning)\n return branch\n elif sHEAD in c_bhistory['order']:\n warnings.warn(\n f'REJECTED: remote HEAD: {sHEAD} behind local: {cHEAD}', UserWarning)\n return branch\n\n # ------------------- get data ------------------------------------\n\n mCmtResponse = client.fetch_find_missing_commits(branch)\n m_cmts = mCmtResponse.commits\n for commit in tqdm(m_cmts, desc='fetching commit data refs'):\n # Get missing label (metadata) digest & values\n m_labels = set(client.fetch_find_missing_labels(commit))\n for label in m_labels:\n received_hash, labelVal = client.fetch_label(label)\n CW.label(received_hash, labelVal)\n # Get missing data schema digests & values\n mSchemaResponse = client.fetch_find_missing_schemas(commit)\n for schema in mSchemaResponse.schema_digests:\n schema_hash, schemaVal = client.fetch_schema(schema)\n CW.schema(schema_hash, schemaVal)\n # Record missing data hash digests (does not get data itself)\n m_hashes = client.fetch_find_missing_hash_records(commit)\n m_schema_hash_map = defaultdict(list)\n for digest, schema_hash in m_hashes:\n m_schema_hash_map[schema_hash].append((digest, schema_hash))\n for schema_hash, received_data in m_schema_hash_map.items():\n CW.data(schema_hash, received_data, backend='50')\n\n # Get missing commit reference specification\n for commit in tqdm(m_cmts, desc='fetching commit spec'):\n cmt, parentVal, specVal, refVal = client.fetch_commit_record(commit)\n CW.commit(cmt, parentVal, specVal, refVal)\n\n # --------------------------- At completion -----------------------\n\n # Update (or create) remote branch pointer with new HEAD commit\n fetchBranchName = f'{remote}/{branch}'\n try:\n heads.create_branch(\n self._env.branchenv, name=fetchBranchName, base_commit=sHEAD)\n except ValueError:\n heads.set_branch_head_commit(\n self._env.branchenv, branch_name=fetchBranchName, commit_hash=sHEAD)\n\n return fetchBranchName"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Upload packages to branch. | def upload_packages(self, packages):
context = {
"username": self.username,
"reponame": self.reponame,
"name": self.name
}
filepaths = [os.path.join(os.path.dirname(path), pfile['filename'])
for path in packages
for pfile in deb_changes(path)['files']]
filepaths.extend(packages)
# get upload token
resp = self._client.postjson(path="/users/%(username)s/"
"repos/%(reponame)s/"
"branches/%(name)s/get_upload_token" %
context)
token = resp['utoken']
for pfile in filepaths:
self._client.upload(path="/upload/%s/send/%s" %
(token, os.path.basename(pfile)),
filepath=pfile)
self._client.post(path="/upload/%s/dput" % token) | [
"def deploy():\n build()\n collect()\n commit()\n push()",
"def push(self, base_repo, branch=\"master\"):\n base_repo.push_to(self, branch)",
"def push(self, base_repo, branch: str = \"master\") -> None:\n raise NotImplementedError",
"def upload(self, connection):\n if not self.already_deployed(connection):\n if self.config.project_type == \"java\":\n print(blue('Pushing jar to nexus server'))\n connection.local('mvn deploy')\n self._already_deployed = True\n else:\n raise Exception(f\"Unsupported project type: {self.config.project_type}\")",
"def upload_mypkg(\n self,\n container: ContainerInfo,\n mypkg_paths: t.Dict[str, Path],\n ) -> None:\n run(\n sys.executable,\n \"-m\",\n \"twine\",\n \"upload\",\n \"--repository-url\",\n f\"http://localhost:{container.port}\",\n \"--username\",\n \"\",\n \"--password\",\n \"\",\n f\"{mypkg_paths['dist_dir']}/*\",\n )",
"def push():\n branch = git.current_branch().name\n shell.run('git push -u origin {}'.format(branch))",
"def upload_mypkg(\n self,\n container: str, # pylint: disable=unused-argument\n mypkg_paths: t.Dict[str, Path],\n ) -> None:\n run(\n sys.executable,\n \"-m\",\n \"twine\",\n \"upload\",\n \"--repository-url\",\n f\"http://localhost:{self.HOST_PORT}\",\n \"--username\",\n \"a\",\n \"--password\",\n \"a\",\n f\"{mypkg_paths['dist_dir']}/*\",\n )",
"def push(self) -> None:\n\n with ImportExtensions(required=True):\n import requests\n\n pkg_path = Path(self.args.path)\n if not pkg_path.exists():\n self.logger.critical(f'`{self.args.path}` is not a valid path!')\n exit(1)\n\n request_headers = self._get_request_header()\n\n try:\n # archive the executor package\n with TimeContext(f'Packaging {self.args.path}', self.logger):\n md5_hash = hashlib.md5()\n bytesio = archive_package(pkg_path)\n content = bytesio.getvalue()\n md5_hash.update(content)\n\n md5_digest = md5_hash.hexdigest()\n\n # upload the archived package\n form_data = {\n 'public': self.args.public if hasattr(self.args, 'public') else False,\n 'private': self.args.private\n if hasattr(self.args, 'private')\n else False,\n 'md5sum': md5_digest,\n 'force': self.args.force,\n 'secret': self.args.secret,\n }\n\n method = 'put' if self.args.force else 'post'\n\n hubble_url = get_hubble_url()\n # upload the archived executor to Jina Hub\n with TimeContext(\n f'Pushing to {hubble_url} ({method.upper()})',\n self.logger,\n ):\n resp = getattr(requests, method)(\n hubble_url,\n files={'file': content},\n data=form_data,\n headers=request_headers,\n )\n\n if 200 <= resp.status_code < 300:\n # TODO: only support single executor now\n image = resp.json()['executors'][0]\n\n uuid8 = image['id']\n secret = image['secret']\n visibility = image['visibility']\n\n info_table = [\n f'\\t🔑 ID:\\t\\t' + colored(f'{uuid8}', 'cyan'),\n f'\\t🔒 Secret:\\t'\n + colored(\n f'{secret}',\n 'cyan',\n )\n + colored(\n ' (👈 Please store this secret carefully, it wont show up again)',\n 'red',\n ),\n f'\\t👀 Visibility:\\t' + colored(f'{visibility}', 'cyan'),\n ]\n\n if 'alias' in image:\n info_table.append(f'\\t📛 Alias:\\t' + colored(image['alias'], 'cyan'))\n\n self.logger.success(f'🎉 Executor `{pkg_path}` is pushed successfully!')\n self.logger.info('\\n' + '\\n'.join(info_table))\n\n usage = (\n f'jinahub://{uuid8}'\n if visibility == 'public'\n else f'jinahub://{uuid8}:{secret}'\n )\n\n self.logger.info(f'You can use it via `uses={usage}` in the Flow/CLI.')\n elif resp.text:\n # NOTE: sometimes resp.text returns empty\n raise Exception(resp.text)\n else:\n resp.raise_for_status()\n except Exception as e: # IO related errors\n self.logger.error(\n f'Error while pushing `{self.args.path}` with session_id={request_headers[\"jinameta-session-id\"]}: '\n f'\\n{e!r}'\n )",
"def git_archive_and_upload_tar():\n current_branch = str(subprocess.Popen('git branch | grep \"*\" | sed \"s/* //\"', \\\n shell=True,\\\n stdin=subprocess.PIPE, \\\n stdout=subprocess.PIPE).communicate()[0]).rstrip()\n env.git_branch = current_branch\n local('git archive --format=tar %(git_branch)s > %(release)s.tar' % env)\n local('touch `git describe HEAD`.tag')\n local('tar rvf %(release)s.tar `git describe HEAD`.tag; rm `git describe HEAD`.tag' % env)\n local('gzip %(release)s.tar' % env)\n run('; mkdir -p %(path)s/releases/%(release)s' % env)\n run('; mkdir -p %(path)s/packages/' % env)\n rsync_project('%(path)s/packages/' % env, '%(release)s.tar.gz' % env, extra_opts='-avz --progress')\n run('cd %(path)s/releases/%(release)s && tar zxf ../../packages/%(release)s.tar.gz' % env)\n local('rm %(release)s.tar.gz' % env)",
"def git_push():\n\n # get current version\n new_version = get_version()\n values = list(map(lambda x: int(x), new_version.split('.')))\n\n # Push to origin new version and corresponding tag:\n # * commit new version\n # * create tag\n # * push version,tag to origin\n local('git add {}/version.py version.py'.format(project_name))\n\n local('git commit -m \"updated version\"')\n local('git tag {}.{}.{}'.format(values[0], values[1], values[2]))\n local('git push origin --tags')\n local('git push')",
"def git_push(c):\n c.run(\"git submodule foreach git push \")",
"def push_updates():\n check_call(['git', 'push', '--tags', '--force'])",
"def scm_push(ctx):\n\n for branch in ('develop', 'master'):\n ctx.run('git push origin {}'.format(branch))\n\n ctx.run('git push --tags')",
"def upload_package(conn, module, remotepath = None, chunk_size = 16000):\r\n if remotepath is None:\r\n site = conn.modules[\"distutils.sysconfig\"].get_python_lib()\r\n remotepath = conn.modules.os.path.join(site, module.__name__)\r\n localpath = os.path.dirname(os.path.abspath(inspect.getsourcefile(module)))\r\n upload(conn, localpath, remotepath, chunk_size = chunk_size)",
"def upload_pypi():\n import os\n from . import remove, dir_char\n remove('dist')\n if os.system('python3 setup.py sdist'):\n os.system('python setup.py sdist')\n os.system('twine upload dist%s*' % dir_char)",
"def git_commit_and_push(self):\r\n self.repo.git.add('--all')\r\n self.repo.index.commit(\"committed changes\")\r\n origin = self.repo.remote('origin')\r\n origin.push('master')\r\n self.repo.git.add(update=True)\r\n print(\"Commit and push changes - completed....\")",
"def upload_package(conn, module, remotepath = None, chunk_size = 16000):\n if remotepath is None:\n site = conn.modules[\"distutils.sysconfig\"].get_python_lib()\n remotepath = conn.modules.os.path.join(site, module.__name__)\n localpath = os.path.dirname(inspect.getsourcefile(module))\n upload(conn, localpath, remotepath, chunk_size = chunk_size)",
"def push():\n # test()\n # TODO - need to improve image detection algorithm. maybe need variable threshold or configurable\n local('git add .;git commit; git push;')\n with settings(user=\"pi\", host_string=\"raspberry.pi\"):\n with cd('/home/pi/src/rpi'):\n run('git pull')",
"def push ():\n\n tagname = get_tag (comp_versions, 'ACE')\n\n if opts.push:\n if opts.take_action:\n vprint (\"Pushing ACE_TAO\", opts.ace_tao_branch, \"to origin\")\n ex (\"cd $DOC_ROOT/ACE_TAO && git push origin \" + opts.ace_tao_branch)\n\n vprint (\"Pushing tag %s on ACE_TAO\" % (tagname))\n ex (\"cd $DOC_ROOT/ACE_TAO && git push origin tag \" + tagname)\n\n vprint (\"Pushing tag %s on MPC\" % (tagname))\n ex (\"cd $DOC_ROOT/MPC && git push origin tag \" + tagname)\n\n # Push release branches\n latest_branch_helper (push_latest_branch, opts.release_type)\n else:\n vprint (\"Pushing tag %s on ACE_TAO\" % (tagname))\n vprint (\"Pushing tag %s on MPC\" % (tagname))\n print (\"Pushing tags:\\n\")\n print (\"Pushing tag \" + tagname + \"\\n\")"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Look up package ID from list of package infos. | def get_pkg_id(pkgs, name, version):
for pinfo in pkgs:
if pinfo["name"] == name and pinfo["version"] == version:
return "%(name)s/%(version)s/%(id)s" % pinfo
raise DerekError("No package %s %s in the branch" % (name, version)) | [
"def _get_aptd_package_id(self, pk_id):\n name, version, arch, data = pk_id.split(\";\")\n id = name\n if arch != self.queue.worker.NATIVE_ARCH and arch != \"all\":\n id += \":%s\" % arch\n if version:\n id += \"=%s\" % version\n return id",
"def map_item_name(self, list_item_id):\n\n return [self.packages.get(k) for k in list_item_id]",
"def get_info(self, pkgname):\n for pkg in self.rpc.info(pkgname):\n return pkg",
"def get_package_info(package_name):\n r = requests.get(f'https://api.npms.io/v2/search?q={package_name}&size=1')\n response_json = r.json()\n\n if 'results' in response_json:\n result = response_json['results'][0]\n return result['package']",
"def list_package_ids(self):\n raise NotImplementedError",
"def get_repo_info_dict_for_import( encoded_repository_id, encoded_repository_ids, repo_info_dicts ):\n for index, repository_id in enumerate( encoded_repository_ids ):\n if repository_id == encoded_repository_id:\n repo_info_dict = repo_info_dicts[ index ]\n return repo_info_dict\n return None",
"def _package_ids_satisfying_requirement(pool, requirement):\n for package in pool.what_provides(requirement):\n yield pool.package_id(package)",
"def get_distid(pkgtype, distslug, config):\n\n distindex = get_distributions(config)\n distributions = distindex[pkgtype]\n distname, codename = distslug.split('/')\n\n if config['debug']:\n print(\"DEBUG: Pkgtype: {} Distribution: {} Codename: {}\".\n format(pkgtype, distname, codename))\n\n for dist in distributions:\n if dist['index_name'] == distname:\n for ver in dist['versions']:\n if ver['index_name'] == codename:\n return ver['id']\n\n abort(\"No distribution id found for: {}\".format(distslug))",
"def package_id(self):\n self.info.header_only()",
"def get_package(self, __package_id):\n raise NotImplementedError",
"def get_package(self, package_id):\r\n\r\n # get the bucket number from the hash function\r\n bucket = self.hash_function(package_id)\r\n\r\n # Keep searching until you find a bucket that is not empty or you search all buckets\r\n num_probed = 0\r\n while self.hash_table[bucket] is not self.EMPTY_SINCE_START and num_probed < self.number_of_buckets:\r\n if self.hash_table[bucket][0] == package_id:\r\n return self.hash_table[bucket]\r\n bucket = self.hash_function(bucket + 1)\r\n num_probed += 1\r\n return None",
"def find_package(self, package_title):\n metadata = self.get_ckan_metadata()\n results = []\n for id, resource in metadata.items():\n if resource['dataset']['title'] == package_title:\n results.append(resource['dataset'])\n return results[0] if len(results) == 1 else results",
"def get_pk_package_id(pk_id, data=\"\"):\n # FIXME add arch support\n name, version, release = split_package_id(pk_id)\n try:\n name, arch = name.split(\":\", 1)\n except ValueError:\n arch = \"\"\n if version is None:\n version = \"\"\n if release is None:\n release = \"\"\n return \"%s;%s;%s;%s\" % (name, version, arch, data or release)",
"def info(self, package):\n # send what the index has\n return self.getInstalledPackages()[package]",
"def package_code(self):\n return self.__squid_to_guid(self.get_product_value(\"PackageCode\"))",
"def getPackageUid(self, packageName, flags):\n pass",
"def get_package_info():\n\n with open(hack.CONDA_ARTIFACT_FILENAME, 'r') as fn:\n pkg_location = fn.read().strip()\n pkg_name = os.path.basename(pkg_location)\n\n return pkg_location, pkg_name",
"def get_item_id_from_list_by_name(self, item_name, list_of_items):\n\n for item in list_of_items:\n if item_name in item['content']:\n return item['id']\n\n return None",
"def package(id = 0):\n\tresults = queries.package(id)\n\tif not results:\n\t\treturn render_template('package_not_found.html')\n\treturn render_template('package.html', package=results)"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test upsert user template as anonymous raises access control error | def test_upsert_user_template_as_anonymous_raises_access_control_error(
self,
):
mock_request = create_mock_request(user=self.anonymous_user)
with self.assertRaises(AccessControlError):
template_api.upsert(
self.fixture.user1_template, request=mock_request
) | [
"def test_upsert_user_template_as_anonymous_with_access_right_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.upsert(\n self.fixture.user1_template, request=mock_request\n )",
"def test_upsert_global_template_as_anonymous_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.upsert(\n self.fixture.global_template, request=mock_request\n )",
"def test_upsert_global_template_as_anonymous_with_access_right_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.upsert(\n self.fixture.global_template, request=mock_request\n )",
"def test_upsert_global_template_as_user_raises_access_control_error(self):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.upsert(\n self.fixture.global_template, request=mock_request\n )",
"def test_update_template_permission(self):\n pass",
"def test_upsert_other_users_template_as_user_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.upsert(\n self.fixture.user2_template, request=mock_request\n )",
"def test_upsert_own_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.upsert(self.fixture.user1_template, request=mock_request)",
"def test_upsert_global_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.upsert(self.fixture.global_template, request=mock_request)",
"def test_upsert_own_template_as_user_saves(self):\n mock_request = create_mock_request(user=self.user1)\n template_api.upsert(self.fixture.user1_template, request=mock_request)",
"def test_upsert_other_users_template_as_staff_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n with self.assertRaises(AccessControlError):\n template_api.upsert(\n self.fixture.user2_template, request=mock_request\n )",
"def test_upsert_other_users_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.upsert(self.fixture.user2_template, request=mock_request)",
"def test_partial_update_system_user(self):\n pass",
"def test_set_display_name_user_template_as_anonymous_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.user1_template, \"new_name\", request=mock_request\n )",
"def test_upsert_global_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.upsert(self.fixture.global_template, request=mock_request)",
"def test_upsert_own_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.upsert(self.fixture.user1_template, request=mock_request)",
"def test_update_template_registration(self):\n pass",
"def test_partial_update_database_user(self):\n pass",
"def test_edit_authorized_user(self):\n pass",
"def test_get_user_template_as_anonymous_raises_access_control_error(self):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.get_by_id(\n self.fixture.user1_template.id, request=mock_request\n )"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test upsert user template as anonymous with access right raises access control error | def test_upsert_user_template_as_anonymous_with_access_right_raises_access_control_error(
self,
):
mock_request = create_mock_request(user=self.anonymous_user)
with self.assertRaises(AccessControlError):
template_api.upsert(
self.fixture.user1_template, request=mock_request
) | [
"def test_upsert_user_template_as_anonymous_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.upsert(\n self.fixture.user1_template, request=mock_request\n )",
"def test_upsert_global_template_as_user_raises_access_control_error(self):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.upsert(\n self.fixture.global_template, request=mock_request\n )",
"def test_upsert_global_template_as_anonymous_with_access_right_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.upsert(\n self.fixture.global_template, request=mock_request\n )",
"def test_upsert_global_template_as_anonymous_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.upsert(\n self.fixture.global_template, request=mock_request\n )",
"def test_update_template_permission(self):\n pass",
"def test_upsert_other_users_template_as_user_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.upsert(\n self.fixture.user2_template, request=mock_request\n )",
"def test_upsert_other_users_template_as_staff_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n with self.assertRaises(AccessControlError):\n template_api.upsert(\n self.fixture.user2_template, request=mock_request\n )",
"def test_upsert_own_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.upsert(self.fixture.user1_template, request=mock_request)",
"def test_upsert_global_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.upsert(self.fixture.global_template, request=mock_request)",
"def test_upsert_own_template_as_user_saves(self):\n mock_request = create_mock_request(user=self.user1)\n template_api.upsert(self.fixture.user1_template, request=mock_request)",
"def test_upsert_other_users_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.upsert(self.fixture.user2_template, request=mock_request)",
"def test_edit_authorized_user(self):\n pass",
"def test_get_user_template_as_anonymous_with_access_right_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.get_by_id(\n self.fixture.user1_template.id, request=mock_request\n )",
"def test_partial_update_system_user(self):\n pass",
"def test_set_display_name_user_template_as_anonymous_with_access_right_access_raises_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.user1_template, \"new_name\", request=mock_request\n )",
"def test_upsert_own_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.upsert(self.fixture.user1_template, request=mock_request)",
"def test_search_template_permission(self):\n pass",
"def test_get_user_template_as_anonymous_raises_access_control_error(self):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.get_by_id(\n self.fixture.user1_template.id, request=mock_request\n )",
"def test_partial_update_database_user(self):\n pass"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test upsert global template as anonymous raises access control error | def test_upsert_global_template_as_anonymous_raises_access_control_error(
self,
):
mock_request = create_mock_request(user=self.anonymous_user)
with self.assertRaises(AccessControlError):
template_api.upsert(
self.fixture.global_template, request=mock_request
) | [
"def test_upsert_global_template_as_anonymous_with_access_right_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.upsert(\n self.fixture.global_template, request=mock_request\n )",
"def test_upsert_global_template_as_user_raises_access_control_error(self):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.upsert(\n self.fixture.global_template, request=mock_request\n )",
"def test_upsert_user_template_as_anonymous_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.upsert(\n self.fixture.user1_template, request=mock_request\n )",
"def test_upsert_global_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.upsert(self.fixture.global_template, request=mock_request)",
"def test_upsert_user_template_as_anonymous_with_access_right_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.upsert(\n self.fixture.user1_template, request=mock_request\n )",
"def test_update_template_permission(self):\n pass",
"def test_update_template_registration(self):\n pass",
"def test_update_template(self):\n pass",
"def test_upsert_global_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.upsert(self.fixture.global_template, request=mock_request)",
"def test_upsert_own_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.upsert(self.fixture.user1_template, request=mock_request)",
"def test_edit_implant_template(self):\n pass",
"def test_upsert_own_template_as_user_saves(self):\n mock_request = create_mock_request(user=self.user1)\n template_api.upsert(self.fixture.user1_template, request=mock_request)",
"def test_email_template_put(self):\n pass",
"def test_upsert_other_users_template_as_user_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.upsert(\n self.fixture.user2_template, request=mock_request\n )",
"def test_no_template(self):\n distillery = Distillery.objects.get_by_natural_key(\n 'mongodb.test_database.test_docs')\n try:\n distillery.save()\n except AttributeError:\n self.fail('put_template() raised AttributeError unexpectedly')",
"def test_upsert_other_users_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.upsert(self.fixture.user2_template, request=mock_request)",
"def test_unshare_template_registration(self):\n pass",
"def test_upsert_other_users_template_as_staff_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n with self.assertRaises(AccessControlError):\n template_api.upsert(\n self.fixture.user2_template, request=mock_request\n )",
"def test_update_inspection_run_template(self):\n pass"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test upsert global template as anonymous raises access control error | def test_upsert_global_template_as_anonymous_with_access_right_raises_access_control_error(
self,
):
mock_request = create_mock_request(user=self.anonymous_user)
with self.assertRaises(AccessControlError):
template_api.upsert(
self.fixture.global_template, request=mock_request
) | [
"def test_upsert_global_template_as_anonymous_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.upsert(\n self.fixture.global_template, request=mock_request\n )",
"def test_upsert_global_template_as_user_raises_access_control_error(self):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.upsert(\n self.fixture.global_template, request=mock_request\n )",
"def test_upsert_user_template_as_anonymous_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.upsert(\n self.fixture.user1_template, request=mock_request\n )",
"def test_upsert_global_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.upsert(self.fixture.global_template, request=mock_request)",
"def test_upsert_user_template_as_anonymous_with_access_right_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.upsert(\n self.fixture.user1_template, request=mock_request\n )",
"def test_update_template_permission(self):\n pass",
"def test_update_template_registration(self):\n pass",
"def test_update_template(self):\n pass",
"def test_upsert_global_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.upsert(self.fixture.global_template, request=mock_request)",
"def test_upsert_own_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.upsert(self.fixture.user1_template, request=mock_request)",
"def test_edit_implant_template(self):\n pass",
"def test_upsert_own_template_as_user_saves(self):\n mock_request = create_mock_request(user=self.user1)\n template_api.upsert(self.fixture.user1_template, request=mock_request)",
"def test_email_template_put(self):\n pass",
"def test_upsert_other_users_template_as_user_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.upsert(\n self.fixture.user2_template, request=mock_request\n )",
"def test_no_template(self):\n distillery = Distillery.objects.get_by_natural_key(\n 'mongodb.test_database.test_docs')\n try:\n distillery.save()\n except AttributeError:\n self.fail('put_template() raised AttributeError unexpectedly')",
"def test_upsert_other_users_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.upsert(self.fixture.user2_template, request=mock_request)",
"def test_unshare_template_registration(self):\n pass",
"def test_upsert_other_users_template_as_staff_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n with self.assertRaises(AccessControlError):\n template_api.upsert(\n self.fixture.user2_template, request=mock_request\n )",
"def test_update_inspection_run_template(self):\n pass"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test upsert own template as user saves | def test_upsert_own_template_as_user_saves(self):
mock_request = create_mock_request(user=self.user1)
template_api.upsert(self.fixture.user1_template, request=mock_request) | [
"def test_upsert_own_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.upsert(self.fixture.user1_template, request=mock_request)",
"def test_upsert_own_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.upsert(self.fixture.user1_template, request=mock_request)",
"def test_upsert_other_users_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.upsert(self.fixture.user2_template, request=mock_request)",
"def test_upsert_global_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.upsert(self.fixture.global_template, request=mock_request)",
"def test_upsert_global_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.upsert(self.fixture.global_template, request=mock_request)",
"def upsert(template, request):\n # Check if schema is valid\n is_schema_valid(template.content, request=request)\n # Get hash for the template\n template.hash = get_hash(template.content)\n template.save_template()\n # Register local dependencies\n _register_local_dependencies(template, request=request)\n # Save template\n return template",
"def upsert(self):\n ...",
"def test_update_template(self):\n pass",
"def test_update_template_registration(self):\n pass",
"def test_email_template_put(self):\n pass",
"def test_upsert_user(self):\n db = database.Database()\n db.upsert_user('nick', 100, 100)\n\n the_args, _ = db._cursor.execute.call_args\n sql = the_args[0]\n expected_sql = 'INSERT INTO quota_violations (username, triggered, last_notified)\\n VALUES (%s, %s, %s)\\n ON CONFLICT (username)\\n DO UPDATE SET\\n (triggered, last_notified)\\n = (EXCLUDED.triggered, EXCLUDED.last_notified);\\n '\n\n self.assertEqual(sql, expected_sql)",
"def test_api_v1_template_programmer_template_put(self):\n pass",
"def test_collections_upsert_collection(self):\n pass",
"def test_upsert_global_template_as_user_raises_access_control_error(self):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.upsert(\n self.fixture.global_template, request=mock_request\n )",
"def test_update_template_permission(self):\n pass",
"def test_update_transaction_template(self):\n pass",
"def test_upsert_profile(mocker, mock_es_profile_serializer, user):\n patched_task = mocker.patch(\"search.search_index_helpers.tasks.upsert_profile\")\n upsert_profile(user.profile.id)\n patched_task.assert_called_once_with(user.profile.id)",
"def test_delete_own_template_as_user_saves(self):\n mock_request = create_mock_request(user=self.user1)\n template_api.delete(self.fixture.user1_template, request=mock_request)",
"def test_partial_update_database_user(self):\n pass"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test upsert other users template as user raises access control error | def test_upsert_other_users_template_as_user_raises_access_control_error(
self,
):
mock_request = create_mock_request(user=self.user1)
with self.assertRaises(AccessControlError):
template_api.upsert(
self.fixture.user2_template, request=mock_request
) | [
"def test_upsert_other_users_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.upsert(self.fixture.user2_template, request=mock_request)",
"def test_upsert_own_template_as_user_saves(self):\n mock_request = create_mock_request(user=self.user1)\n template_api.upsert(self.fixture.user1_template, request=mock_request)",
"def test_upsert_own_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.upsert(self.fixture.user1_template, request=mock_request)",
"def test_upsert_global_template_as_user_raises_access_control_error(self):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.upsert(\n self.fixture.global_template, request=mock_request\n )",
"def test_upsert_other_users_template_as_staff_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n with self.assertRaises(AccessControlError):\n template_api.upsert(\n self.fixture.user2_template, request=mock_request\n )",
"def test_upsert_global_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.upsert(self.fixture.global_template, request=mock_request)",
"def test_upsert_user_template_as_anonymous_with_access_right_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.upsert(\n self.fixture.user1_template, request=mock_request\n )",
"def test_upsert_own_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.upsert(self.fixture.user1_template, request=mock_request)",
"def test_upsert_user_template_as_anonymous_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.upsert(\n self.fixture.user1_template, request=mock_request\n )",
"def test_update_template_permission(self):\n pass",
"def test_upsert_global_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.upsert(self.fixture.global_template, request=mock_request)",
"def test_upsert_global_template_as_anonymous_with_access_right_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.upsert(\n self.fixture.global_template, request=mock_request\n )",
"def test_upsert_global_template_as_anonymous_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.upsert(\n self.fixture.global_template, request=mock_request\n )",
"def test_partial_update_system_user(self):\n pass",
"def test_partial_update_database_user(self):\n pass",
"def test_duplicate_user(self):\n pass",
"def test_update_template(self):\n pass",
"def test_update_template_registration(self):\n pass",
"def test_delete_other_users_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.delete(self.fixture.user2_template, request=mock_request)"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test upsert global template as user raises access control error | def test_upsert_global_template_as_user_raises_access_control_error(self):
mock_request = create_mock_request(user=self.user1)
with self.assertRaises(AccessControlError):
template_api.upsert(
self.fixture.global_template, request=mock_request
) | [
"def test_upsert_global_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.upsert(self.fixture.global_template, request=mock_request)",
"def test_upsert_own_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.upsert(self.fixture.user1_template, request=mock_request)",
"def test_update_template_permission(self):\n pass",
"def test_upsert_own_template_as_user_saves(self):\n mock_request = create_mock_request(user=self.user1)\n template_api.upsert(self.fixture.user1_template, request=mock_request)",
"def test_upsert_other_users_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.upsert(self.fixture.user2_template, request=mock_request)",
"def test_upsert_global_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.upsert(self.fixture.global_template, request=mock_request)",
"def test_upsert_global_template_as_anonymous_with_access_right_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.upsert(\n self.fixture.global_template, request=mock_request\n )",
"def test_upsert_global_template_as_anonymous_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.upsert(\n self.fixture.global_template, request=mock_request\n )",
"def test_upsert_other_users_template_as_user_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.upsert(\n self.fixture.user2_template, request=mock_request\n )",
"def test_upsert_user_template_as_anonymous_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.upsert(\n self.fixture.user1_template, request=mock_request\n )",
"def test_upsert_user_template_as_anonymous_with_access_right_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.upsert(\n self.fixture.user1_template, request=mock_request\n )",
"def test_upsert_other_users_template_as_staff_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n with self.assertRaises(AccessControlError):\n template_api.upsert(\n self.fixture.user2_template, request=mock_request\n )",
"def test_update_template_registration(self):\n pass",
"def test_update_template(self):\n pass",
"def test_upsert_own_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.upsert(self.fixture.user1_template, request=mock_request)",
"def test_partial_update_system_user(self):\n pass",
"def test_edit_implant_template(self):\n pass",
"def test_email_template_put(self):\n pass",
"def test_share_template_registration(self):\n pass"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test upsert own template as staff saves | def test_upsert_own_template_as_staff_saves(self):
mock_request = create_mock_request(user=self.staff_user1)
template_api.upsert(self.fixture.user1_template, request=mock_request) | [
"def test_upsert_global_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.upsert(self.fixture.global_template, request=mock_request)",
"def test_upsert_own_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.upsert(self.fixture.user1_template, request=mock_request)",
"def test_upsert_own_template_as_user_saves(self):\n mock_request = create_mock_request(user=self.user1)\n template_api.upsert(self.fixture.user1_template, request=mock_request)",
"def test_upsert_global_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.upsert(self.fixture.global_template, request=mock_request)",
"def test_upsert_other_users_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.upsert(self.fixture.user2_template, request=mock_request)",
"def test_update_template(self):\n pass",
"def upsert(self):\n ...",
"def upsert(template, request):\n # Check if schema is valid\n is_schema_valid(template.content, request=request)\n # Get hash for the template\n template.hash = get_hash(template.content)\n template.save_template()\n # Register local dependencies\n _register_local_dependencies(template, request=request)\n # Save template\n return template",
"def test_update_template_registration(self):\n pass",
"def test_email_template_put(self):\n pass",
"def test_api_v1_template_programmer_template_put(self):\n pass",
"def test_collections_upsert_collection(self):\n pass",
"def test_update_transaction_template(self):\n pass",
"def test_is_data_in_template_and_database_same(self):\n SimplePersonFactory.create()\n contact = Person.objects.last()\n self.assertEqual(check_content_in_template(contact), True)\n contact.name = \"test_is_data_in_template_and_database_same\"\n contact.save()\n self.assertEqual(check_content_in_template(contact), True)",
"def test_edit_implant_template(self):\n pass",
"def test_update_template_permission(self):\n pass",
"def test_update_transaction_template_item(self):\n pass",
"def test_update_activity_template(self):\n pass",
"def test_upsert_other_users_template_as_staff_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n with self.assertRaises(AccessControlError):\n template_api.upsert(\n self.fixture.user2_template, request=mock_request\n )"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test upsert other users template as staff raises access control error | def test_upsert_other_users_template_as_staff_raises_access_control_error(
self,
):
mock_request = create_mock_request(user=self.staff_user1)
with self.assertRaises(AccessControlError):
template_api.upsert(
self.fixture.user2_template, request=mock_request
) | [
"def test_upsert_other_users_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.upsert(self.fixture.user2_template, request=mock_request)",
"def test_upsert_own_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.upsert(self.fixture.user1_template, request=mock_request)",
"def test_upsert_own_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.upsert(self.fixture.user1_template, request=mock_request)",
"def test_upsert_other_users_template_as_user_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.upsert(\n self.fixture.user2_template, request=mock_request\n )",
"def test_upsert_own_template_as_user_saves(self):\n mock_request = create_mock_request(user=self.user1)\n template_api.upsert(self.fixture.user1_template, request=mock_request)",
"def test_upsert_global_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.upsert(self.fixture.global_template, request=mock_request)",
"def test_upsert_global_template_as_user_raises_access_control_error(self):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.upsert(\n self.fixture.global_template, request=mock_request\n )",
"def test_upsert_global_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.upsert(self.fixture.global_template, request=mock_request)",
"def test_update_template_permission(self):\n pass",
"def test_upsert_user_template_as_anonymous_with_access_right_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.upsert(\n self.fixture.user1_template, request=mock_request\n )",
"def test_upsert_user_template_as_anonymous_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.upsert(\n self.fixture.user1_template, request=mock_request\n )",
"def test_upsert_global_template_as_anonymous_with_access_right_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.upsert(\n self.fixture.global_template, request=mock_request\n )",
"def test_partial_update_system_user(self):\n pass",
"def test_get_other_users_template_as_staff_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n with self.assertRaises(AccessControlError):\n template_api.get_by_id(\n self.fixture.user2_template.id, request=mock_request\n )",
"def test_partial_update_database_user(self):\n pass",
"def test_update_template(self):\n pass",
"def test_upsert_global_template_as_anonymous_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.upsert(\n self.fixture.global_template, request=mock_request\n )",
"def test_update_template_registration(self):\n pass",
"def test_set_display_name_other_users_template_as_staff_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.user2_template, \"new_name\", request=mock_request\n )"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test upsert global template as staff saves | def test_upsert_global_template_as_staff_saves(self):
mock_request = create_mock_request(user=self.staff_user1)
template_api.upsert(self.fixture.global_template, request=mock_request) | [
"def test_upsert_global_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.upsert(self.fixture.global_template, request=mock_request)",
"def test_upsert_own_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.upsert(self.fixture.user1_template, request=mock_request)",
"def test_upsert_own_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.upsert(self.fixture.user1_template, request=mock_request)",
"def test_upsert_own_template_as_user_saves(self):\n mock_request = create_mock_request(user=self.user1)\n template_api.upsert(self.fixture.user1_template, request=mock_request)",
"def test_upsert_other_users_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.upsert(self.fixture.user2_template, request=mock_request)",
"def test_update_template(self):\n pass",
"def test_update_template_registration(self):\n pass",
"def test_email_template_put(self):\n pass",
"def upsert(self):\n ...",
"def test_api_v1_template_programmer_template_put(self):\n pass",
"def upsert(template, request):\n # Check if schema is valid\n is_schema_valid(template.content, request=request)\n # Get hash for the template\n template.hash = get_hash(template.content)\n template.save_template()\n # Register local dependencies\n _register_local_dependencies(template, request=request)\n # Save template\n return template",
"def test_collections_upsert_collection(self):\n pass",
"def test_delete_global_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.delete(self.fixture.global_template, request=mock_request)",
"def test_update_template_permission(self):\n pass",
"def test_update_transaction_template(self):\n pass",
"def test_edit_implant_template(self):\n pass",
"def test_update_activity_template(self):\n pass",
"def test_is_data_in_template_and_database_same(self):\n SimplePersonFactory.create()\n contact = Person.objects.last()\n self.assertEqual(check_content_in_template(contact), True)\n contact.name = \"test_is_data_in_template_and_database_same\"\n contact.save()\n self.assertEqual(check_content_in_template(contact), True)",
"def test_update_inspection_run_template(self):\n pass"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test upsert own template as superuser saves | def test_upsert_own_template_as_superuser_saves(self):
mock_request = create_mock_request(user=self.superuser1)
template_api.upsert(self.fixture.user1_template, request=mock_request) | [
"def test_upsert_global_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.upsert(self.fixture.global_template, request=mock_request)",
"def test_upsert_other_users_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.upsert(self.fixture.user2_template, request=mock_request)",
"def test_upsert_own_template_as_user_saves(self):\n mock_request = create_mock_request(user=self.user1)\n template_api.upsert(self.fixture.user1_template, request=mock_request)",
"def test_upsert_own_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.upsert(self.fixture.user1_template, request=mock_request)",
"def test_upsert_global_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.upsert(self.fixture.global_template, request=mock_request)",
"def upsert(self):\n ...",
"def upsert(template, request):\n # Check if schema is valid\n is_schema_valid(template.content, request=request)\n # Get hash for the template\n template.hash = get_hash(template.content)\n template.save_template()\n # Register local dependencies\n _register_local_dependencies(template, request=request)\n # Save template\n return template",
"def test_update_template(self):\n pass",
"def test_update_template_registration(self):\n pass",
"def test_update_template_permission(self):\n pass",
"def test_email_template_put(self):\n pass",
"def test_delete_own_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.delete(self.fixture.user1_template, request=mock_request)",
"def test_api_v1_template_programmer_template_put(self):\n pass",
"def test_upsert_global_template_as_user_raises_access_control_error(self):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.upsert(\n self.fixture.global_template, request=mock_request\n )",
"def test_upsert_user(self):\n db = database.Database()\n db.upsert_user('nick', 100, 100)\n\n the_args, _ = db._cursor.execute.call_args\n sql = the_args[0]\n expected_sql = 'INSERT INTO quota_violations (username, triggered, last_notified)\\n VALUES (%s, %s, %s)\\n ON CONFLICT (username)\\n DO UPDATE SET\\n (triggered, last_notified)\\n = (EXCLUDED.triggered, EXCLUDED.last_notified);\\n '\n\n self.assertEqual(sql, expected_sql)",
"def test_collections_upsert_collection(self):\n pass",
"def test_update_transaction_template(self):\n pass",
"def test_edit_implant_template(self):\n pass",
"def test_delete_other_users_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.delete(self.fixture.user2_template, request=mock_request)"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test upsert other users template as superuser saves | def test_upsert_other_users_template_as_superuser_saves(self):
mock_request = create_mock_request(user=self.superuser1)
template_api.upsert(self.fixture.user2_template, request=mock_request) | [
"def test_upsert_own_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.upsert(self.fixture.user1_template, request=mock_request)",
"def test_upsert_own_template_as_user_saves(self):\n mock_request = create_mock_request(user=self.user1)\n template_api.upsert(self.fixture.user1_template, request=mock_request)",
"def test_upsert_global_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.upsert(self.fixture.global_template, request=mock_request)",
"def test_upsert_own_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.upsert(self.fixture.user1_template, request=mock_request)",
"def test_upsert_global_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.upsert(self.fixture.global_template, request=mock_request)",
"def upsert(self):\n ...",
"def upsert(template, request):\n # Check if schema is valid\n is_schema_valid(template.content, request=request)\n # Get hash for the template\n template.hash = get_hash(template.content)\n template.save_template()\n # Register local dependencies\n _register_local_dependencies(template, request=request)\n # Save template\n return template",
"def test_delete_other_users_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.delete(self.fixture.user2_template, request=mock_request)",
"def test_update_template(self):\n pass",
"def test_update_template_registration(self):\n pass",
"def test_delete_own_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.delete(self.fixture.user1_template, request=mock_request)",
"def test_upsert_other_users_template_as_user_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.upsert(\n self.fixture.user2_template, request=mock_request\n )",
"def test_upsert_other_users_template_as_staff_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n with self.assertRaises(AccessControlError):\n template_api.upsert(\n self.fixture.user2_template, request=mock_request\n )",
"def test_upsert_user(self):\n db = database.Database()\n db.upsert_user('nick', 100, 100)\n\n the_args, _ = db._cursor.execute.call_args\n sql = the_args[0]\n expected_sql = 'INSERT INTO quota_violations (username, triggered, last_notified)\\n VALUES (%s, %s, %s)\\n ON CONFLICT (username)\\n DO UPDATE SET\\n (triggered, last_notified)\\n = (EXCLUDED.triggered, EXCLUDED.last_notified);\\n '\n\n self.assertEqual(sql, expected_sql)",
"def test_upsert_global_template_as_user_raises_access_control_error(self):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.upsert(\n self.fixture.global_template, request=mock_request\n )",
"def test_update_template_permission(self):\n pass",
"def test_partial_update_database_user(self):\n pass",
"def test_email_template_put(self):\n pass",
"def test_api_v1_template_programmer_template_put(self):\n pass"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test upsert global template as superuser saves | def test_upsert_global_template_as_superuser_saves(self):
mock_request = create_mock_request(user=self.superuser1)
template_api.upsert(self.fixture.global_template, request=mock_request) | [
"def test_upsert_own_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.upsert(self.fixture.user1_template, request=mock_request)",
"def test_upsert_other_users_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.upsert(self.fixture.user2_template, request=mock_request)",
"def test_upsert_global_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.upsert(self.fixture.global_template, request=mock_request)",
"def test_upsert_own_template_as_user_saves(self):\n mock_request = create_mock_request(user=self.user1)\n template_api.upsert(self.fixture.user1_template, request=mock_request)",
"def test_upsert_own_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.upsert(self.fixture.user1_template, request=mock_request)",
"def test_update_template_registration(self):\n pass",
"def test_update_template(self):\n pass",
"def upsert(template, request):\n # Check if schema is valid\n is_schema_valid(template.content, request=request)\n # Get hash for the template\n template.hash = get_hash(template.content)\n template.save_template()\n # Register local dependencies\n _register_local_dependencies(template, request=request)\n # Save template\n return template",
"def upsert(self):\n ...",
"def test_delete_global_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.delete(self.fixture.global_template, request=mock_request)",
"def test_email_template_put(self):\n pass",
"def test_update_template_permission(self):\n pass",
"def test_upsert_global_template_as_user_raises_access_control_error(self):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.upsert(\n self.fixture.global_template, request=mock_request\n )",
"def test_api_v1_template_programmer_template_put(self):\n pass",
"def test_delete_own_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.delete(self.fixture.user1_template, request=mock_request)",
"def test_set_display_name_global_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def test_edit_implant_template(self):\n pass",
"def test_delete_other_users_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.delete(self.fixture.user2_template, request=mock_request)",
"def test_update_transaction_template(self):\n pass"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test set display name user template as anonymous raises access control error | def test_set_display_name_user_template_as_anonymous_raises_access_control_error(
self,
):
mock_request = create_mock_request(user=self.anonymous_user)
with self.assertRaises(AccessControlError):
template_api.set_display_name(
self.fixture.user1_template, "new_name", request=mock_request
) | [
"def test_set_display_name_user_template_as_anonymous_with_access_right_access_raises_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.user1_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_global_template_as_user_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_global_template_as_anonymous_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_global_template_as_anonymous_with_access_right_access_raises_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_other_users_template_as_user_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.user2_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_other_users_template_as_staff_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.user2_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_own_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.set_display_name(\n self.fixture.user1_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_global_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_other_users_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.set_display_name(\n self.fixture.user2_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_own_template_as_user_saves(self):\n mock_request = create_mock_request(user=self.user1)\n template_api.set_display_name(\n self.fixture.user1_template, \"new_name\", request=mock_request\n )",
"def test_display_name_template(param):\n assert param",
"def test_set_display_name_own_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.set_display_name(\n self.fixture.user1_template, \"new_name\", request=mock_request\n )",
"def show_nonexisting_user(self):\n self.test_runner.run_nonexisting_user_show()",
"def test_profile_template(self):\n user = User.objects.first()\n self.client.force_login(user)\n response = self.client.get('/profile/')\n self.assertEqual(response.templates[0].name, 'imager_profile/profile.html')",
"def test_set_display_name_global_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def test_profile_route_uses_right_templates(self):\n self.add_testuser()\n response = self.client.get(\"/profile/testuser/\")\n self.assertTemplateUsed(response, \"layout.html\")",
"def test_automatic_default_public_username_role_administrator(self):\n\n consumer = LTIConsumerFactory(slug=\"consumer\")\n passport = LTIPassportFactory(title=\"consumer1_passport1\", consumer=consumer)\n\n user_count = get_user_model().objects.count()\n\n new_user = self._authenticate(\n {\n \"user_id\": \"3fd0ff83-a62d-4a12-9716-4d48821ae24f\",\n \"lti_message_type\": \"basic-lti-launch-request\",\n \"lti_version\": \"LTI-1p0\",\n \"resource_link_id\": \"aaa\",\n \"context_id\": \"course-v1:fooschool+authbackend+0001\",\n \"lis_person_contact_email_primary\": \"user_without_username@example.com\",\n \"roles\": \"Administrator\",\n },\n passport,\n )\n\n self.assertEqual(consumer, new_user.lti_consumer)\n self.assertEqual(\"user_without_username@example.com\", new_user.email)\n self.assertEqual(\n \"3fd0ff83-a62d-4a12-9716-4d48821ae24f@consumer\", new_user.username\n )\n self.assertEqual(user_count + 1, get_user_model().objects.count())\n self.assertEqual(\"Administrator\", new_user.public_username)",
"def test_automatic_default_public_username_role_administrator_instructor(self):\n\n consumer = LTIConsumerFactory(slug=\"consumer\")\n passport = LTIPassportFactory(title=\"consumer1_passport1\", consumer=consumer)\n\n user_count = get_user_model().objects.count()\n\n new_user = self._authenticate(\n {\n \"user_id\": \"3fd0ff83-a62d-4a12-9716-4d48821ae24f\",\n \"lti_message_type\": \"basic-lti-launch-request\",\n \"lti_version\": \"LTI-1p0\",\n \"resource_link_id\": \"aaa\",\n \"context_id\": \"course-v1:fooschool+authbackend+0001\",\n \"lis_person_contact_email_primary\": \"user_without_username@example.com\",\n \"roles\": (\n \"Administrator,Instructor,urn:lti:sysrole:ims/lis/Administrator,\"\n \"urn:lti:instrole:ims/lis/Administrator\"\n ),\n },\n passport,\n )\n\n self.assertEqual(consumer, new_user.lti_consumer)\n self.assertEqual(\"user_without_username@example.com\", new_user.email)\n self.assertEqual(\n \"3fd0ff83-a62d-4a12-9716-4d48821ae24f@consumer\", new_user.username\n )\n self.assertEqual(user_count + 1, get_user_model().objects.count())\n self.assertEqual(\"Educational team\", new_user.public_username)",
"def test_edit_authorized_user(self):\n pass"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test set display name user template as anonymous with right access raises access control error | def test_set_display_name_user_template_as_anonymous_with_access_right_access_raises_control_error(
self,
):
mock_request = create_mock_request(user=self.anonymous_user)
with self.assertRaises(AccessControlError):
template_api.set_display_name(
self.fixture.user1_template, "new_name", request=mock_request
) | [
"def test_set_display_name_global_template_as_user_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_user_template_as_anonymous_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.user1_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_global_template_as_anonymous_with_access_right_access_raises_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_global_template_as_anonymous_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_other_users_template_as_user_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.user2_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_other_users_template_as_staff_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.user2_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_own_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.set_display_name(\n self.fixture.user1_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_other_users_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.set_display_name(\n self.fixture.user2_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_global_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def test_edit_authorized_user(self):\n pass",
"def test_set_display_name_own_template_as_user_saves(self):\n mock_request = create_mock_request(user=self.user1)\n template_api.set_display_name(\n self.fixture.user1_template, \"new_name\", request=mock_request\n )",
"def test_profile_route_uses_right_templates(self):\n self.add_testuser()\n response = self.client.get(\"/profile/testuser/\")\n self.assertTemplateUsed(response, \"layout.html\")",
"def test_set_display_name_own_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.set_display_name(\n self.fixture.user1_template, \"new_name\", request=mock_request\n )",
"def test_automatic_default_public_username_role_administrator(self):\n\n consumer = LTIConsumerFactory(slug=\"consumer\")\n passport = LTIPassportFactory(title=\"consumer1_passport1\", consumer=consumer)\n\n user_count = get_user_model().objects.count()\n\n new_user = self._authenticate(\n {\n \"user_id\": \"3fd0ff83-a62d-4a12-9716-4d48821ae24f\",\n \"lti_message_type\": \"basic-lti-launch-request\",\n \"lti_version\": \"LTI-1p0\",\n \"resource_link_id\": \"aaa\",\n \"context_id\": \"course-v1:fooschool+authbackend+0001\",\n \"lis_person_contact_email_primary\": \"user_without_username@example.com\",\n \"roles\": \"Administrator\",\n },\n passport,\n )\n\n self.assertEqual(consumer, new_user.lti_consumer)\n self.assertEqual(\"user_without_username@example.com\", new_user.email)\n self.assertEqual(\n \"3fd0ff83-a62d-4a12-9716-4d48821ae24f@consumer\", new_user.username\n )\n self.assertEqual(user_count + 1, get_user_model().objects.count())\n self.assertEqual(\"Administrator\", new_user.public_username)",
"def test_search_template_permission(self):\n pass",
"def test_profile_template(self):\n user = User.objects.first()\n self.client.force_login(user)\n response = self.client.get('/profile/')\n self.assertEqual(response.templates[0].name, 'imager_profile/profile.html')",
"def test_automatic_default_public_username_role_administrator_instructor(self):\n\n consumer = LTIConsumerFactory(slug=\"consumer\")\n passport = LTIPassportFactory(title=\"consumer1_passport1\", consumer=consumer)\n\n user_count = get_user_model().objects.count()\n\n new_user = self._authenticate(\n {\n \"user_id\": \"3fd0ff83-a62d-4a12-9716-4d48821ae24f\",\n \"lti_message_type\": \"basic-lti-launch-request\",\n \"lti_version\": \"LTI-1p0\",\n \"resource_link_id\": \"aaa\",\n \"context_id\": \"course-v1:fooschool+authbackend+0001\",\n \"lis_person_contact_email_primary\": \"user_without_username@example.com\",\n \"roles\": (\n \"Administrator,Instructor,urn:lti:sysrole:ims/lis/Administrator,\"\n \"urn:lti:instrole:ims/lis/Administrator\"\n ),\n },\n passport,\n )\n\n self.assertEqual(consumer, new_user.lti_consumer)\n self.assertEqual(\"user_without_username@example.com\", new_user.email)\n self.assertEqual(\n \"3fd0ff83-a62d-4a12-9716-4d48821ae24f@consumer\", new_user.username\n )\n self.assertEqual(user_count + 1, get_user_model().objects.count())\n self.assertEqual(\"Educational team\", new_user.public_username)",
"def test_replace_user(self):\n pass",
"def test_update_template_permission(self):\n pass"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test set display name global template as anonymous raises access control error | def test_set_display_name_global_template_as_anonymous_raises_access_control_error(
self,
):
mock_request = create_mock_request(user=self.anonymous_user)
with self.assertRaises(AccessControlError):
template_api.set_display_name(
self.fixture.global_template, "new_name", request=mock_request
) | [
"def test_set_display_name_global_template_as_anonymous_with_access_right_access_raises_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_global_template_as_user_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_user_template_as_anonymous_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.user1_template, \"new_name\", request=mock_request\n )",
"def test_display_name_template(param):\n assert param",
"def test_set_display_name_user_template_as_anonymous_with_access_right_access_raises_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.user1_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_global_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_own_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.set_display_name(\n self.fixture.user1_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_global_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def test_unicode_display_name_template(param):\n assert param",
"def test_get_implant_template_by_name(self):\n pass",
"def test_set_display_name_other_users_template_as_user_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.user2_template, \"new_name\", request=mock_request\n )",
"def test_create_namespaced_template(self):\n pass",
"def test_register_template(self):\n pass",
"def test_edit_implant_template(self):\n pass",
"def test_set_display_name_own_template_as_user_saves(self):\n mock_request = create_mock_request(user=self.user1)\n template_api.set_display_name(\n self.fixture.user1_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_other_users_template_as_staff_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.user2_template, \"new_name\", request=mock_request\n )",
"def template_name(self):\n\t\traise NotImplementedError('template_name must be defined')",
"def test_create_template_subsciption(self):\n pass",
"def test_set_display_name_other_users_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.set_display_name(\n self.fixture.user2_template, \"new_name\", request=mock_request\n )"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test set display name global template as anonymous with right access raises access control error | def test_set_display_name_global_template_as_anonymous_with_access_right_access_raises_control_error(
self,
):
mock_request = create_mock_request(user=self.anonymous_user)
with self.assertRaises(AccessControlError):
template_api.set_display_name(
self.fixture.global_template, "new_name", request=mock_request
) | [
"def test_set_display_name_global_template_as_user_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_global_template_as_anonymous_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_user_template_as_anonymous_with_access_right_access_raises_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.user1_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_user_template_as_anonymous_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.user1_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_global_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_other_users_template_as_user_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.user2_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_other_users_template_as_staff_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.user2_template, \"new_name\", request=mock_request\n )",
"def test_display_name_template(param):\n assert param",
"def test_set_display_name_own_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.set_display_name(\n self.fixture.user1_template, \"new_name\", request=mock_request\n )",
"def test_edit_implant_template(self):\n pass",
"def test_set_display_name_global_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def test_search_template_permission(self):\n pass",
"def test_create_template_subsciption(self):\n pass",
"def test_get_implant_template_by_name(self):\n pass",
"def test_create_namespaced_template(self):\n pass",
"def test_get_global_template_as_anonymous_with_access_right_returns_template(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n template = template_api.get_by_id(\n self.fixture.global_template.id, request=mock_request\n )\n self.assertEqual(template, self.fixture.global_template)",
"def test_register_template(self):\n pass",
"def test_get_implant_template(self):\n pass",
"def test_share_template_registration(self):\n pass"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test set display name own template as user saves | def test_set_display_name_own_template_as_user_saves(self):
mock_request = create_mock_request(user=self.user1)
template_api.set_display_name(
self.fixture.user1_template, "new_name", request=mock_request
) | [
"def test_set_display_name_own_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.set_display_name(\n self.fixture.user1_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_global_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_own_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.set_display_name(\n self.fixture.user1_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_other_users_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.set_display_name(\n self.fixture.user2_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_global_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def set_display_name(template, display_name, request):\n # Set display name\n template.display_name = display_name\n # Save\n template.save()",
"def test_set_display_name_global_template_as_user_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def test_display_name_template(param):\n assert param",
"def test_upsert_own_template_as_user_saves(self):\n mock_request = create_mock_request(user=self.user1)\n template_api.upsert(self.fixture.user1_template, request=mock_request)",
"def edit_user_name():\n raise NotImplementedError",
"def test_obj_creation_username(self):\n eq_(self.obj.user_name, \"ignucius\")",
"def test_upsert_own_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.upsert(self.fixture.user1_template, request=mock_request)",
"def test_set_display_name_other_users_template_as_user_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.user2_template, \"new_name\", request=mock_request\n )",
"def test_profile_template(self):\n user = User.objects.first()\n self.client.force_login(user)\n response = self.client.get('/profile/')\n self.assertEqual(response.templates[0].name, 'imager_profile/profile.html')",
"def test_set_displayname(self) -> None:\n\n # Modify user\n channel = self.make_request(\n \"PUT\",\n self.url_other_user,\n access_token=self.admin_user_tok,\n content={\"displayname\": \"foobar\"},\n )\n\n self.assertEqual(200, channel.code, msg=channel.json_body)\n self.assertEqual(\"@user:test\", channel.json_body[\"name\"])\n self.assertEqual(\"foobar\", channel.json_body[\"displayname\"])\n\n # Get user\n channel = self.make_request(\n \"GET\",\n self.url_other_user,\n access_token=self.admin_user_tok,\n )\n\n self.assertEqual(200, channel.code, msg=channel.json_body)\n self.assertEqual(\"@user:test\", channel.json_body[\"name\"])\n self.assertEqual(\"foobar\", channel.json_body[\"displayname\"])",
"def test_profile_route_uses_right_templates(self):\n self.add_testuser()\n response = self.client.get(\"/profile/testuser/\")\n self.assertTemplateUsed(response, \"layout.html\")",
"def autoname(self):\n\t\tself.name = self.role_profile",
"def test_edit_implant_template(self):\n pass",
"def test_display_name_mirrored_default(self):\n a = Account.objects.create(email='test_email')\n e = Entity.objects.get_for_obj(a)\n self.assertEqual(e.display_name, 'test_email')"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test set display name other users template as user raises access control error | def test_set_display_name_other_users_template_as_user_raises_access_control_error(
self,
):
mock_request = create_mock_request(user=self.user1)
with self.assertRaises(AccessControlError):
template_api.set_display_name(
self.fixture.user2_template, "new_name", request=mock_request
) | [
"def test_set_display_name_global_template_as_user_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_own_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.set_display_name(\n self.fixture.user1_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_other_users_template_as_staff_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.user2_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_other_users_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.set_display_name(\n self.fixture.user2_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_own_template_as_user_saves(self):\n mock_request = create_mock_request(user=self.user1)\n template_api.set_display_name(\n self.fixture.user1_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_user_template_as_anonymous_with_access_right_access_raises_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.user1_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_user_template_as_anonymous_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.user1_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_global_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_own_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.set_display_name(\n self.fixture.user1_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_global_template_as_anonymous_with_access_right_access_raises_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_global_template_as_anonymous_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_global_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def test_user_verbose_name(self):\n self.assertEquals(self.user_profile_inst._meta.get_field('user').verbose_name, 'Пользователь')",
"def test_replace_user(self):\n pass",
"def test_display_name_template(param):\n assert param",
"def test_set_displayname(self) -> None:\n\n # Modify user\n channel = self.make_request(\n \"PUT\",\n self.url_other_user,\n access_token=self.admin_user_tok,\n content={\"displayname\": \"foobar\"},\n )\n\n self.assertEqual(200, channel.code, msg=channel.json_body)\n self.assertEqual(\"@user:test\", channel.json_body[\"name\"])\n self.assertEqual(\"foobar\", channel.json_body[\"displayname\"])\n\n # Get user\n channel = self.make_request(\n \"GET\",\n self.url_other_user,\n access_token=self.admin_user_tok,\n )\n\n self.assertEqual(200, channel.code, msg=channel.json_body)\n self.assertEqual(\"@user:test\", channel.json_body[\"name\"])\n self.assertEqual(\"foobar\", channel.json_body[\"displayname\"])",
"def edit_user_name():\n raise NotImplementedError",
"def test_user_first_name(self):\n self.assertEqual(self.user.get_short_name(), 'First')",
"def test_get_form_label_name(self):\n self.user.name = 'Full Name'\n self.assertEqual(\n self.user.get_form_label(),\n 'Full Name (testuser)',\n )"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test set display name global template as user raises access control error | def test_set_display_name_global_template_as_user_raises_access_control_error(
self,
):
mock_request = create_mock_request(user=self.user1)
with self.assertRaises(AccessControlError):
template_api.set_display_name(
self.fixture.global_template, "new_name", request=mock_request
) | [
"def test_set_display_name_global_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_global_template_as_anonymous_with_access_right_access_raises_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_own_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.set_display_name(\n self.fixture.user1_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_global_template_as_anonymous_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_other_users_template_as_user_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.user2_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_global_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_other_users_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.set_display_name(\n self.fixture.user2_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_own_template_as_user_saves(self):\n mock_request = create_mock_request(user=self.user1)\n template_api.set_display_name(\n self.fixture.user1_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_user_template_as_anonymous_with_access_right_access_raises_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.user1_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_user_template_as_anonymous_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.user1_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_other_users_template_as_staff_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.user2_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_own_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.set_display_name(\n self.fixture.user1_template, \"new_name\", request=mock_request\n )",
"def test_display_name_template(param):\n assert param",
"def test_unicode_display_name_template(param):\n assert param",
"def test_update_template_profile_for_system_module(self):\n pass",
"def test_profile_route_uses_right_templates(self):\n self.add_testuser()\n response = self.client.get(\"/profile/testuser/\")\n self.assertTemplateUsed(response, \"layout.html\")",
"def test_create_template_subsciption(self):\n pass",
"def test_global_template_as_user_returns_template(self):\n mock_request = create_mock_request(user=self.user1)\n template = template_api.get_by_id(\n self.fixture.global_template.id, request=mock_request\n )\n self.assertEqual(template, self.fixture.global_template)",
"def test_edit_implant_template(self):\n pass"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test set display name own template as staff saves | def test_set_display_name_own_template_as_staff_saves(self):
mock_request = create_mock_request(user=self.staff_user1)
template_api.set_display_name(
self.fixture.user1_template, "new_name", request=mock_request
) | [
"def test_set_display_name_global_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_own_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.set_display_name(\n self.fixture.user1_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_own_template_as_user_saves(self):\n mock_request = create_mock_request(user=self.user1)\n template_api.set_display_name(\n self.fixture.user1_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_global_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_other_users_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.set_display_name(\n self.fixture.user2_template, \"new_name\", request=mock_request\n )",
"def set_display_name(template, display_name, request):\n # Set display name\n template.display_name = display_name\n # Save\n template.save()",
"def test_edit_implant_template(self):\n pass",
"def test_upsert_own_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.upsert(self.fixture.user1_template, request=mock_request)",
"def test_display_name_template(param):\n assert param",
"def test_set_display_name_other_users_template_as_staff_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.user2_template, \"new_name\", request=mock_request\n )",
"def test_upsert_global_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.upsert(self.fixture.global_template, request=mock_request)",
"def test_create_template_subsciption(self):\n pass",
"def test_obj_creation_displayname(self):\n eq_(self.obj.display_name, u'Test Zone')",
"def test_set_display_name_global_template_as_user_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def test_create_with_template(self):\n values = {\n \"name\": \"pouet.com\", \"quota\": 100, \"create_dom_admin\": \"yes\",\n \"dom_admin_username\": \"toto\", \"create_aliases\": \"yes\",\n \"stepid\": 2\n }\n self.check_ajax_post(reverse(\"modoboa.admin.views.newdomain\"), values)\n dom = Domain.objects.get(name=\"pouet.com\")\n da = User.objects.get(username=\"toto@pouet.com\")\n self.assertIn(da, dom.admins)\n al = Alias.objects.get(address=\"postmaster\", domain__name=\"pouet.com\")\n self.assertIn(da.mailbox_set.all()[0], al.mboxes.all())\n self.assertTrue(da.can_access(al))",
"def test_upsert_own_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.upsert(self.fixture.user1_template, request=mock_request)",
"def test_create_implant_template(self):\n pass",
"def autoname(self):\n\t\timport re\n\t\tfrom webnotes.utils import validate_email_add\n\n\t\tif self.doc.name not in ('Guest','Administrator'):\n\t\t\tself.doc.email = self.doc.email.strip()\n\t\t\tif not validate_email_add(self.doc.email):\n\t\t\t\twebnotes.msgprint(\"%s is not a valid email id\" % self.doc.email)\n\t\t\t\traise Exception\n\t\t\n\t\t\tself.doc.name = self.doc.email",
"def test_register_template(self):\n pass"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test set display name other users template as staff raises access control error | def test_set_display_name_other_users_template_as_staff_raises_access_control_error(
self,
):
mock_request = create_mock_request(user=self.staff_user1)
with self.assertRaises(AccessControlError):
template_api.set_display_name(
self.fixture.user2_template, "new_name", request=mock_request
) | [
"def test_set_display_name_global_template_as_user_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_own_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.set_display_name(\n self.fixture.user1_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_other_users_template_as_user_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.user2_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_own_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.set_display_name(\n self.fixture.user1_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_user_template_as_anonymous_with_access_right_access_raises_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.user1_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_other_users_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.set_display_name(\n self.fixture.user2_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_global_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_global_template_as_anonymous_with_access_right_access_raises_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_user_template_as_anonymous_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.user1_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_global_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_own_template_as_user_saves(self):\n mock_request = create_mock_request(user=self.user1)\n template_api.set_display_name(\n self.fixture.user1_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_global_template_as_anonymous_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def test_replace_user(self):\n pass",
"def test_edit_authorized_user(self):\n pass",
"def test_display_name_template(param):\n assert param",
"def test_set_displayname(self) -> None:\n\n # Modify user\n channel = self.make_request(\n \"PUT\",\n self.url_other_user,\n access_token=self.admin_user_tok,\n content={\"displayname\": \"foobar\"},\n )\n\n self.assertEqual(200, channel.code, msg=channel.json_body)\n self.assertEqual(\"@user:test\", channel.json_body[\"name\"])\n self.assertEqual(\"foobar\", channel.json_body[\"displayname\"])\n\n # Get user\n channel = self.make_request(\n \"GET\",\n self.url_other_user,\n access_token=self.admin_user_tok,\n )\n\n self.assertEqual(200, channel.code, msg=channel.json_body)\n self.assertEqual(\"@user:test\", channel.json_body[\"name\"])\n self.assertEqual(\"foobar\", channel.json_body[\"displayname\"])",
"def test_automatic_default_public_username_role_administrator_instructor(self):\n\n consumer = LTIConsumerFactory(slug=\"consumer\")\n passport = LTIPassportFactory(title=\"consumer1_passport1\", consumer=consumer)\n\n user_count = get_user_model().objects.count()\n\n new_user = self._authenticate(\n {\n \"user_id\": \"3fd0ff83-a62d-4a12-9716-4d48821ae24f\",\n \"lti_message_type\": \"basic-lti-launch-request\",\n \"lti_version\": \"LTI-1p0\",\n \"resource_link_id\": \"aaa\",\n \"context_id\": \"course-v1:fooschool+authbackend+0001\",\n \"lis_person_contact_email_primary\": \"user_without_username@example.com\",\n \"roles\": (\n \"Administrator,Instructor,urn:lti:sysrole:ims/lis/Administrator,\"\n \"urn:lti:instrole:ims/lis/Administrator\"\n ),\n },\n passport,\n )\n\n self.assertEqual(consumer, new_user.lti_consumer)\n self.assertEqual(\"user_without_username@example.com\", new_user.email)\n self.assertEqual(\n \"3fd0ff83-a62d-4a12-9716-4d48821ae24f@consumer\", new_user.username\n )\n self.assertEqual(user_count + 1, get_user_model().objects.count())\n self.assertEqual(\"Educational team\", new_user.public_username)",
"def test_automatic_default_public_username_role_administrator(self):\n\n consumer = LTIConsumerFactory(slug=\"consumer\")\n passport = LTIPassportFactory(title=\"consumer1_passport1\", consumer=consumer)\n\n user_count = get_user_model().objects.count()\n\n new_user = self._authenticate(\n {\n \"user_id\": \"3fd0ff83-a62d-4a12-9716-4d48821ae24f\",\n \"lti_message_type\": \"basic-lti-launch-request\",\n \"lti_version\": \"LTI-1p0\",\n \"resource_link_id\": \"aaa\",\n \"context_id\": \"course-v1:fooschool+authbackend+0001\",\n \"lis_person_contact_email_primary\": \"user_without_username@example.com\",\n \"roles\": \"Administrator\",\n },\n passport,\n )\n\n self.assertEqual(consumer, new_user.lti_consumer)\n self.assertEqual(\"user_without_username@example.com\", new_user.email)\n self.assertEqual(\n \"3fd0ff83-a62d-4a12-9716-4d48821ae24f@consumer\", new_user.username\n )\n self.assertEqual(user_count + 1, get_user_model().objects.count())\n self.assertEqual(\"Administrator\", new_user.public_username)",
"def test_user_first_name(self):\n self.assertEqual(self.user.get_short_name(), 'First')"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test set display name global template as staff saves | def test_set_display_name_global_template_as_staff_saves(self):
mock_request = create_mock_request(user=self.staff_user1)
template_api.set_display_name(
self.fixture.global_template, "new_name", request=mock_request
) | [
"def test_set_display_name_global_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_own_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.set_display_name(\n self.fixture.user1_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_own_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.set_display_name(\n self.fixture.user1_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_own_template_as_user_saves(self):\n mock_request = create_mock_request(user=self.user1)\n template_api.set_display_name(\n self.fixture.user1_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_other_users_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.set_display_name(\n self.fixture.user2_template, \"new_name\", request=mock_request\n )",
"def set_display_name(template, display_name, request):\n # Set display name\n template.display_name = display_name\n # Save\n template.save()",
"def test_set_display_name_global_template_as_user_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def test_upsert_global_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.upsert(self.fixture.global_template, request=mock_request)",
"def test_display_name_template(param):\n assert param",
"def test_edit_implant_template(self):\n pass",
"def test_register_template(self):\n pass",
"def test_obj_creation_displayname(self):\n eq_(self.obj.display_name, u'Test Zone')",
"def test_set_display_name_other_users_template_as_staff_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.user2_template, \"new_name\", request=mock_request\n )",
"def test_upsert_global_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.upsert(self.fixture.global_template, request=mock_request)",
"def test_create_template_subsciption(self):\n pass",
"def test_set_display_name_global_template_as_anonymous_with_access_right_access_raises_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def autoname(self):\n\t\tself.name = self.role_profile",
"def autoname(self):\n\t\timport re\n\t\tfrom webnotes.utils import validate_email_add\n\n\t\tif self.doc.name not in ('Guest','Administrator'):\n\t\t\tself.doc.email = self.doc.email.strip()\n\t\t\tif not validate_email_add(self.doc.email):\n\t\t\t\twebnotes.msgprint(\"%s is not a valid email id\" % self.doc.email)\n\t\t\t\traise Exception\n\t\t\n\t\t\tself.doc.name = self.doc.email",
"def test_update_template_registration(self):\n pass"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test set display name own template as superuser saves | def test_set_display_name_own_template_as_superuser_saves(self):
mock_request = create_mock_request(user=self.superuser1)
template_api.set_display_name(
self.fixture.user1_template, "new_name", request=mock_request
) | [
"def test_set_display_name_global_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_other_users_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.set_display_name(\n self.fixture.user2_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_own_template_as_user_saves(self):\n mock_request = create_mock_request(user=self.user1)\n template_api.set_display_name(\n self.fixture.user1_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_own_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.set_display_name(\n self.fixture.user1_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_global_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def set_display_name(template, display_name, request):\n # Set display name\n template.display_name = display_name\n # Save\n template.save()",
"def test_upsert_own_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.upsert(self.fixture.user1_template, request=mock_request)",
"def test_set_display_name_global_template_as_user_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def test_upsert_global_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.upsert(self.fixture.global_template, request=mock_request)",
"def test_set_display_name_other_users_template_as_staff_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.user2_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_other_users_template_as_user_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.user2_template, \"new_name\", request=mock_request\n )",
"def test_edit_implant_template(self):\n pass",
"def test_display_name_template(param):\n assert param",
"def edit_user_name():\n raise NotImplementedError",
"def test_upsert_own_template_as_user_saves(self):\n mock_request = create_mock_request(user=self.user1)\n template_api.upsert(self.fixture.user1_template, request=mock_request)",
"def test_delete_own_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.delete(self.fixture.user1_template, request=mock_request)",
"def test_set_displayname(self) -> None:\n\n # Modify user\n channel = self.make_request(\n \"PUT\",\n self.url_other_user,\n access_token=self.admin_user_tok,\n content={\"displayname\": \"foobar\"},\n )\n\n self.assertEqual(200, channel.code, msg=channel.json_body)\n self.assertEqual(\"@user:test\", channel.json_body[\"name\"])\n self.assertEqual(\"foobar\", channel.json_body[\"displayname\"])\n\n # Get user\n channel = self.make_request(\n \"GET\",\n self.url_other_user,\n access_token=self.admin_user_tok,\n )\n\n self.assertEqual(200, channel.code, msg=channel.json_body)\n self.assertEqual(\"@user:test\", channel.json_body[\"name\"])\n self.assertEqual(\"foobar\", channel.json_body[\"displayname\"])",
"def test_profile_route_uses_right_templates(self):\n self.add_testuser()\n response = self.client.get(\"/profile/testuser/\")\n self.assertTemplateUsed(response, \"layout.html\")",
"def test_create_template_subsciption(self):\n pass"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test set display name other users template as superuser saves | def test_set_display_name_other_users_template_as_superuser_saves(self):
mock_request = create_mock_request(user=self.superuser1)
template_api.set_display_name(
self.fixture.user2_template, "new_name", request=mock_request
) | [
"def test_set_display_name_own_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.set_display_name(\n self.fixture.user1_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_own_template_as_user_saves(self):\n mock_request = create_mock_request(user=self.user1)\n template_api.set_display_name(\n self.fixture.user1_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_global_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_own_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.set_display_name(\n self.fixture.user1_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_global_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_global_template_as_user_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def set_display_name(template, display_name, request):\n # Set display name\n template.display_name = display_name\n # Save\n template.save()",
"def test_set_display_name_other_users_template_as_user_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.user2_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_other_users_template_as_staff_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.user2_template, \"new_name\", request=mock_request\n )",
"def test_upsert_own_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.upsert(self.fixture.user1_template, request=mock_request)",
"def test_set_displayname(self) -> None:\n\n # Modify user\n channel = self.make_request(\n \"PUT\",\n self.url_other_user,\n access_token=self.admin_user_tok,\n content={\"displayname\": \"foobar\"},\n )\n\n self.assertEqual(200, channel.code, msg=channel.json_body)\n self.assertEqual(\"@user:test\", channel.json_body[\"name\"])\n self.assertEqual(\"foobar\", channel.json_body[\"displayname\"])\n\n # Get user\n channel = self.make_request(\n \"GET\",\n self.url_other_user,\n access_token=self.admin_user_tok,\n )\n\n self.assertEqual(200, channel.code, msg=channel.json_body)\n self.assertEqual(\"@user:test\", channel.json_body[\"name\"])\n self.assertEqual(\"foobar\", channel.json_body[\"displayname\"])",
"def test_user_verbose_name(self):\n self.assertEquals(self.user_profile_inst._meta.get_field('user').verbose_name, 'Пользователь')",
"def edit_user_name():\n raise NotImplementedError",
"def test_replace_user(self):\n pass",
"def test_obj_creation_username(self):\n eq_(self.obj.user_name, \"ignucius\")",
"def test_display_name_template(param):\n assert param",
"def test_user_first_name(self):\n self.assertEqual(self.user.get_short_name(), 'First')",
"def test_get_form_label_name(self):\n self.user.name = 'Full Name'\n self.assertEqual(\n self.user.get_form_label(),\n 'Full Name (testuser)',\n )",
"def test_user_command_createsuperadmin(self):\n management.call_command('createsuperadmin', '--force')\n user = UserModel.objects.get(\n username=\"admin\"\n )\n self.assertEqual(user.email, \"saimer@snapdec.com\")\n self.assertEqual(user.username, \"admin\")"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test set display name global template as superuser saves | def test_set_display_name_global_template_as_superuser_saves(self):
mock_request = create_mock_request(user=self.superuser1)
template_api.set_display_name(
self.fixture.global_template, "new_name", request=mock_request
) | [
"def test_set_display_name_own_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.set_display_name(\n self.fixture.user1_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_global_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_other_users_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.set_display_name(\n self.fixture.user2_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_own_template_as_user_saves(self):\n mock_request = create_mock_request(user=self.user1)\n template_api.set_display_name(\n self.fixture.user1_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_own_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.set_display_name(\n self.fixture.user1_template, \"new_name\", request=mock_request\n )",
"def set_display_name(template, display_name, request):\n # Set display name\n template.display_name = display_name\n # Save\n template.save()",
"def test_set_display_name_global_template_as_user_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def test_upsert_global_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.upsert(self.fixture.global_template, request=mock_request)",
"def test_upsert_own_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.upsert(self.fixture.user1_template, request=mock_request)",
"def test_set_display_name_global_template_as_anonymous_with_access_right_access_raises_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def test_set_display_name_global_template_as_anonymous_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def test_display_name_template(param):\n assert param",
"def autoname(self):\n\t\tself.name = self.role_profile",
"def edit_user_name():\n raise NotImplementedError",
"def test_delete_global_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.delete(self.fixture.global_template, request=mock_request)",
"def test_register_template(self):\n pass",
"def test_admin_override_template():\n app = create_ctfd()\n with app.app_context():\n override_template('admin/team.html', 'ADMIN TEAM OVERRIDE')\n\n client = login_as_user(app, name=\"admin\", password=\"password\")\n r = client.get('/admin/team/1')\n assert r.status_code == 200\n output = r.get_data(as_text=True)\n assert 'ADMIN TEAM OVERRIDE' in output\n destroy_ctfd(app)",
"def test_update_template_profile_for_system_module(self):\n pass",
"def test_set_display_name_other_users_template_as_staff_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.user2_template, \"new_name\", request=mock_request\n )"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test get user template as anonymous raises access control error | def test_get_user_template_as_anonymous_raises_access_control_error(self):
mock_request = create_mock_request(user=self.anonymous_user)
with self.assertRaises(AccessControlError):
template_api.get_by_id(
self.fixture.user1_template.id, request=mock_request
) | [
"def test_get_global_template_as_anonymous_with_access_right_returns_template(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n template = template_api.get_by_id(\n self.fixture.global_template.id, request=mock_request\n )\n self.assertEqual(template, self.fixture.global_template)",
"def test_get_user_template_as_anonymous_with_access_right_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.get_by_id(\n self.fixture.user1_template.id, request=mock_request\n )",
"def test_get_all_as_anonymous_with_access_right_returns_global_templates(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 1)\n self.assertTrue((template.user is None for template in templates))",
"def test_get_all_accessible_by_hash_as_anonymous_with_access_right_does_not_return_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(templates.count() == 0)",
"def test_profile_template(self):\n user = User.objects.first()\n self.client.force_login(user)\n response = self.client.get('/profile/')\n self.assertEqual(response.templates[0].name, 'imager_profile/profile.html')",
"def test_view_as_regular_user(self):\n response = self.client.get(self.url)\n self.assertEqual(403, response.status_code)",
"def test_set_display_name_user_template_as_anonymous_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.user1_template, \"new_name\", request=mock_request\n )",
"def test_get_all_accessible_by_hash_as_anonymous_with_access_right_returns_global(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(templates.count() == 1)\n self.assertTrue((template.user is None for template in templates))",
"def test_set_display_name_user_template_as_anonymous_with_access_right_access_raises_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.user1_template, \"new_name\", request=mock_request\n )",
"def test_search_template_permission(self):\n pass",
"def test_get_all_accessible_by_hash_list_as_anonymous_with_access_right_does_not_return_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(templates.count() == 0)",
"def test_delete_user_template_as_anonymous_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.delete(\n self.fixture.user1_template, request=mock_request\n )",
"def test_get_all_as_user_returns_accessible_templates(self):\n mock_request = create_mock_request(user=self.user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 2)\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_profile_base_template(self):\n user = User.objects.first()\n self.client.force_login(user)\n response = self.client.get('/profile/')\n self.assertEqual(response.templates[1].name, 'generic/base.html')",
"def test_photo_template(self):\n user = User.objects.first()\n self.client.force_login(user)\n response = self.client.get('/images/photos/')\n self.assertEqual(response.templates[0].name, 'imager_images/photo.html')",
"def test_set_display_name_global_template_as_anonymous_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def test_profile_route_uses_right_templates(self):\n self.add_testuser()\n response = self.client.get(\"/profile/testuser/\")\n self.assertTemplateUsed(response, \"layout.html\")",
"def test_set_display_name_global_template_as_anonymous_with_access_right_access_raises_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )",
"def test_get_any_template_as_superuser_returns_template(self):\n mock_request = create_mock_request(user=self.superuser1)\n template = template_api.get_by_id(\n self.fixture.user1_template.id, request=mock_request\n )\n self.assertEqual(template, self.fixture.user1_template)\n template = template_api.get_by_id(\n self.fixture.user2_template.id, request=mock_request\n )\n self.assertEqual(template, self.fixture.user2_template)\n template = template_api.get_by_id(\n self.fixture.global_template.id, request=mock_request\n )\n self.assertEqual(template, self.fixture.global_template)"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test get user template as anonymous with access right raises access control error | def test_get_user_template_as_anonymous_with_access_right_raises_access_control_error(
self,
):
mock_request = create_mock_request(user=self.anonymous_user)
with self.assertRaises(AccessControlError):
template_api.get_by_id(
self.fixture.user1_template.id, request=mock_request
) | [
"def test_get_user_template_as_anonymous_raises_access_control_error(self):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.get_by_id(\n self.fixture.user1_template.id, request=mock_request\n )",
"def test_get_global_template_as_anonymous_with_access_right_returns_template(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n template = template_api.get_by_id(\n self.fixture.global_template.id, request=mock_request\n )\n self.assertEqual(template, self.fixture.global_template)",
"def test_get_all_accessible_by_hash_as_anonymous_with_access_right_does_not_return_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(templates.count() == 0)",
"def test_get_all_as_anonymous_with_access_right_returns_global_templates(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 1)\n self.assertTrue((template.user is None for template in templates))",
"def test_view_as_regular_user(self):\n response = self.client.get(self.url)\n self.assertEqual(403, response.status_code)",
"def test_get_all_accessible_by_hash_list_as_anonymous_with_access_right_does_not_return_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(templates.count() == 0)",
"def test_search_template_permission(self):\n pass",
"def test_get_all_accessible_by_hash_as_anonymous_with_access_right_returns_global(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(templates.count() == 1)\n self.assertTrue((template.user is None for template in templates))",
"def test_profile_template(self):\n user = User.objects.first()\n self.client.force_login(user)\n response = self.client.get('/profile/')\n self.assertEqual(response.templates[0].name, 'imager_profile/profile.html')",
"def test_set_display_name_user_template_as_anonymous_with_access_right_access_raises_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.user1_template, \"new_name\", request=mock_request\n )",
"def test_get_all_as_user_returns_accessible_templates(self):\n mock_request = create_mock_request(user=self.user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 2)\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_delete_user_template_as_anonymous_with_access_right_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.delete(\n self.fixture.user1_template, request=mock_request\n )",
"def test_get_other_users_template_as_staff_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n with self.assertRaises(AccessControlError):\n template_api.get_by_id(\n self.fixture.user2_template.id, request=mock_request\n )",
"def test_get_authorized_user(self):\n pass",
"def test_upsert_user_template_as_anonymous_with_access_right_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.upsert(\n self.fixture.user1_template, request=mock_request\n )",
"def test_set_display_name_user_template_as_anonymous_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.user1_template, \"new_name\", request=mock_request\n )",
"def test_get_other_users_template_raises_access_control_error(self):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.get_by_id(\n self.fixture.user2_template.id, request=mock_request\n )",
"def test_delete_user_template_as_anonymous_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.delete(\n self.fixture.user1_template, request=mock_request\n )",
"def test_set_display_name_global_template_as_anonymous_with_access_right_access_raises_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.global_template, \"new_name\", request=mock_request\n )"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test get global template as anonymous with access right returns template | def test_get_global_template_as_anonymous_with_access_right_returns_template(
self,
):
mock_request = create_mock_request(user=self.anonymous_user)
template = template_api.get_by_id(
self.fixture.global_template.id, request=mock_request
)
self.assertEqual(template, self.fixture.global_template) | [
"def test_get_implant_template(self):\n pass",
"def test_get_implant_template_by_name(self):\n pass",
"def test_template_used(self):\r\n template_name = 'test.jinja'\r\n\r\n def view(request, template_name):\r\n tmpl = Template(\"{{ test }}\")\r\n return HttpResponse(tmpl.stream({\"test\": \"success\"}))\r\n\r\n with self.settings(TEMPLATE_DEBUG=True):\r\n request = RequestFactory().get('/')\r\n response = view(request, template_name=template_name)\r\n self.assertTemplateUsed(response, template_name)\r\n self.assertEqual(response.content, b\"success\")",
"def test_register_template(self):\n pass",
"def test_global_template_as_user_returns_template(self):\n mock_request = create_mock_request(user=self.user1)\n template = template_api.get_by_id(\n self.fixture.global_template.id, request=mock_request\n )\n self.assertEqual(template, self.fixture.global_template)",
"def test_get_implant_templates(self):\n pass",
"def test_retrieve_template_registration(self):\n pass",
"def test_application_templates_get(self):\n pass",
"def test_read_namespaced_template(self):\n pass",
"def test_get_all_as_anonymous_with_access_right_returns_global_templates(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 1)\n self.assertTrue((template.user is None for template in templates))",
"def test_right_template_is_used(self):\n self.assertTemplateUsed(self.response, self.template)",
"def test_master_email_template_get(self):\n pass",
"def test_get_activity_template(self):\n pass",
"def test_email_template_get(self):\n pass",
"def get_template(self, context, **kwargs):\r\n return self.template",
"def test_create_implant_template(self):\n pass",
"def test_templater(self):\n\n # Set a global templater for all items\n self.site.template(r\"(.*)\", lambda item: \"ALL\")\n # Set another templater on the index item\n self.site.template(r\"index.html\", lambda item: \"INDEX\")\n\n # Since an item can only have one templater, the index templater should have been overwritten\n self.assertEqual(\"INDEX\", self.site.items[\"index.html\"].templated)\n self.assertEqual(\"ALL\", self.site.items[\"test/test.html\"].templated)",
"def test_theme_template_loading_by_prefix():\n app = create_ctfd()\n with app.test_request_context():\n tpl1 = render_template_string(\"{% extends 'core/page.html' %}\", content=\"test\")\n tpl2 = render_template(\"page.html\", content=\"test\")\n assert tpl1 == tpl2",
"def _template(self):\n return getattr(self, self.template)()"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test get own template as user returns template | def test_get_own_template_as_user_returns_template(self):
mock_request = create_mock_request(user=self.user1)
template = template_api.get_by_id(
self.fixture.user1_template.id, request=mock_request
)
self.assertEqual(template, self.fixture.user1_template) | [
"def test_get_implant_template(self):\n pass",
"def test_global_template_as_user_returns_template(self):\n mock_request = create_mock_request(user=self.user1)\n template = template_api.get_by_id(\n self.fixture.global_template.id, request=mock_request\n )\n self.assertEqual(template, self.fixture.global_template)",
"def test_get_any_template_as_superuser_returns_template(self):\n mock_request = create_mock_request(user=self.superuser1)\n template = template_api.get_by_id(\n self.fixture.user1_template.id, request=mock_request\n )\n self.assertEqual(template, self.fixture.user1_template)\n template = template_api.get_by_id(\n self.fixture.user2_template.id, request=mock_request\n )\n self.assertEqual(template, self.fixture.user2_template)\n template = template_api.get_by_id(\n self.fixture.global_template.id, request=mock_request\n )\n self.assertEqual(template, self.fixture.global_template)",
"def test_get_implant_template_by_name(self):\n pass",
"def test_api_v1_template_programmer_template_get(self):\n pass",
"def test_retrieve_template_registration(self):\n pass",
"def test_email_template_get(self):\n pass",
"def test_get_activity_template(self):\n pass",
"def test_master_email_template_get(self):\n pass",
"def test_profile_template(self):\n user = User.objects.first()\n self.client.force_login(user)\n response = self.client.get('/profile/')\n self.assertEqual(response.templates[0].name, 'imager_profile/profile.html')",
"def GetTemplate(self, _page_data):\n return self.template",
"def test_photo_template(self):\n user = User.objects.first()\n self.client.force_login(user)\n response = self.client.get('/images/photos/')\n self.assertEqual(response.templates[0].name, 'imager_images/photo.html')",
"def test_right_template_is_used(self):\n self.assertTemplateUsed(\n self.response,\n 'imager_profile/profile_page.html'\n )",
"def test_right_template_is_used(self):\n self.assertTemplateUsed(self.response, self.template)",
"def test_get_implant_templates(self):\n pass",
"def test_right_template_is_used(self):\n self.assertTemplateUsed(\n self.response,\n 'imager_profile/edit_profile_page.html'\n )",
"def test_photo_base_template(self):\n user = User.objects.first()\n self.client.force_login(user)\n response = self.client.get('/images/photos/')\n self.assertEqual(response.templates[1].name, 'generic/base.html')",
"def test_application_templates_get(self):\n pass",
"def test_get_global_template_as_anonymous_with_access_right_returns_template(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n template = template_api.get_by_id(\n self.fixture.global_template.id, request=mock_request\n )\n self.assertEqual(template, self.fixture.global_template)"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test global template as user returns template | def test_global_template_as_user_returns_template(self):
mock_request = create_mock_request(user=self.user1)
template = template_api.get_by_id(
self.fixture.global_template.id, request=mock_request
)
self.assertEqual(template, self.fixture.global_template) | [
"def test_right_template_is_used(self):\n self.assertTemplateUsed(self.response, self.template)",
"def test_get_implant_template(self):\n pass",
"def test_register_template(self):\n pass",
"def test_correct_template(self):\n self.assertCorrectTemplateUsed('common/home.html')",
"def test_correct_main_page_template(self):\n response = self.client.get('/')\n self.assertTemplateUsed(response, 'main.html')",
"def test_template_used(self):\r\n template_name = 'test.jinja'\r\n\r\n def view(request, template_name):\r\n tmpl = Template(\"{{ test }}\")\r\n return HttpResponse(tmpl.stream({\"test\": \"success\"}))\r\n\r\n with self.settings(TEMPLATE_DEBUG=True):\r\n request = RequestFactory().get('/')\r\n response = view(request, template_name=template_name)\r\n self.assertTemplateUsed(response, template_name)\r\n self.assertEqual(response.content, b\"success\")",
"def test_retrieve_template_registration(self):\n pass",
"def test_application_templates_get(self):\n pass",
"def test_get_implant_template_by_name(self):\n pass",
"def test_for_template_usage(self):\n self.assertTemplateUsed(self.response, \"edit_contacts.html\")",
"def test_get_global_template_as_anonymous_with_access_right_returns_template(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n template = template_api.get_by_id(\n self.fixture.global_template.id, request=mock_request\n )\n self.assertEqual(template, self.fixture.global_template)",
"def test_right_template_is_used(self):\n self.assertTemplateUsed(\n self.response,\n 'imager_profile/profile_page.html'\n )",
"def test_template_lookup_result_returned(self, template_override_mock):\n mock_template = mock.Mock()\n mock_template.name = 'site-1/base_site.html'\n request = mock.Mock()\n request.resolver_match.kwargs.get.return_value = 'site-1'\n template_override_mock.return_value = mock_template\n context = context_processors.decide_base_template(request)\n self.assertEqual(\n context['base_template'], 'site-1/base_site.html'\n )",
"def test_master_email_template_get(self):\n pass",
"def test_get_any_template_as_superuser_returns_template(self):\n mock_request = create_mock_request(user=self.superuser1)\n template = template_api.get_by_id(\n self.fixture.user1_template.id, request=mock_request\n )\n self.assertEqual(template, self.fixture.user1_template)\n template = template_api.get_by_id(\n self.fixture.user2_template.id, request=mock_request\n )\n self.assertEqual(template, self.fixture.user2_template)\n template = template_api.get_by_id(\n self.fixture.global_template.id, request=mock_request\n )\n self.assertEqual(template, self.fixture.global_template)",
"def test_template_retrieval(self):\n # Check the directories are correct\n template_dirs = spack.config.get(\"config:template_dirs\")\n template_dirs = [canonicalize_path(x) for x in template_dirs]\n assert len(template_dirs) == 3\n\n env = tengine.make_environment(template_dirs)\n\n # Retrieve a.txt, which resides in the second\n # template directory specified in the mock configuration\n template = env.get_template(\"a.txt\")\n text = template.render({\"word\": \"world\"})\n assert \"Hello world!\" == text\n\n # Retrieve b.txt, which resides in the third\n # template directory specified in the mock configuration\n template = env.get_template(\"b.txt\")\n text = template.render({\"word\": \"world\"})\n assert \"Howdy world!\" == text",
"def test_view_uses_correct_template(self):\n response = self.client.get(reverse('home'))\n self.assertEqual(response.status_code, 200)\n self.assertTemplateUsed(response, 'home.html')",
"def test_template_feedback(self):\r\n pass",
"def test_pages_use_correct_template(self):\n templates_pages_names = {\n INDEX_TEMPLATE: reverse(HOMEPAGE_NAME),\n NEW_POST_TEMPLATE: reverse(NEW_POST_NAME),\n GROUP_TEMPLATE: (\n reverse(GROUP_PAGE_NAME, kwargs={\"slug\": GROUP_SLUG})\n ),\n }\n for template, reverse_name in templates_pages_names.items():\n with self.subTest(reverse_name=reverse_name):\n response = self.authorized_client.get(reverse_name)\n self.assertTemplateUsed(response, template)"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test get other users template raises access control error | def test_get_other_users_template_raises_access_control_error(self):
mock_request = create_mock_request(user=self.user1)
with self.assertRaises(AccessControlError):
template_api.get_by_id(
self.fixture.user2_template.id, request=mock_request
) | [
"def test_get_other_users_template_as_staff_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n with self.assertRaises(AccessControlError):\n template_api.get_by_id(\n self.fixture.user2_template.id, request=mock_request\n )",
"def test_get_all_as_user_returns_accessible_templates(self):\n mock_request = create_mock_request(user=self.user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 2)\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_any_template_as_superuser_returns_template(self):\n mock_request = create_mock_request(user=self.superuser1)\n template = template_api.get_by_id(\n self.fixture.user1_template.id, request=mock_request\n )\n self.assertEqual(template, self.fixture.user1_template)\n template = template_api.get_by_id(\n self.fixture.user2_template.id, request=mock_request\n )\n self.assertEqual(template, self.fixture.user2_template)\n template = template_api.get_by_id(\n self.fixture.global_template.id, request=mock_request\n )\n self.assertEqual(template, self.fixture.global_template)",
"def test_get_user_template_as_anonymous_with_access_right_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.get_by_id(\n self.fixture.user1_template.id, request=mock_request\n )",
"def test_get_own_template_as_user_returns_template(self):\n mock_request = create_mock_request(user=self.user1)\n template = template_api.get_by_id(\n self.fixture.user1_template.id, request=mock_request\n )\n self.assertEqual(template, self.fixture.user1_template)",
"def test_get_user_template_as_anonymous_raises_access_control_error(self):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.get_by_id(\n self.fixture.user1_template.id, request=mock_request\n )",
"def test_view_as_regular_user(self):\n response = self.client.get(self.url)\n self.assertEqual(403, response.status_code)",
"def test_profile_template(self):\n user = User.objects.first()\n self.client.force_login(user)\n response = self.client.get('/profile/')\n self.assertEqual(response.templates[0].name, 'imager_profile/profile.html')",
"def test_get_global_template_as_anonymous_with_access_right_returns_template(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n template = template_api.get_by_id(\n self.fixture.global_template.id, request=mock_request\n )\n self.assertEqual(template, self.fixture.global_template)",
"def test_get_all_accessible_by_hash_as_anonymous_with_access_right_does_not_return_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(templates.count() == 0)",
"def test_get_all_accessible_by_hash_as_superuser_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_as_staff_returns_accessible_templates(self):\n mock_request = create_mock_request(user=self.staff_user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 2)\n self.assertTrue(self.fixture.user2_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_urls_uses_correct_template(self):\n for template, reverse_name in self.templates_url_names.items():\n with self.subTest():\n response = self.authorized_client_john.get(reverse_name)\n self.assertTemplateUsed(response, template)",
"def test_search_template_permission(self):\n pass",
"def test_teams_id_templates_nk_permission_get(self):\n pass",
"def test_get_all_as_anonymous_with_access_right_returns_global_templates(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 1)\n self.assertTrue((template.user is None for template in templates))",
"def test_profile_route_uses_right_templates(self):\n self.add_testuser()\n response = self.client.get(\"/profile/testuser/\")\n self.assertTemplateUsed(response, \"layout.html\")",
"def test_get_all_accessible_by_hash_as_user_returns_user_template(self):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_right_template_is_used(self):\n self.assertTemplateUsed(\n self.response,\n 'imager_profile/edit_profile_page.html'\n )"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test get any template as superuser returns template | def test_get_any_template_as_superuser_returns_template(self):
mock_request = create_mock_request(user=self.superuser1)
template = template_api.get_by_id(
self.fixture.user1_template.id, request=mock_request
)
self.assertEqual(template, self.fixture.user1_template)
template = template_api.get_by_id(
self.fixture.user2_template.id, request=mock_request
)
self.assertEqual(template, self.fixture.user2_template)
template = template_api.get_by_id(
self.fixture.global_template.id, request=mock_request
)
self.assertEqual(template, self.fixture.global_template) | [
"def test_get_own_template_as_user_returns_template(self):\n mock_request = create_mock_request(user=self.user1)\n template = template_api.get_by_id(\n self.fixture.user1_template.id, request=mock_request\n )\n self.assertEqual(template, self.fixture.user1_template)",
"def test_get_all_as_user_returns_accessible_templates(self):\n mock_request = create_mock_request(user=self.user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 2)\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_as_superuser_returns_all_templates(self):\n mock_request = create_mock_request(user=self.superuser)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 3)\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_superuser_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_global_template_as_user_returns_template(self):\n mock_request = create_mock_request(user=self.user1)\n template = template_api.get_by_id(\n self.fixture.global_template.id, request=mock_request\n )\n self.assertEqual(template, self.fixture.global_template)",
"def test_get_implant_template(self):\n pass",
"def test_get_all_as_staff_returns_accessible_templates(self):\n mock_request = create_mock_request(user=self.staff_user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 2)\n self.assertTrue(self.fixture.user2_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_admin_get_template(self):\n\n self.login_usuario(self.admin)\n self.get_check_200(self.URL, pk=600)\n\n self.assertResponseContains('id_parent', html=False)",
"def test_profile_route_uses_right_templates(self):\n self.add_testuser()\n response = self.client.get(\"/profile/testuser/\")\n self.assertTemplateUsed(response, \"layout.html\")",
"def test_profile_template(self):\n user = User.objects.first()\n self.client.force_login(user)\n response = self.client.get('/profile/')\n self.assertEqual(response.templates[0].name, 'imager_profile/profile.html')",
"def test_search_template_permission(self):\n pass",
"def test_photo_base_template(self):\n user = User.objects.first()\n self.client.force_login(user)\n response = self.client.get('/images/photos/')\n self.assertEqual(response.templates[1].name, 'generic/base.html')",
"def test_photo_template(self):\n user = User.objects.first()\n self.client.force_login(user)\n response = self.client.get('/images/photos/')\n self.assertEqual(response.templates[0].name, 'imager_images/photo.html')",
"def test_get_all_accessible_by_hash_list_as_superuser_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_admin_get_template(self):\n\n self.login_usuario(self.admin)\n self.get_check_200(self.URL)\n\n self.assertResponseContains('id_lideres', html=False)",
"def test_retrieve_template_registration(self):\n pass",
"def test_profile_base_template(self):\n user = User.objects.first()\n self.client.force_login(user)\n response = self.client.get('/profile/')\n self.assertEqual(response.templates[1].name, 'generic/base.html')",
"def test_application_templates_get(self):\n pass",
"def test_get_all_accessible_by_hash_as_superuser_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test get other users template as staff raises access control error | def test_get_other_users_template_as_staff_raises_access_control_error(
self,
):
mock_request = create_mock_request(user=self.staff_user1)
with self.assertRaises(AccessControlError):
template_api.get_by_id(
self.fixture.user2_template.id, request=mock_request
) | [
"def test_get_all_as_staff_returns_accessible_templates(self):\n mock_request = create_mock_request(user=self.staff_user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 2)\n self.assertTrue(self.fixture.user2_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_any_template_as_superuser_returns_template(self):\n mock_request = create_mock_request(user=self.superuser1)\n template = template_api.get_by_id(\n self.fixture.user1_template.id, request=mock_request\n )\n self.assertEqual(template, self.fixture.user1_template)\n template = template_api.get_by_id(\n self.fixture.user2_template.id, request=mock_request\n )\n self.assertEqual(template, self.fixture.user2_template)\n template = template_api.get_by_id(\n self.fixture.global_template.id, request=mock_request\n )\n self.assertEqual(template, self.fixture.global_template)",
"def test_get_other_users_template_raises_access_control_error(self):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.get_by_id(\n self.fixture.user2_template.id, request=mock_request\n )",
"def test_get_all_as_user_returns_accessible_templates(self):\n mock_request = create_mock_request(user=self.user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 2)\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_own_template_as_user_returns_template(self):\n mock_request = create_mock_request(user=self.user1)\n template = template_api.get_by_id(\n self.fixture.user1_template.id, request=mock_request\n )\n self.assertEqual(template, self.fixture.user1_template)",
"def test_get_all_accessible_by_hash_as_staff_returns_user_template(self):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_moderator_view_GET_no_staff(self):\n current_user = self.NoStaff\n self.client.force_login(current_user)\n url = reverse('moderator')\n response = self.client.get(url)\n self.assertTemplateNotUsed(response, 'anonticket/moderator.html')",
"def test_get_user_template_as_anonymous_with_access_right_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.get_by_id(\n self.fixture.user1_template.id, request=mock_request\n )",
"def test_search_template_permission(self):\n pass",
"def test_teams_id_templates_nk_permission_get(self):\n pass",
"def test_profile_template(self):\n user = User.objects.first()\n self.client.force_login(user)\n response = self.client.get('/profile/')\n self.assertEqual(response.templates[0].name, 'imager_profile/profile.html')",
"def test_get_all_accessible_by_hash_as_superuser_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_view_as_regular_user(self):\n response = self.client.get(self.url)\n self.assertEqual(403, response.status_code)",
"def test_get_global_template_as_anonymous_with_access_right_returns_template(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n template = template_api.get_by_id(\n self.fixture.global_template.id, request=mock_request\n )\n self.assertEqual(template, self.fixture.global_template)",
"def test_set_display_name_other_users_template_as_staff_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n with self.assertRaises(AccessControlError):\n template_api.set_display_name(\n self.fixture.user2_template, \"new_name\", request=mock_request\n )",
"def test_admin_get_template(self):\n\n self.login_usuario(self.admin)\n self.get_check_200(self.URL, pk=600)\n\n self.assertResponseContains('id_parent', html=False)",
"def test_delete_other_users_template_as_staff_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n with self.assertRaises(AccessControlError):\n template_api.delete(\n self.fixture.user2_template, request=mock_request\n )",
"def test_get_user_template_as_anonymous_raises_access_control_error(self):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.get_by_id(\n self.fixture.user1_template.id, request=mock_request\n )",
"def test_get_all_accessible_by_hash_list_as_staff_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test get all accessible by id list as user returns accessible templates | def test_get_all_accessible_by_id_list_as_user_returns_accessible_templates(
self,
):
mock_request = create_mock_request(user=self.user1)
templates = template_api.get_all_accessible_by_id_list(
self.template_id_list, request=mock_request
)
self.assertTrue(self.fixture.user1_template in list(templates))
self.assertTrue(self.fixture.user2_template not in list(templates))
self.assertTrue(self.fixture.global_template in list(templates)) | [
"def test_get_all_accessible_by_id_list_as_superuser_returns_accessible_templates(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_id_list(\n self.template_id_list, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_id_list_as_staff_returns_accessible_templates(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_id_list(\n self.template_id_list, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_as_user_returns_accessible_templates(self):\n mock_request = create_mock_request(user=self.user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 2)\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_user_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_as_staff_returns_accessible_templates(self):\n mock_request = create_mock_request(user=self.staff_user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 2)\n self.assertTrue(self.fixture.user2_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_anonymous_with_access_right_does_not_return_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(templates.count() == 0)",
"def test_get_all_accessible_by_hash_list_as_superuser_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_staff_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_as_user_returns_user_template(self):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_user_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_anonymous_with_access_right_returns_global(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(templates.count() == 1)\n self.assertTrue((template.user is None for template in templates))",
"def test_get_all_accessible_by_hash_as_superuser_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_as_superuser_returns_all_templates(self):\n mock_request = create_mock_request(user=self.superuser)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 3)\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_staff_returns_user_template(self):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_superuser_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_anonymous_with_access_right_does_not_return_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(templates.count() == 0)",
"def test_get_all_as_anonymous_with_access_right_returns_global_templates(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 1)\n self.assertTrue((template.user is None for template in templates))",
"def test_get_all_accessible_by_hash_list_as_staff_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def get_all_accessible_by_id_list(template_id_list, request):\n return Template.get_all_by_id_list(\n template_id_list, users=get_accessible_owners(request=request)\n )"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test get all accessible by id list as staff returns accessible templates | def test_get_all_accessible_by_id_list_as_staff_returns_accessible_templates(
self,
):
mock_request = create_mock_request(user=self.staff_user1)
templates = template_api.get_all_accessible_by_id_list(
self.template_id_list, request=mock_request
)
self.assertTrue(self.fixture.user1_template in list(templates))
self.assertTrue(self.fixture.user2_template not in list(templates))
self.assertTrue(self.fixture.global_template in list(templates)) | [
"def test_get_all_accessible_by_id_list_as_superuser_returns_accessible_templates(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_id_list(\n self.template_id_list, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_id_list_as_user_returns_accessible_templates(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_id_list(\n self.template_id_list, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_as_staff_returns_accessible_templates(self):\n mock_request = create_mock_request(user=self.staff_user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 2)\n self.assertTrue(self.fixture.user2_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_staff_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_as_user_returns_accessible_templates(self):\n mock_request = create_mock_request(user=self.user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 2)\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_staff_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_staff_returns_user_template(self):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_anonymous_with_access_right_does_not_return_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(templates.count() == 0)",
"def test_get_all_accessible_by_hash_list_as_superuser_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_user_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_anonymous_with_access_right_returns_global(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(templates.count() == 1)\n self.assertTrue((template.user is None for template in templates))",
"def test_get_all_accessible_by_hash_as_staff_returns_global_template(self):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def get_all_accessible_by_id_list(template_id_list, request):\n return Template.get_all_by_id_list(\n template_id_list, users=get_accessible_owners(request=request)\n )",
"def test_get_all_accessible_by_hash_list_as_superuser_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_superuser_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_teams_id_templates_nk_permission_get(self):\n pass",
"def test_get_all_accessible_by_hash_list_as_user_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_teams_id_templates_get(self):\n pass",
"def test_get_all_accessible_by_hash_as_anonymous_with_access_right_does_not_return_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(templates.count() == 0)"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test get all accessible by id list as superuser returns accessible templates | def test_get_all_accessible_by_id_list_as_superuser_returns_accessible_templates(
self,
):
mock_request = create_mock_request(user=self.superuser1)
templates = template_api.get_all_accessible_by_id_list(
self.template_id_list, request=mock_request
)
self.assertTrue(self.fixture.user1_template in list(templates))
self.assertTrue(self.fixture.user2_template in list(templates))
self.assertTrue(self.fixture.global_template in list(templates)) | [
"def test_get_all_accessible_by_id_list_as_user_returns_accessible_templates(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_id_list(\n self.template_id_list, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_id_list_as_staff_returns_accessible_templates(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_id_list(\n self.template_id_list, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_as_user_returns_accessible_templates(self):\n mock_request = create_mock_request(user=self.user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 2)\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_as_staff_returns_accessible_templates(self):\n mock_request = create_mock_request(user=self.staff_user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 2)\n self.assertTrue(self.fixture.user2_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_superuser_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_anonymous_with_access_right_does_not_return_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(templates.count() == 0)",
"def test_get_all_accessible_by_hash_list_as_user_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_staff_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_as_superuser_returns_all_templates(self):\n mock_request = create_mock_request(user=self.superuser)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 3)\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_superuser_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_superuser_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_anonymous_with_access_right_returns_global(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(templates.count() == 1)\n self.assertTrue((template.user is None for template in templates))",
"def test_get_all_accessible_by_hash_as_user_returns_user_template(self):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_as_staff_returns_user_template(self):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_user_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_staff_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_anonymous_with_access_right_does_not_return_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(templates.count() == 0)",
"def get_all_accessible_by_id_list(template_id_list, request):\n return Template.get_all_by_id_list(\n template_id_list, users=get_accessible_owners(request=request)\n )",
"def test_get_all_accessible_by_hash_as_superuser_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test get all accessible by hash as anonymous with access right does not return user template | def test_get_all_accessible_by_hash_as_anonymous_with_access_right_does_not_return_user_template(
self,
):
mock_request = create_mock_request(user=self.anonymous_user)
templates = template_api.get_all_accessible_by_hash(
self.fixture.user1_template.hash, request=mock_request
)
self.assertTrue(templates.count() == 0) | [
"def test_get_all_accessible_by_hash_as_user_returns_user_template(self):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_anonymous_with_access_right_does_not_return_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(templates.count() == 0)",
"def test_get_all_accessible_by_hash_as_superuser_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_user_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_as_anonymous_with_access_right_returns_global(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(templates.count() == 1)\n self.assertTrue((template.user is None for template in templates))",
"def test_get_all_accessible_by_hash_list_as_anonymous_with_access_right_returns_global(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(templates.count() == 1)\n self.assertTrue((template.user is None for template in templates))",
"def test_get_all_accessible_by_hash_list_as_superuser_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_as_staff_returns_user_template(self):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_as_user_returns_global_template(self):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_superuser_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_user_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_staff_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_superuser_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_staff_returns_global_template(self):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_staff_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_anonymous_does_not_return_global(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(templates.count() == 0)",
"def test_get_all_as_user_returns_accessible_templates(self):\n mock_request = create_mock_request(user=self.user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 2)\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_as_anonymous_with_access_right_returns_global_templates(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 1)\n self.assertTrue((template.user is None for template in templates))",
"def test_get_all_accessible_by_id_list_as_user_returns_accessible_templates(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_id_list(\n self.template_id_list, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test get all accessible by hash as anonymous with access right returns global | def test_get_all_accessible_by_hash_as_anonymous_with_access_right_returns_global(
self,
):
mock_request = create_mock_request(user=self.anonymous_user)
templates = template_api.get_all_accessible_by_hash(
self.fixture.global_template.hash, request=mock_request
)
self.assertTrue(templates.count() == 1)
self.assertTrue((template.user is None for template in templates)) | [
"def test_get_all_accessible_by_hash_list_as_anonymous_with_access_right_returns_global(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(templates.count() == 1)\n self.assertTrue((template.user is None for template in templates))",
"def test_get_all_accessible_by_hash_list_as_anonymous_does_not_return_global(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(templates.count() == 0)",
"def test_get_all_accessible_by_hash_as_user_returns_global_template(self):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_superuser_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_user_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_staff_returns_global_template(self):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_anonymous_with_access_right_does_not_return_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(templates.count() == 0)",
"def test_get_all_accessible_by_hash_list_as_superuser_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_staff_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_anonymous_with_access_right_does_not_return_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(templates.count() == 0)",
"def test_get_all_accessible_by_hash_as_user_returns_user_template(self):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_as_superuser_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_keys(self):\n response = self.client.get_keys()\n assert isinstance(response, dict)\n assert 'public' in response\n assert 'private' in response\n assert response['public'] is not None\n assert response['private'] is not None",
"def test_standardvariables_get(self):\n pass",
"def test_get_secret(self):\n pass",
"def test_get_all_as_anonymous_with_access_right_returns_global_templates(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 1)\n self.assertTrue((template.user is None for template in templates))",
"def test_variables_get(self):\n pass",
"def test_get_all_accessible_by_hash_list_as_user_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_token_supply_all_using_get(self):\n pass"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test get all accessible by hash as user returns user template | def test_get_all_accessible_by_hash_as_user_returns_user_template(self):
mock_request = create_mock_request(user=self.user1)
templates = template_api.get_all_accessible_by_hash(
self.fixture.user1_template.hash, request=mock_request
)
self.assertTrue(self.fixture.user1_template in list(templates))
self.assertTrue(self.fixture.user2_template not in list(templates))
self.assertTrue(self.fixture.global_template not in list(templates)) | [
"def test_get_all_accessible_by_hash_list_as_user_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_as_superuser_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_superuser_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_as_staff_returns_user_template(self):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_staff_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_user_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_user_returns_global_template(self):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_superuser_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_anonymous_with_access_right_does_not_return_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(templates.count() == 0)",
"def test_get_all_accessible_by_hash_list_as_superuser_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_anonymous_with_access_right_does_not_return_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(templates.count() == 0)",
"def test_get_all_accessible_by_hash_list_as_anonymous_with_access_right_returns_global(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(templates.count() == 1)\n self.assertTrue((template.user is None for template in templates))",
"def test_get_all_accessible_by_hash_as_staff_returns_global_template(self):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_staff_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_as_user_returns_accessible_templates(self):\n mock_request = create_mock_request(user=self.user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 2)\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_anonymous_with_access_right_returns_global(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(templates.count() == 1)\n self.assertTrue((template.user is None for template in templates))",
"def test_get_all_as_superuser_returns_all_templates(self):\n mock_request = create_mock_request(user=self.superuser)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 3)\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_id_list_as_user_returns_accessible_templates(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_id_list(\n self.template_id_list, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_user(self):\n pass"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test get all accessible by hash as user returns global template | def test_get_all_accessible_by_hash_as_user_returns_global_template(self):
mock_request = create_mock_request(user=self.user1)
templates = template_api.get_all_accessible_by_hash(
self.fixture.global_template.hash, request=mock_request
)
self.assertTrue(self.fixture.user1_template not in list(templates))
self.assertTrue(self.fixture.user2_template not in list(templates))
self.assertTrue(self.fixture.global_template in list(templates)) | [
"def test_get_all_accessible_by_hash_as_superuser_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_user_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_user_returns_user_template(self):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_superuser_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_staff_returns_global_template(self):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_superuser_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_as_anonymous_with_access_right_returns_global(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(templates.count() == 1)\n self.assertTrue((template.user is None for template in templates))",
"def test_get_all_accessible_by_hash_list_as_staff_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_anonymous_with_access_right_returns_global(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(templates.count() == 1)\n self.assertTrue((template.user is None for template in templates))",
"def test_get_all_accessible_by_hash_list_as_user_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_as_staff_returns_user_template(self):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_superuser_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_staff_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_as_anonymous_with_access_right_does_not_return_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(templates.count() == 0)",
"def test_get_all_as_user_returns_accessible_templates(self):\n mock_request = create_mock_request(user=self.user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 2)\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_anonymous_with_access_right_does_not_return_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(templates.count() == 0)",
"def test_get_all_as_anonymous_with_access_right_returns_global_templates(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 1)\n self.assertTrue((template.user is None for template in templates))",
"def test_get_all_accessible_by_hash_list_as_anonymous_does_not_return_global(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(templates.count() == 0)",
"def test_get_all_as_superuser_returns_all_templates(self):\n mock_request = create_mock_request(user=self.superuser)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 3)\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test get all accessible by hash as staff returns user template | def test_get_all_accessible_by_hash_as_staff_returns_user_template(self):
mock_request = create_mock_request(user=self.staff_user1)
templates = template_api.get_all_accessible_by_hash(
self.fixture.user1_template.hash, request=mock_request
)
self.assertTrue(self.fixture.user1_template in list(templates))
self.assertTrue(self.fixture.user2_template not in list(templates))
self.assertTrue(self.fixture.global_template not in list(templates)) | [
"def test_get_all_accessible_by_hash_list_as_staff_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_as_superuser_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_superuser_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_as_user_returns_user_template(self):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_user_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_staff_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_staff_returns_global_template(self):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_superuser_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_anonymous_with_access_right_does_not_return_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(templates.count() == 0)",
"def test_get_all_accessible_by_hash_list_as_superuser_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_user_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_anonymous_with_access_right_does_not_return_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(templates.count() == 0)",
"def test_get_all_accessible_by_hash_as_user_returns_global_template(self):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_anonymous_with_access_right_returns_global(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(templates.count() == 1)\n self.assertTrue((template.user is None for template in templates))",
"def test_get_all_accessible_by_hash_as_anonymous_with_access_right_returns_global(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(templates.count() == 1)\n self.assertTrue((template.user is None for template in templates))",
"def test_get_all_as_staff_returns_accessible_templates(self):\n mock_request = create_mock_request(user=self.staff_user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 2)\n self.assertTrue(self.fixture.user2_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_as_user_returns_accessible_templates(self):\n mock_request = create_mock_request(user=self.user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 2)\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_id_list_as_staff_returns_accessible_templates(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_id_list(\n self.template_id_list, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_id_list_as_superuser_returns_accessible_templates(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_id_list(\n self.template_id_list, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test get all accessible by hash as staff returns global template | def test_get_all_accessible_by_hash_as_staff_returns_global_template(self):
mock_request = create_mock_request(user=self.staff_user1)
templates = template_api.get_all_accessible_by_hash(
self.fixture.global_template.hash, request=mock_request
)
self.assertTrue(self.fixture.user1_template not in list(templates))
self.assertTrue(self.fixture.user2_template not in list(templates))
self.assertTrue(self.fixture.global_template in list(templates)) | [
"def test_get_all_accessible_by_hash_as_superuser_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_staff_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_user_returns_global_template(self):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_superuser_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_user_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_staff_returns_user_template(self):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_as_superuser_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_as_user_returns_user_template(self):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_staff_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_anonymous_with_access_right_returns_global(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(templates.count() == 1)\n self.assertTrue((template.user is None for template in templates))",
"def test_get_all_accessible_by_hash_as_anonymous_with_access_right_returns_global(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(templates.count() == 1)\n self.assertTrue((template.user is None for template in templates))",
"def test_get_all_accessible_by_hash_list_as_superuser_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_user_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_anonymous_with_access_right_does_not_return_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(templates.count() == 0)",
"def test_get_all_accessible_by_hash_as_anonymous_with_access_right_does_not_return_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(templates.count() == 0)",
"def test_get_all_accessible_by_hash_list_as_anonymous_does_not_return_global(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(templates.count() == 0)",
"def test_get_implant_templates(self):\n pass",
"def test_get_implant_template(self):\n pass",
"def test_application_templates_get(self):\n pass"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test get all accessible by hash as superuser returns user template | def test_get_all_accessible_by_hash_as_superuser_returns_user_template(
self,
):
mock_request = create_mock_request(user=self.superuser1)
templates = template_api.get_all_accessible_by_hash(
self.fixture.user1_template.hash, request=mock_request
)
self.assertTrue(self.fixture.user1_template in list(templates))
self.assertTrue(self.fixture.user2_template not in list(templates))
self.assertTrue(self.fixture.global_template not in list(templates)) | [
"def test_get_all_accessible_by_hash_list_as_superuser_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_as_user_returns_user_template(self):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_user_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_as_staff_returns_user_template(self):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_as_superuser_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_staff_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_superuser_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_user_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_user_returns_global_template(self):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_anonymous_with_access_right_does_not_return_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(templates.count() == 0)",
"def test_get_all_accessible_by_hash_as_anonymous_with_access_right_does_not_return_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(templates.count() == 0)",
"def test_get_all_accessible_by_hash_as_staff_returns_global_template(self):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_staff_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_as_user_returns_accessible_templates(self):\n mock_request = create_mock_request(user=self.user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 2)\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_anonymous_with_access_right_returns_global(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(templates.count() == 1)\n self.assertTrue((template.user is None for template in templates))",
"def test_get_all_accessible_by_hash_as_anonymous_with_access_right_returns_global(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(templates.count() == 1)\n self.assertTrue((template.user is None for template in templates))",
"def test_get_all_as_superuser_returns_all_templates(self):\n mock_request = create_mock_request(user=self.superuser)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 3)\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_retrieve_all_users_information_non_superuser(self):\n\n self._create_multiple_users()\n\n su = UserHelpers.create_authenticated_user(superuser=False)\n token = su.auth_token.key\n headers = UserHelpers.create_authentication_header(token)\n\n url = reverse('user_items')\n\n response = self.client.get(url, **headers)\n\n self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)",
"def test_get_all_accessible_by_id_list_as_superuser_returns_accessible_templates(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_id_list(\n self.template_id_list, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test get all accessible by hash as superuser returns global template | def test_get_all_accessible_by_hash_as_superuser_returns_global_template(
self,
):
mock_request = create_mock_request(user=self.superuser1)
templates = template_api.get_all_accessible_by_hash(
self.fixture.global_template.hash, request=mock_request
)
self.assertTrue(self.fixture.user1_template not in list(templates))
self.assertTrue(self.fixture.user2_template not in list(templates))
self.assertTrue(self.fixture.global_template in list(templates)) | [
"def test_get_all_accessible_by_hash_list_as_superuser_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_user_returns_global_template(self):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_superuser_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_user_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_staff_returns_global_template(self):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_user_returns_user_template(self):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_staff_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_superuser_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_as_anonymous_with_access_right_returns_global(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(templates.count() == 1)\n self.assertTrue((template.user is None for template in templates))",
"def test_get_all_accessible_by_hash_as_staff_returns_user_template(self):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_anonymous_with_access_right_returns_global(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(templates.count() == 1)\n self.assertTrue((template.user is None for template in templates))",
"def test_get_all_accessible_by_hash_list_as_user_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_staff_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_as_user_returns_accessible_templates(self):\n mock_request = create_mock_request(user=self.user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 2)\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_anonymous_with_access_right_does_not_return_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(templates.count() == 0)",
"def test_get_all_accessible_by_hash_list_as_anonymous_with_access_right_does_not_return_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(templates.count() == 0)",
"def test_get_all_as_superuser_returns_all_templates(self):\n mock_request = create_mock_request(user=self.superuser)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 3)\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_as_anonymous_with_access_right_returns_global_templates(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 1)\n self.assertTrue((template.user is None for template in templates))",
"def test_get_all_accessible_by_hash_list_as_anonymous_does_not_return_global(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(templates.count() == 0)"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test get all accessible by hash list as anonymous with access right does not return user template | def test_get_all_accessible_by_hash_list_as_anonymous_with_access_right_does_not_return_user_template(
self,
):
mock_request = create_mock_request(user=self.anonymous_user)
templates = template_api.get_all_accessible_by_hash_list(
[self.fixture.user1_template.hash], request=mock_request
)
self.assertTrue(templates.count() == 0) | [
"def test_get_all_accessible_by_hash_list_as_user_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_superuser_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_anonymous_with_access_right_returns_global(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(templates.count() == 1)\n self.assertTrue((template.user is None for template in templates))",
"def test_get_all_accessible_by_hash_as_user_returns_user_template(self):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_staff_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_as_superuser_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_user_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_anonymous_with_access_right_does_not_return_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(templates.count() == 0)",
"def test_get_all_accessible_by_hash_list_as_superuser_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_staff_returns_user_template(self):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_as_anonymous_with_access_right_returns_global(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(templates.count() == 1)\n self.assertTrue((template.user is None for template in templates))",
"def test_get_all_accessible_by_hash_list_as_staff_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_superuser_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_user_returns_global_template(self):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_anonymous_does_not_return_global(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(templates.count() == 0)",
"def test_get_all_accessible_by_hash_as_staff_returns_global_template(self):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_as_user_returns_accessible_templates(self):\n mock_request = create_mock_request(user=self.user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 2)\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_id_list_as_user_returns_accessible_templates(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_id_list(\n self.template_id_list, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_id_list_as_superuser_returns_accessible_templates(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_id_list(\n self.template_id_list, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test get all accessible by hash list as anonymous does not return global | def test_get_all_accessible_by_hash_list_as_anonymous_does_not_return_global(
self,
):
mock_request = create_mock_request(user=self.anonymous_user)
templates = template_api.get_all_accessible_by_hash_list(
[self.fixture.global_template.hash], request=mock_request
)
self.assertTrue(templates.count() == 0) | [
"def test_get_all_accessible_by_hash_list_as_anonymous_with_access_right_returns_global(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(templates.count() == 1)\n self.assertTrue((template.user is None for template in templates))",
"def test_get_all_accessible_by_hash_as_anonymous_with_access_right_returns_global(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(templates.count() == 1)\n self.assertTrue((template.user is None for template in templates))",
"def test_get_all_accessible_by_hash_list_as_user_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_superuser_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_staff_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_user_returns_global_template(self):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_superuser_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_staff_returns_global_template(self):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_anonymous_with_access_right_does_not_return_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(templates.count() == 0)",
"def test_get_all_accessible_by_hash_list_as_user_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_superuser_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_hashlist_ok_glob(self):\n try:\n vbval = (\"verbose\" in testhelp.testargs())\n h = hpss.HSI(verbose=(\"verbose\" in testhelp.testargs()))\n # make sure the hashables all have a checksum stored\n x = h.hashlist(self.plist)\n for path in self.plist:\n if util.rgxin(\"\\(?none\\)? %s\" % path, x):\n h.hashcreate(path)\n\n # run the test payload\n result = h.hashlist(\"%s/hash*\" % self.hdir)\n h.quit()\n self.expected_in(\"hashlist\", result)\n for path in self.plist:\n exp = \"\\(?md5\\)? %s\" % path\n self.expected_in(exp, result)\n exp = \"\\(?none\\)? %s/hashnot\" % self.hdir\n self.expected_in(exp, result)\n except hpss.HSIerror as e:\n if MSG.hpss_unavailable in str(e):\n pytest.skip(str(e))",
"def test_getall0(self):\n pass",
"def test_keys(self):\n self.assertEqual(self.cache.keys(), [\"some\", \"foo\"])",
"def test_get_list(self):\n pass",
"def test_get_token_supply_all_using_get(self):\n pass",
"def test_get_all_accessible_by_hash_list_as_staff_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_as_anonymous_with_access_right_does_not_return_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(templates.count() == 0)",
"def test_get_all_accessible_by_hash_as_superuser_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test get all accessible by hash list as anonymous with access right returns global | def test_get_all_accessible_by_hash_list_as_anonymous_with_access_right_returns_global(
self,
):
mock_request = create_mock_request(user=self.anonymous_user)
templates = template_api.get_all_accessible_by_hash_list(
[self.fixture.global_template.hash], request=mock_request
)
self.assertTrue(templates.count() == 1)
self.assertTrue((template.user is None for template in templates)) | [
"def test_get_all_accessible_by_hash_as_anonymous_with_access_right_returns_global(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(templates.count() == 1)\n self.assertTrue((template.user is None for template in templates))",
"def test_get_all_accessible_by_hash_list_as_anonymous_does_not_return_global(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(templates.count() == 0)",
"def test_get_all_accessible_by_hash_list_as_user_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_staff_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_superuser_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_user_returns_global_template(self):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_anonymous_with_access_right_does_not_return_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(templates.count() == 0)",
"def test_get_all_accessible_by_hash_as_superuser_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_staff_returns_global_template(self):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_user_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_direct_access_list(self):\n result = self.param_dict.get_direct_access_list()\n self.assertTrue(isinstance(result, list))\n self.assertEquals(len(result), 3)\n self.assert_(\"foo\" in result)\n self.assert_(\"baz\" in result)\n self.assert_(\"qut\" in result)",
"def test_get_direct_access_list(self):\n result = self.param_dict.get_direct_access_list()\n self.assertTrue(isinstance(result, list))\n self.assertEquals(len(result), 2)\n self.assert_(\"foo\" in result)\n self.assert_(\"baz\" in result)",
"def test_get_all_accessible_by_hash_as_anonymous_with_access_right_does_not_return_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(templates.count() == 0)",
"def test_get_all_accessible_by_hash_list_as_superuser_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_staff_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_as_user_returns_user_template(self):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_as_superuser_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_token_supply_all_using_get(self):\n pass",
"def test_get_list(self):\n pass"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test get all accessible by hash list as user returns user template | def test_get_all_accessible_by_hash_list_as_user_returns_user_template(
self,
):
mock_request = create_mock_request(user=self.user1)
templates = template_api.get_all_accessible_by_hash_list(
[self.fixture.user1_template.hash], request=mock_request
)
self.assertTrue(self.fixture.user1_template in list(templates))
self.assertTrue(self.fixture.user2_template not in list(templates))
self.assertTrue(self.fixture.global_template not in list(templates)) | [
"def test_get_all_accessible_by_hash_list_as_superuser_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_as_user_returns_user_template(self):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_staff_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_as_superuser_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_user_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_staff_returns_user_template(self):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_superuser_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_anonymous_with_access_right_does_not_return_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(templates.count() == 0)",
"def test_get_all_accessible_by_hash_list_as_staff_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_superuser_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_user_returns_global_template(self):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_anonymous_with_access_right_returns_global(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(templates.count() == 1)\n self.assertTrue((template.user is None for template in templates))",
"def test_get_all_accessible_by_hash_as_anonymous_with_access_right_does_not_return_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(templates.count() == 0)",
"def test_get_all_as_user_returns_accessible_templates(self):\n mock_request = create_mock_request(user=self.user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 2)\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_staff_returns_global_template(self):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_list_user(self):\n pass",
"def test_get_all_accessible_by_hash_as_anonymous_with_access_right_returns_global(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(templates.count() == 1)\n self.assertTrue((template.user is None for template in templates))",
"def test_get_all_accessible_by_id_list_as_user_returns_accessible_templates(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_id_list(\n self.template_id_list, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_anonymous_does_not_return_global(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(templates.count() == 0)"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test get all accessible by hash list as user returns global template | def test_get_all_accessible_by_hash_list_as_user_returns_global_template(
self,
):
mock_request = create_mock_request(user=self.user1)
templates = template_api.get_all_accessible_by_hash_list(
[self.fixture.global_template.hash], request=mock_request
)
self.assertTrue(self.fixture.user1_template not in list(templates))
self.assertTrue(self.fixture.user2_template not in list(templates))
self.assertTrue(self.fixture.global_template in list(templates)) | [
"def test_get_all_accessible_by_hash_list_as_superuser_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_staff_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_superuser_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_user_returns_global_template(self):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_user_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_superuser_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_anonymous_with_access_right_returns_global(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(templates.count() == 1)\n self.assertTrue((template.user is None for template in templates))",
"def test_get_all_accessible_by_hash_as_user_returns_user_template(self):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_as_staff_returns_global_template(self):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_superuser_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_staff_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_as_anonymous_with_access_right_returns_global(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(templates.count() == 1)\n self.assertTrue((template.user is None for template in templates))",
"def test_get_all_accessible_by_hash_as_staff_returns_user_template(self):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_anonymous_with_access_right_does_not_return_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(templates.count() == 0)",
"def test_get_all_accessible_by_hash_list_as_anonymous_does_not_return_global(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(templates.count() == 0)",
"def test_get_all_as_user_returns_accessible_templates(self):\n mock_request = create_mock_request(user=self.user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 2)\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_anonymous_with_access_right_does_not_return_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(templates.count() == 0)",
"def test_get_all_as_anonymous_with_access_right_returns_global_templates(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 1)\n self.assertTrue((template.user is None for template in templates))",
"def test_get_all_as_superuser_returns_all_templates(self):\n mock_request = create_mock_request(user=self.superuser)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 3)\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test get all accessible by hash list as staff returns user template | def test_get_all_accessible_by_hash_list_as_staff_returns_user_template(
self,
):
mock_request = create_mock_request(user=self.staff_user1)
templates = template_api.get_all_accessible_by_hash_list(
[self.fixture.user1_template.hash], request=mock_request
)
self.assertTrue(self.fixture.user1_template in list(templates))
self.assertTrue(self.fixture.user2_template not in list(templates))
self.assertTrue(self.fixture.global_template not in list(templates)) | [
"def test_get_all_accessible_by_hash_list_as_user_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_superuser_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_as_staff_returns_user_template(self):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_as_superuser_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_staff_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_user_returns_user_template(self):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_user_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_superuser_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_anonymous_with_access_right_does_not_return_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(templates.count() == 0)",
"def test_get_all_accessible_by_hash_as_staff_returns_global_template(self):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_anonymous_with_access_right_returns_global(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(templates.count() == 1)\n self.assertTrue((template.user is None for template in templates))",
"def test_get_all_accessible_by_hash_as_superuser_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_anonymous_with_access_right_does_not_return_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(templates.count() == 0)",
"def test_get_all_accessible_by_hash_as_user_returns_global_template(self):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_list_user(self):\n pass",
"def test_get_all_as_staff_returns_accessible_templates(self):\n mock_request = create_mock_request(user=self.staff_user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 2)\n self.assertTrue(self.fixture.user2_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_as_user_returns_accessible_templates(self):\n mock_request = create_mock_request(user=self.user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 2)\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_anonymous_with_access_right_returns_global(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(templates.count() == 1)\n self.assertTrue((template.user is None for template in templates))",
"def test_get_all_accessible_by_id_list_as_staff_returns_accessible_templates(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_id_list(\n self.template_id_list, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test get all accessible by hash list as staff returns global template | def test_get_all_accessible_by_hash_list_as_staff_returns_global_template(
self,
):
mock_request = create_mock_request(user=self.staff_user1)
templates = template_api.get_all_accessible_by_hash_list(
[self.fixture.global_template.hash], request=mock_request
)
self.assertTrue(self.fixture.user1_template not in list(templates))
self.assertTrue(self.fixture.user2_template not in list(templates))
self.assertTrue(self.fixture.global_template in list(templates)) | [
"def test_get_all_accessible_by_hash_list_as_superuser_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_user_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_staff_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_as_staff_returns_global_template(self):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_superuser_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_as_superuser_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_user_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_anonymous_with_access_right_returns_global(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(templates.count() == 1)\n self.assertTrue((template.user is None for template in templates))",
"def test_get_all_accessible_by_hash_as_staff_returns_user_template(self):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_as_user_returns_global_template(self):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_superuser_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_as_user_returns_user_template(self):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_anonymous_with_access_right_does_not_return_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(templates.count() == 0)",
"def test_get_all_accessible_by_hash_as_anonymous_with_access_right_returns_global(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(templates.count() == 1)\n self.assertTrue((template.user is None for template in templates))",
"def test_get_all_accessible_by_hash_list_as_anonymous_does_not_return_global(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(templates.count() == 0)",
"def test_get_all_accessible_by_hash_as_anonymous_with_access_right_does_not_return_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(templates.count() == 0)",
"def test_get_all_as_staff_returns_accessible_templates(self):\n mock_request = create_mock_request(user=self.staff_user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 2)\n self.assertTrue(self.fixture.user2_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_as_user_returns_accessible_templates(self):\n mock_request = create_mock_request(user=self.user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 2)\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def get_all_accessible_by_hash_list(template_hash_list, request):\n return Template.get_all_by_hash_list(\n template_hash_list, users=get_accessible_owners(request=request)\n )"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test get all accessible by hash list as superuser returns user template | def test_get_all_accessible_by_hash_list_as_superuser_returns_user_template(
self,
):
mock_request = create_mock_request(user=self.superuser1)
templates = template_api.get_all_accessible_by_hash_list(
[self.fixture.user1_template.hash], request=mock_request
)
self.assertTrue(self.fixture.user1_template in list(templates))
self.assertTrue(self.fixture.user2_template not in list(templates))
self.assertTrue(self.fixture.global_template not in list(templates)) | [
"def test_get_all_accessible_by_hash_list_as_user_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_as_superuser_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_staff_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_as_user_returns_user_template(self):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_superuser_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_staff_returns_user_template(self):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_user_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_superuser_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_anonymous_with_access_right_does_not_return_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(templates.count() == 0)",
"def test_get_all_accessible_by_hash_list_as_staff_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_anonymous_with_access_right_returns_global(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(templates.count() == 1)\n self.assertTrue((template.user is None for template in templates))",
"def test_get_all_accessible_by_hash_as_user_returns_global_template(self):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_list_user(self):\n pass",
"def test_get_all_accessible_by_hash_as_staff_returns_global_template(self):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_anonymous_with_access_right_does_not_return_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(templates.count() == 0)",
"def test_get_all_as_user_returns_accessible_templates(self):\n mock_request = create_mock_request(user=self.user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 2)\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_list(self):\n self.userbase('create', 'alice', 'localhost', SECRET)\n self.userbase('create', 'bob', 'localhost', SECRET)\n output = self.userbase('list')\n self.assertEqual(output, ['alice@localhost', 'bob@localhost'])",
"def test_get_all_as_superuser_returns_all_templates(self):\n mock_request = create_mock_request(user=self.superuser)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 3)\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_retrieve_all_users_information_non_superuser(self):\n\n self._create_multiple_users()\n\n su = UserHelpers.create_authenticated_user(superuser=False)\n token = su.auth_token.key\n headers = UserHelpers.create_authentication_header(token)\n\n url = reverse('user_items')\n\n response = self.client.get(url, **headers)\n\n self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test get all accessible by hash list as superuser returns global template | def test_get_all_accessible_by_hash_list_as_superuser_returns_global_template(
self,
):
mock_request = create_mock_request(user=self.superuser1)
templates = template_api.get_all_accessible_by_hash_list(
[self.fixture.global_template.hash], request=mock_request
)
self.assertTrue(self.fixture.user1_template not in list(templates))
self.assertTrue(self.fixture.user2_template not in list(templates))
self.assertTrue(self.fixture.global_template in list(templates)) | [
"def test_get_all_accessible_by_hash_list_as_user_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_superuser_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_superuser_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_staff_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_superuser_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_user_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_as_user_returns_global_template(self):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_staff_returns_global_template(self):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_anonymous_with_access_right_returns_global(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(templates.count() == 1)\n self.assertTrue((template.user is None for template in templates))",
"def test_get_all_accessible_by_hash_list_as_staff_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_as_user_returns_user_template(self):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_as_staff_returns_user_template(self):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_as_anonymous_with_access_right_returns_global(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(templates.count() == 1)\n self.assertTrue((template.user is None for template in templates))",
"def test_get_all_accessible_by_hash_list_as_anonymous_with_access_right_does_not_return_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(templates.count() == 0)",
"def test_get_all_accessible_by_hash_list_as_anonymous_does_not_return_global(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(templates.count() == 0)",
"def test_get_all_as_user_returns_accessible_templates(self):\n mock_request = create_mock_request(user=self.user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 2)\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_anonymous_with_access_right_does_not_return_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(templates.count() == 0)",
"def test_get_all_as_superuser_returns_all_templates(self):\n mock_request = create_mock_request(user=self.superuser)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 3)\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_id_list_as_superuser_returns_accessible_templates(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_id_list(\n self.template_id_list, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test get all as anonymous with access right returns global templates | def test_get_all_as_anonymous_with_access_right_returns_global_templates(
self,
):
mock_request = create_mock_request(user=self.anonymous_user)
templates = template_api.get_all(request=mock_request)
self.assertEqual(templates.count(), 1)
self.assertTrue((template.user is None for template in templates)) | [
"def test_get_implant_templates(self):\n pass",
"def test_application_templates_get(self):\n pass",
"def test_get_implant_template(self):\n pass",
"def test_list_template_for_all_namespaces(self):\n pass",
"def test_get_all_as_user_returns_accessible_templates(self):\n mock_request = create_mock_request(user=self.user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 2)\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_master_email_templates_get(self):\n pass",
"def test_email_templates_get(self):\n pass",
"def test_retrieve_template_registration(self):\n pass",
"def test_get_templates_in_virtualization_realm(self):\n pass",
"def test_get_implant_template_by_name(self):\n pass",
"def test_get_all_as_superuser_returns_all_templates(self):\n mock_request = create_mock_request(user=self.superuser)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 3)\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_activity_templates(self):\n pass",
"def test_get_global_template_as_anonymous_with_access_right_returns_template(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n template = template_api.get_by_id(\n self.fixture.global_template.id, request=mock_request\n )\n self.assertEqual(template, self.fixture.global_template)",
"def test_create_template_for_all_namespaces(self):\n pass",
"def test_get_all_as_staff_returns_accessible_templates(self):\n mock_request = create_mock_request(user=self.staff_user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 2)\n self.assertTrue(self.fixture.user2_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_application_templates_list(self):\n pass",
"def test_templater(self):\n\n # Set a global templater for all items\n self.site.template(r\"(.*)\", lambda item: \"ALL\")\n # Set another templater on the index item\n self.site.template(r\"index.html\", lambda item: \"INDEX\")\n\n # Since an item can only have one templater, the index templater should have been overwritten\n self.assertEqual(\"INDEX\", self.site.items[\"index.html\"].templated)\n self.assertEqual(\"ALL\", self.site.items[\"test/test.html\"].templated)",
"def test_search_mappings_with_template_get(self):\n pass",
"def test_get_all_accessible_by_hash_as_anonymous_with_access_right_returns_global(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(templates.count() == 1)\n self.assertTrue((template.user is None for template in templates))"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test get all as user returns accessible templates | def test_get_all_as_user_returns_accessible_templates(self):
mock_request = create_mock_request(user=self.user)
templates = template_api.get_all(request=mock_request)
self.assertEqual(templates.count(), 2)
self.assertTrue(self.fixture.user1_template in list(templates))
self.assertTrue(self.fixture.global_template in list(templates)) | [
"def test_get_all_as_superuser_returns_all_templates(self):\n mock_request = create_mock_request(user=self.superuser)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 3)\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_as_staff_returns_accessible_templates(self):\n mock_request = create_mock_request(user=self.staff_user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 2)\n self.assertTrue(self.fixture.user2_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_as_anonymous_with_access_right_returns_global_templates(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 1)\n self.assertTrue((template.user is None for template in templates))",
"def test_application_templates_get(self):\n pass",
"def test_get_implant_templates(self):\n pass",
"def test_get_all_accessible_by_id_list_as_superuser_returns_accessible_templates(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_id_list(\n self.template_id_list, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_user_returns_user_template(self):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_id_list_as_user_returns_accessible_templates(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_id_list(\n self.template_id_list, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_any_template_as_superuser_returns_template(self):\n mock_request = create_mock_request(user=self.superuser1)\n template = template_api.get_by_id(\n self.fixture.user1_template.id, request=mock_request\n )\n self.assertEqual(template, self.fixture.user1_template)\n template = template_api.get_by_id(\n self.fixture.user2_template.id, request=mock_request\n )\n self.assertEqual(template, self.fixture.user2_template)\n template = template_api.get_by_id(\n self.fixture.global_template.id, request=mock_request\n )\n self.assertEqual(template, self.fixture.global_template)",
"def test_get_all_accessible_by_hash_as_superuser_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_user_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_superuser_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_as_staff_returns_user_template(self):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_user_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_superuser_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_list_as_staff_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_as_superuser_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_user_returns_global_template(self):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_templates_in_virtualization_realm(self):\n pass"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test get all as staff returns accessible templates | def test_get_all_as_staff_returns_accessible_templates(self):
mock_request = create_mock_request(user=self.staff_user)
templates = template_api.get_all(request=mock_request)
self.assertEqual(templates.count(), 2)
self.assertTrue(self.fixture.user2_template in list(templates))
self.assertTrue(self.fixture.global_template in list(templates)) | [
"def test_get_all_as_user_returns_accessible_templates(self):\n mock_request = create_mock_request(user=self.user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 2)\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_id_list_as_staff_returns_accessible_templates(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_id_list(\n self.template_id_list, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_implant_templates(self):\n pass",
"def test_get_all_as_superuser_returns_all_templates(self):\n mock_request = create_mock_request(user=self.superuser)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 3)\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_staff_returns_user_template(self):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_staff_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_id_list_as_superuser_returns_accessible_templates(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_id_list(\n self.template_id_list, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_application_templates_get(self):\n pass",
"def test_get_all_accessible_by_hash_list_as_staff_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_hash_as_staff_returns_global_template(self):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_id_list_as_user_returns_accessible_templates(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_id_list(\n self.template_id_list, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_templates_in_virtualization_realm(self):\n pass",
"def test_get_all_as_anonymous_with_access_right_returns_global_templates(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 1)\n self.assertTrue((template.user is None for template in templates))",
"def test_get_any_template_as_superuser_returns_template(self):\n mock_request = create_mock_request(user=self.superuser1)\n template = template_api.get_by_id(\n self.fixture.user1_template.id, request=mock_request\n )\n self.assertEqual(template, self.fixture.user1_template)\n template = template_api.get_by_id(\n self.fixture.user2_template.id, request=mock_request\n )\n self.assertEqual(template, self.fixture.user2_template)\n template = template_api.get_by_id(\n self.fixture.global_template.id, request=mock_request\n )\n self.assertEqual(template, self.fixture.global_template)",
"def test_email_templates_get(self):\n pass",
"def test_master_email_templates_get(self):\n pass",
"def test_get_all_accessible_by_hash_list_as_superuser_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_activity_templates(self):\n pass",
"def test_templates(self):\n response = self.client.get(reverse('manage:templates'))\n eq_(response.status_code, 200)"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test get all as superuser returns all templates | def test_get_all_as_superuser_returns_all_templates(self):
mock_request = create_mock_request(user=self.superuser)
templates = template_api.get_all(request=mock_request)
self.assertEqual(templates.count(), 3)
self.assertTrue(self.fixture.user1_template in list(templates))
self.assertTrue(self.fixture.user2_template in list(templates))
self.assertTrue(self.fixture.global_template in list(templates)) | [
"def test_get_all_as_user_returns_accessible_templates(self):\n mock_request = create_mock_request(user=self.user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 2)\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_as_staff_returns_accessible_templates(self):\n mock_request = create_mock_request(user=self.staff_user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 2)\n self.assertTrue(self.fixture.user2_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_any_template_as_superuser_returns_template(self):\n mock_request = create_mock_request(user=self.superuser1)\n template = template_api.get_by_id(\n self.fixture.user1_template.id, request=mock_request\n )\n self.assertEqual(template, self.fixture.user1_template)\n template = template_api.get_by_id(\n self.fixture.user2_template.id, request=mock_request\n )\n self.assertEqual(template, self.fixture.user2_template)\n template = template_api.get_by_id(\n self.fixture.global_template.id, request=mock_request\n )\n self.assertEqual(template, self.fixture.global_template)",
"def test_get_all_accessible_by_id_list_as_superuser_returns_accessible_templates(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_id_list(\n self.template_id_list, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_as_anonymous_with_access_right_returns_global_templates(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 1)\n self.assertTrue((template.user is None for template in templates))",
"def test_application_templates_get(self):\n pass",
"def test_get_all_accessible_by_hash_list_as_superuser_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_as_superuser_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.user1_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template not in list(templates))",
"def test_get_all_accessible_by_hash_list_as_superuser_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def get_templates(self):\n return self.http_call(\"get\", url=f\"{self.base_url}/templates\").json()",
"def test_get_implant_templates(self):\n pass",
"def get_all_templates(cls):\n raise NotImplementedError()",
"def test_get_all_accessible_by_hash_as_superuser_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template not in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_all_accessible_by_id_list_as_user_returns_accessible_templates(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_id_list(\n self.template_id_list, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))",
"def test_get_templates_in_virtualization_realm(self):\n pass",
"def get_templates(self):\n return self.templates.all()",
"def list_templates(request):\n templates = models.Template.all().order('name')\n return utility.respond(request, 'admin/list_templates', {'templates': templates})",
"def test_admin_get_template(self):\n\n self.login_usuario(self.admin)\n self.get_check_200(self.URL, pk=600)\n\n self.assertResponseContains('id_parent', html=False)",
"def test_get_all_accessible_by_id_list_as_staff_returns_accessible_templates(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n templates = template_api.get_all_accessible_by_id_list(\n self.template_id_list, request=mock_request\n )\n self.assertTrue(self.fixture.user1_template in list(templates))\n self.assertTrue(self.fixture.user2_template not in list(templates))\n self.assertTrue(self.fixture.global_template in list(templates))"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test delete user template as anonymous raises access control error | def test_delete_user_template_as_anonymous_raises_access_control_error(
self,
):
mock_request = create_mock_request(user=self.anonymous_user)
with self.assertRaises(AccessControlError):
template_api.delete(
self.fixture.user1_template, request=mock_request
) | [
"def test_delete_user_template_as_anonymous_with_access_right_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.delete(\n self.fixture.user1_template, request=mock_request\n )",
"def test_delete_authorized_user(self):\n pass",
"def test_delete_global_template_as_user_raises_access_control_error(self):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.delete(\n self.fixture.global_template, request=mock_request\n )",
"def test_delete_global_template_as_anonymous_with_access_right_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.delete(\n self.fixture.global_template, request=mock_request\n )",
"def test_delete_unverified_user(self):\n pass",
"def test_delete_other_users_template_as_user_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.delete(\n self.fixture.user2_template, request=mock_request\n )",
"def test_delete_implant_template(self):\n pass",
"def test_delete_user(self):\n pass",
"def test_delete_other_users_template_as_staff_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n with self.assertRaises(AccessControlError):\n template_api.delete(\n self.fixture.user2_template, request=mock_request\n )",
"def test_teams_id_templates_nk_permission_delete(self):\n pass",
"def test_delete_own_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.delete(self.fixture.user1_template, request=mock_request)",
"def test_delete_non_owner(self):\n another_user = CustomUser.objects.create(id=134, email='another_user2@mail.com', is_active=True)\n another_user.set_password('qwerty12345')\n another_user.save()\n\n self.client.login(email='another_user2@mail.com', password='qwerty12345')\n\n url = reverse('notification',\n kwargs={'way_id': self.notification.way_id, 'notification_id': 87876})\n\n response = self.client.delete(url)\n\n self.assertEqual(response.status_code, 403)",
"def test_user_access_to_delete_other_not_permitted(self, user, testapp):\n with pytest.raises(AppError):\n testapp.get(url_for('user.delete', name=user.username))",
"def test_authenticated_cannot_delete_a_tag(self):\n self.client.force_login(user=self.user)\n response = self.client.post(\n reverse(self.list_view),\n {'name': 'delete'}\n )\n self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)",
"def test_delete_access_resource(self):\n pass",
"def test_delete_activity_template(self):\n pass",
"def test_delete_own_template_as_user_saves(self):\n mock_request = create_mock_request(user=self.user1)\n template_api.delete(self.fixture.user1_template, request=mock_request)",
"def test_plant_delete_normal_users(self):\n url = reverse('plant-detail', kwargs={\"pk\": self.plant.pk})\n self.client.force_authenticate(user=self.user)\n response = self.client.delete(url, format='json')\n\n self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)",
"def test_delete_global_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.delete(self.fixture.global_template, request=mock_request)"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test delete user template as anonymous with access right raises access control error | def test_delete_user_template_as_anonymous_with_access_right_raises_access_control_error(
self,
):
mock_request = create_mock_request(user=self.anonymous_user)
with self.assertRaises(AccessControlError):
template_api.delete(
self.fixture.user1_template, request=mock_request
) | [
"def test_delete_user_template_as_anonymous_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.delete(\n self.fixture.user1_template, request=mock_request\n )",
"def test_delete_global_template_as_user_raises_access_control_error(self):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.delete(\n self.fixture.global_template, request=mock_request\n )",
"def test_delete_authorized_user(self):\n pass",
"def test_delete_global_template_as_anonymous_with_access_right_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.delete(\n self.fixture.global_template, request=mock_request\n )",
"def test_delete_other_users_template_as_user_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.delete(\n self.fixture.user2_template, request=mock_request\n )",
"def test_delete_other_users_template_as_staff_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n with self.assertRaises(AccessControlError):\n template_api.delete(\n self.fixture.user2_template, request=mock_request\n )",
"def test_teams_id_templates_nk_permission_delete(self):\n pass",
"def test_delete_implant_template(self):\n pass",
"def test_delete_user(self):\n pass",
"def test_delete_own_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.delete(self.fixture.user1_template, request=mock_request)",
"def test_delete_unverified_user(self):\n pass",
"def test_delete_access_resource(self):\n pass",
"def test_delete_non_owner(self):\n another_user = CustomUser.objects.create(id=134, email='another_user2@mail.com', is_active=True)\n another_user.set_password('qwerty12345')\n another_user.save()\n\n self.client.login(email='another_user2@mail.com', password='qwerty12345')\n\n url = reverse('notification',\n kwargs={'way_id': self.notification.way_id, 'notification_id': 87876})\n\n response = self.client.delete(url)\n\n self.assertEqual(response.status_code, 403)",
"def test_user_access_to_delete_other_not_permitted(self, user, testapp):\n with pytest.raises(AppError):\n testapp.get(url_for('user.delete', name=user.username))",
"def test_delete_own_template_as_user_saves(self):\n mock_request = create_mock_request(user=self.user1)\n template_api.delete(self.fixture.user1_template, request=mock_request)",
"def allowed_topologytemplate_access_delete(user, template):\n try:\n up = user.get_profile()\n except AttributeError:\n return False\n\n return template.owner == user or user.has_perm(\"vnswww.topologytemplete_delete_any\") or (user.has_perm(\"vnswww.topologytemplete_delete_org\") and template.org == up.org)",
"def test_delete_global_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.delete(self.fixture.global_template, request=mock_request)",
"def test_update_template_permission(self):\n pass",
"def test_delete_activity_template(self):\n pass"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test delete global template as anonymous with access right raises access control error | def test_delete_global_template_as_anonymous_with_access_right_raises_access_control_error(
self,
):
mock_request = create_mock_request(user=self.anonymous_user)
with self.assertRaises(AccessControlError):
template_api.delete(
self.fixture.global_template, request=mock_request
) | [
"def test_delete_implant_template(self):\n pass",
"def test_delete_namespaced_template(self):\n pass",
"def test_delete_global_template_as_user_raises_access_control_error(self):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.delete(\n self.fixture.global_template, request=mock_request\n )",
"def test_unshare_template_registration(self):\n pass",
"def test_unregister_template(self):\n pass",
"def test_teams_id_templates_nk_permission_delete(self):\n pass",
"def test_delete_activity_template(self):\n pass",
"def test_delete_user_template_as_anonymous_with_access_right_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.delete(\n self.fixture.user1_template, request=mock_request\n )",
"def test_delete_global_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.delete(self.fixture.global_template, request=mock_request)",
"def test_delete_user_template_as_anonymous_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.delete(\n self.fixture.user1_template, request=mock_request\n )",
"def test_delete_access_resource(self):\n pass",
"def test_delete_template_subscription(self):\n pass",
"def test_email_template_delete(self):\n pass",
"def test_delete_device_template(self):\n pass",
"def test_update_template_permission(self):\n pass",
"def test_delete_subscription_template(self):\n pass",
"def test_delete_global_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.delete(self.fixture.global_template, request=mock_request)",
"def test_delete_collection_namespaced_template(self):\n pass",
"def test_delete_other_users_template_as_user_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.delete(\n self.fixture.user2_template, request=mock_request\n )"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test delete own template as user saves | def test_delete_own_template_as_user_saves(self):
mock_request = create_mock_request(user=self.user1)
template_api.delete(self.fixture.user1_template, request=mock_request) | [
"def test_delete_own_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.delete(self.fixture.user1_template, request=mock_request)",
"def test_delete_implant_template(self):\n pass",
"def test_delete_own_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.delete(self.fixture.user1_template, request=mock_request)",
"def test_email_template_delete(self):\n pass",
"def test_delete_global_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.delete(self.fixture.global_template, request=mock_request)",
"def test_delete_other_users_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.delete(self.fixture.user2_template, request=mock_request)",
"def test_delete_activity_template(self):\n pass",
"def test_delete_template_subscription(self):\n pass",
"def test_delete_namespaced_template(self):\n pass",
"def test_delete_global_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.delete(self.fixture.global_template, request=mock_request)",
"def test_xml_template_delete(self):\n XmlTemplate.delete_by_id(1)\n self.assertEqual(XmlTemplate.objects.count(), 1)\n self.assertFalse(XmlTemplate.objects.filter(pk=1).exists())",
"def test_delete_subscription_template(self):\n pass",
"def test_delete_device_template(self):\n pass",
"def test_delete_user(self):\n pass",
"def test_teams_id_templates_delete(self):\n pass",
"def test_delete_authorized_user(self):\n pass",
"def test_teams_id_templates_nk_permission_delete(self):\n pass",
"def test_teams_id_templates_nk_template_members_delete(self):\n pass",
"def test_commentary_view_delete(self):\n \n test_response = self.client.get('/papers/commentary/1/delete')\n self.assertEqual(test_response.status_code, 200)\n self.assertTrue('object' in test_response.context) \n self.assertTemplateUsed(test_response, 'base.html')\n self.assertTemplateUsed(test_response, 'confirm_delete.html')"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test delete other users template as user raises access control error | def test_delete_other_users_template_as_user_raises_access_control_error(
self,
):
mock_request = create_mock_request(user=self.user1)
with self.assertRaises(AccessControlError):
template_api.delete(
self.fixture.user2_template, request=mock_request
) | [
"def test_delete_other_users_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.delete(self.fixture.user2_template, request=mock_request)",
"def test_delete_own_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.delete(self.fixture.user1_template, request=mock_request)",
"def test_delete_own_template_as_user_saves(self):\n mock_request = create_mock_request(user=self.user1)\n template_api.delete(self.fixture.user1_template, request=mock_request)",
"def test_delete_other_users_template_as_staff_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.staff_user1)\n with self.assertRaises(AccessControlError):\n template_api.delete(\n self.fixture.user2_template, request=mock_request\n )",
"def test_delete_global_template_as_user_raises_access_control_error(self):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.delete(\n self.fixture.global_template, request=mock_request\n )",
"def test_delete_authorized_user(self):\n pass",
"def test_delete_implant_template(self):\n pass",
"def test_teams_id_templates_nk_permission_delete(self):\n pass",
"def test_delete_user(self):\n pass",
"def test_delete_user_template_as_anonymous_with_access_right_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.delete(\n self.fixture.user1_template, request=mock_request\n )",
"def test_delete_global_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.delete(self.fixture.global_template, request=mock_request)",
"def test_delete_user_template_as_anonymous_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.delete(\n self.fixture.user1_template, request=mock_request\n )",
"def test_delete_own_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.delete(self.fixture.user1_template, request=mock_request)",
"def test_delete_activity_template(self):\n pass",
"def test_delete_non_owner(self):\n another_user = CustomUser.objects.create(id=134, email='another_user2@mail.com', is_active=True)\n another_user.set_password('qwerty12345')\n another_user.save()\n\n self.client.login(email='another_user2@mail.com', password='qwerty12345')\n\n url = reverse('notification',\n kwargs={'way_id': self.notification.way_id, 'notification_id': 87876})\n\n response = self.client.delete(url)\n\n self.assertEqual(response.status_code, 403)",
"def test_email_template_delete(self):\n pass",
"def test_delete_unverified_user(self):\n pass",
"def test_user_access_to_delete_other_not_permitted(self, user, testapp):\n with pytest.raises(AppError):\n testapp.get(url_for('user.delete', name=user.username))",
"def test_teams_id_templates_nk_template_members_delete(self):\n pass"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test delete global template as user raises access control error | def test_delete_global_template_as_user_raises_access_control_error(self):
mock_request = create_mock_request(user=self.user1)
with self.assertRaises(AccessControlError):
template_api.delete(
self.fixture.global_template, request=mock_request
) | [
"def test_delete_implant_template(self):\n pass",
"def test_delete_global_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.delete(self.fixture.global_template, request=mock_request)",
"def test_delete_namespaced_template(self):\n pass",
"def test_delete_global_template_as_anonymous_with_access_right_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.delete(\n self.fixture.global_template, request=mock_request\n )",
"def test_teams_id_templates_nk_permission_delete(self):\n pass",
"def test_unshare_template_registration(self):\n pass",
"def test_delete_activity_template(self):\n pass",
"def test_delete_global_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.delete(self.fixture.global_template, request=mock_request)",
"def test_delete_own_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.delete(self.fixture.user1_template, request=mock_request)",
"def test_email_template_delete(self):\n pass",
"def test_delete_device_template(self):\n pass",
"def test_unregister_template(self):\n pass",
"def test_delete_template_subscription(self):\n pass",
"def test_delete_own_template_as_user_saves(self):\n mock_request = create_mock_request(user=self.user1)\n template_api.delete(self.fixture.user1_template, request=mock_request)",
"def test_delete_user_template_as_anonymous_with_access_right_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.delete(\n self.fixture.user1_template, request=mock_request\n )",
"def test_delete_other_users_template_as_user_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.delete(\n self.fixture.user2_template, request=mock_request\n )",
"def test_delete_user_template_as_anonymous_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.delete(\n self.fixture.user1_template, request=mock_request\n )",
"def test_update_template_permission(self):\n pass",
"def test_delete_subscription_template(self):\n pass"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test delete own template as staff saves | def test_delete_own_template_as_staff_saves(self):
mock_request = create_mock_request(user=self.staff_user1)
template_api.delete(self.fixture.user1_template, request=mock_request) | [
"def test_delete_implant_template(self):\n pass",
"def test_delete_own_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.delete(self.fixture.user1_template, request=mock_request)",
"def test_delete_own_template_as_user_saves(self):\n mock_request = create_mock_request(user=self.user1)\n template_api.delete(self.fixture.user1_template, request=mock_request)",
"def test_delete_global_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.delete(self.fixture.global_template, request=mock_request)",
"def test_email_template_delete(self):\n pass",
"def test_delete_activity_template(self):\n pass",
"def test_delete_namespaced_template(self):\n pass",
"def test_delete_global_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.delete(self.fixture.global_template, request=mock_request)",
"def test_delete_template_subscription(self):\n pass",
"def test_team_template_folders_id_delete(self):\n pass",
"def test_xml_template_delete(self):\n XmlTemplate.delete_by_id(1)\n self.assertEqual(XmlTemplate.objects.count(), 1)\n self.assertFalse(XmlTemplate.objects.filter(pk=1).exists())",
"def test_delete_other_users_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.delete(self.fixture.user2_template, request=mock_request)",
"def test_teams_id_templates_delete(self):\n pass",
"def test_team_template_folders_id_templates_fk_delete(self):\n pass",
"def test_delete_subscription_template(self):\n pass",
"def test_teams_id_template_folders_delete(self):\n pass",
"def test_teams_id_templates_nk_permission_delete(self):\n pass",
"def test_delete_device_template(self):\n pass",
"def test_template_delete(self):\n # This is managed by django's default ForeignKey.on_delete\n # so doesn't need implementation, but let's test it anyways:\n domain = Domain(\n name='example.com',\n template=self.domain_template1,\n reverse_template=self.domain_template2,\n )\n domain.save()\n assert_does_exist(\n Record,\n domain=domain,\n content='192.168.1.3'\n )\n assert_does_exist(\n Record,\n name='3.1.168.192.in-addr.arpa',\n type='PTR'\n )\n self.t1_a_record.delete()\n self.assertEqual(domain.record_set.count(), 2)\n assert_not_exists(\n Record,\n domain=domain,\n content='192.168.1.3'\n )\n assert_not_exists(\n Record,\n name='3.1.168.192.in-addr.arpa',\n type='PTR'\n )"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test delete other users template as staff raises access control error | def test_delete_other_users_template_as_staff_raises_access_control_error(
self,
):
mock_request = create_mock_request(user=self.staff_user1)
with self.assertRaises(AccessControlError):
template_api.delete(
self.fixture.user2_template, request=mock_request
) | [
"def test_delete_own_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.delete(self.fixture.user1_template, request=mock_request)",
"def test_delete_other_users_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.delete(self.fixture.user2_template, request=mock_request)",
"def test_delete_own_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.delete(self.fixture.user1_template, request=mock_request)",
"def test_delete_other_users_template_as_user_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.delete(\n self.fixture.user2_template, request=mock_request\n )",
"def test_teams_id_templates_nk_permission_delete(self):\n pass",
"def test_delete_global_template_as_user_raises_access_control_error(self):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.delete(\n self.fixture.global_template, request=mock_request\n )",
"def test_delete_own_template_as_user_saves(self):\n mock_request = create_mock_request(user=self.user1)\n template_api.delete(self.fixture.user1_template, request=mock_request)",
"def test_delete_authorized_user(self):\n pass",
"def test_delete_implant_template(self):\n pass",
"def test_delete_global_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.delete(self.fixture.global_template, request=mock_request)",
"def test_delete_global_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.delete(self.fixture.global_template, request=mock_request)",
"def test_delete_user_template_as_anonymous_with_access_right_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.delete(\n self.fixture.user1_template, request=mock_request\n )",
"def test_delete_user(self):\n pass",
"def test_delete_user_template_as_anonymous_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.delete(\n self.fixture.user1_template, request=mock_request\n )",
"def test_teams_id_templates_nk_template_members_delete(self):\n pass",
"def test_delete_activity_template(self):\n pass",
"def test_email_template_delete(self):\n pass",
"def test_delete_non_owner(self):\n another_user = CustomUser.objects.create(id=134, email='another_user2@mail.com', is_active=True)\n another_user.set_password('qwerty12345')\n another_user.save()\n\n self.client.login(email='another_user2@mail.com', password='qwerty12345')\n\n url = reverse('notification',\n kwargs={'way_id': self.notification.way_id, 'notification_id': 87876})\n\n response = self.client.delete(url)\n\n self.assertEqual(response.status_code, 403)",
"def test_plant_delete_normal_users(self):\n url = reverse('plant-detail', kwargs={\"pk\": self.plant.pk})\n self.client.force_authenticate(user=self.user)\n response = self.client.delete(url, format='json')\n\n self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test delete global template as staff saves | def test_delete_global_template_as_staff_saves(self):
mock_request = create_mock_request(user=self.staff_user1)
template_api.delete(self.fixture.global_template, request=mock_request) | [
"def test_delete_implant_template(self):\n pass",
"def test_delete_global_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.delete(self.fixture.global_template, request=mock_request)",
"def test_email_template_delete(self):\n pass",
"def test_delete_own_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.delete(self.fixture.user1_template, request=mock_request)",
"def test_delete_namespaced_template(self):\n pass",
"def test_delete_activity_template(self):\n pass",
"def test_delete_own_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.delete(self.fixture.user1_template, request=mock_request)",
"def test_team_template_folders_id_delete(self):\n pass",
"def test_delete_template_subscription(self):\n pass",
"def test_delete_own_template_as_user_saves(self):\n mock_request = create_mock_request(user=self.user1)\n template_api.delete(self.fixture.user1_template, request=mock_request)",
"def test_teams_id_template_folders_delete(self):\n pass",
"def test_teams_id_templates_delete(self):\n pass",
"def test_delete_device_template(self):\n pass",
"def test_unshare_template_registration(self):\n pass",
"def test_teams_id_templates_nk_portal_folders_delete(self):\n pass",
"def test_unregister_template(self):\n pass",
"def test_delete_subscription_template(self):\n pass",
"def test_xml_template_delete(self):\n XmlTemplate.delete_by_id(1)\n self.assertEqual(XmlTemplate.objects.count(), 1)\n self.assertFalse(XmlTemplate.objects.filter(pk=1).exists())",
"def test_team_template_folders_id_templates_fk_delete(self):\n pass"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test delete own template as superuser saves | def test_delete_own_template_as_superuser_saves(self):
mock_request = create_mock_request(user=self.superuser1)
template_api.delete(self.fixture.user1_template, request=mock_request) | [
"def test_delete_own_template_as_user_saves(self):\n mock_request = create_mock_request(user=self.user1)\n template_api.delete(self.fixture.user1_template, request=mock_request)",
"def test_delete_global_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.delete(self.fixture.global_template, request=mock_request)",
"def test_delete_implant_template(self):\n pass",
"def test_delete_other_users_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.delete(self.fixture.user2_template, request=mock_request)",
"def test_delete_own_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.delete(self.fixture.user1_template, request=mock_request)",
"def test_email_template_delete(self):\n pass",
"def test_delete_activity_template(self):\n pass",
"def test_delete_template_subscription(self):\n pass",
"def test_delete_global_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.delete(self.fixture.global_template, request=mock_request)",
"def test_delete_namespaced_template(self):\n pass",
"def test_delete_device_template(self):\n pass",
"def test_delete_subscription_template(self):\n pass",
"def test_superuser_can_delete_a_tag(self):\n self.client.force_login(user=self.superuser)\n response = self.client.delete(\n reverse(self.detail_view, kwargs={'pk': 1})\n )\n self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)",
"def test_xml_template_delete(self):\n XmlTemplate.delete_by_id(1)\n self.assertEqual(XmlTemplate.objects.count(), 1)\n self.assertFalse(XmlTemplate.objects.filter(pk=1).exists())",
"def test_teams_id_templates_nk_permission_delete(self):\n pass",
"def test_delete_authorized_user(self):\n pass",
"def test_post_delete_admin(self):\n url = reverse('post-detail', kwargs={'pk': self.post.id})\n self.client.force_authenticate(user=self.superuser)\n response = self.client.delete(url)\n self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)",
"def test_delete_view_uses_correct_template(self):\n self.client.force_login(self.test_user)\n response = self.client.get(self.url)\n self.assertTemplateUsed(response, 'calendars/delete.html')",
"def test_plant_delete_super_users(self):\n url = reverse('plant-detail', kwargs={\"pk\": self.plant.pk})\n self.client.force_authenticate(user=self.superuser)\n response = self.client.delete(url, format='json')\n\n self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test delete other users template as superuser saves | def test_delete_other_users_template_as_superuser_saves(self):
mock_request = create_mock_request(user=self.superuser1)
template_api.delete(self.fixture.user2_template, request=mock_request) | [
"def test_delete_own_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.delete(self.fixture.user1_template, request=mock_request)",
"def test_delete_own_template_as_user_saves(self):\n mock_request = create_mock_request(user=self.user1)\n template_api.delete(self.fixture.user1_template, request=mock_request)",
"def test_delete_global_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.delete(self.fixture.global_template, request=mock_request)",
"def test_delete_own_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.delete(self.fixture.user1_template, request=mock_request)",
"def test_delete_implant_template(self):\n pass",
"def test_email_template_delete(self):\n pass",
"def test_delete_global_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.delete(self.fixture.global_template, request=mock_request)",
"def test_delete_user(self):\n pass",
"def test_delete_activity_template(self):\n pass",
"def test_plant_delete_super_users(self):\n url = reverse('plant-detail', kwargs={\"pk\": self.plant.pk})\n self.client.force_authenticate(user=self.superuser)\n response = self.client.delete(url, format='json')\n\n self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)",
"def test_delete_authorized_user(self):\n pass",
"def test_superuser_can_delete_a_tag(self):\n self.client.force_login(user=self.superuser)\n response = self.client.delete(\n reverse(self.detail_view, kwargs={'pk': 1})\n )\n self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)",
"def test_delete_device_template(self):\n pass",
"def test_delete_template_subscription(self):\n pass",
"def test_delete_subscription_template(self):\n pass",
"def test_delete_namespaced_template(self):\n pass",
"def test_teams_id_templates_nk_permission_delete(self):\n pass",
"def test_delete_user_field(self):\n pass",
"def test_successfult_post_deletion(self):\n self.user.is_moderator = True\n self.user.save()\n response = self.client.delete(reverse('api:posts-detail', kwargs={'pk': self.post1.id}))\n self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)\n self.assertEqual(Post.objects.count(), 1)"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test delete global template as superuser saves | def test_delete_global_template_as_superuser_saves(self):
mock_request = create_mock_request(user=self.superuser1)
template_api.delete(self.fixture.global_template, request=mock_request) | [
"def test_delete_own_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.delete(self.fixture.user1_template, request=mock_request)",
"def test_delete_global_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.delete(self.fixture.global_template, request=mock_request)",
"def test_delete_implant_template(self):\n pass",
"def test_delete_other_users_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.delete(self.fixture.user2_template, request=mock_request)",
"def test_delete_own_template_as_user_saves(self):\n mock_request = create_mock_request(user=self.user1)\n template_api.delete(self.fixture.user1_template, request=mock_request)",
"def test_email_template_delete(self):\n pass",
"def test_delete_namespaced_template(self):\n pass",
"def test_delete_activity_template(self):\n pass",
"def test_delete_own_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staff_user1)\n template_api.delete(self.fixture.user1_template, request=mock_request)",
"def test_delete_device_template(self):\n pass",
"def test_delete_template_subscription(self):\n pass",
"def test_unshare_template_registration(self):\n pass",
"def test_unregister_template(self):\n pass",
"def test_delete_subscription_template(self):\n pass",
"def test_delete_global_template_as_user_raises_access_control_error(self):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.delete(\n self.fixture.global_template, request=mock_request\n )",
"def test_teams_id_templates_nk_permission_delete(self):\n pass",
"def test_team_template_folders_id_delete(self):\n pass",
"def test_upsert_global_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.upsert(self.fixture.global_template, request=mock_request)",
"def test_xml_template_delete(self):\n XmlTemplate.delete_by_id(1)\n self.assertEqual(XmlTemplate.objects.count(), 1)\n self.assertFalse(XmlTemplate.objects.filter(pk=1).exists())"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates a breakpoint, which is a renamed deep copy of the QuantumCircuit, and creates and appends an AssertUniform instruction to its end. If the statistical test passes, the assertion passes; if the test fails, the assertion fails. | def get_breakpoint_uniform(self, qubit, cbit, pcrit=0.05):
clone = self.copy(Asserts._new_breakpoint_name())
assertion = AssertUniform(qubit, cbit, pcrit, False)
clone.append(assertion, [assertion._qubit], [assertion._cbit])
return clone | [
"def get_breakpoint_not_uniform(self, qubit, cbit, pcrit=0.05):\n clone = self.copy(Asserts._new_breakpoint_name())\n assertion = AssertUniform(qubit, cbit, pcrit, True)\n clone.append(assertion, [assertion._qubit], [assertion._cbit])\n return clone",
"def get_breakpoint_product(self, qubit0, cbit0, qubit1, cbit1, pcrit=0.05):\n clone = self.copy(Asserts._new_breakpoint_name())\n assertion = AssertProduct(qubit0, cbit0, qubit1, cbit1, pcrit, False)\n clone.append(assertion, [assertion._qubit], [assertion._cbit])\n return clone",
"def get_breakpoint_not_product(self, qubit0, cbit0, qubit1, cbit1, pcrit=0.05):\n clone = self.copy(Asserts._new_breakpoint_name())\n assertion = AssertProduct(qubit0, cbit0, qubit1, cbit1, pcrit, True)\n clone.append(assertion, [assertion._qubit], [assertion._cbit])\n return clone",
"def assert_valid_circuit(self, transpiled):\n self.assertIsInstance(transpiled, QuantumCircuit)\n self.assertIsNotNone(getattr(transpiled, \"_layout\", None))\n\n def _visit_block(circuit, qubit_mapping=None):\n for instruction in circuit:\n if instruction.operation.name in {\"barrier\", \"measure\"}:\n continue\n self.assertIn(instruction.operation.name, self.basis_gates)\n qargs = tuple(qubit_mapping[x] for x in instruction.qubits)\n if not isinstance(instruction.operation, ControlFlowOp):\n if len(qargs) > 2 or len(qargs) < 0:\n raise Exception(\"Invalid number of qargs for instruction\")\n if len(qargs) == 2:\n self.assertIn(qargs, self.coupling_edge_set)\n else:\n self.assertLessEqual(qargs[0], 26)\n else:\n for block in instruction.operation.blocks:\n self.assertEqual(block.num_qubits, len(instruction.qubits))\n self.assertEqual(block.num_clbits, len(instruction.clbits))\n new_mapping = {\n inner: qubit_mapping[outer]\n for outer, inner in zip(instruction.qubits, block.qubits)\n }\n _visit_block(block, new_mapping)\n\n # Assert routing ran.\n _visit_block(\n transpiled,\n qubit_mapping={qubit: index for index, qubit in enumerate(transpiled.qubits)},\n )",
"def test(self):\n self.gdb.command(\"b just_before_write_loop\")\n self.gdb.c()\n write_loop = self.gdb.p(\"&write_loop\")\n self.gdb.command(\"watch data\")\n self.gdb.c()\n # Accept hitting the breakpoint before or after the store instruction.\n assertIn(self.gdb.p(\"$pc\"), [write_loop, write_loop + 4])\n assertEqual(self.gdb.p(\"$a0\"), self.gdb.p(\"&data\"))",
"def test_lldbmi_var_create_in_sibling_scope(self):\n\n self.spawnLldbMi(args=None)\n\n # Load executable\n self.runCmd(\"-file-exec-and-symbols %s\" % self.myexe)\n self.expect(\"\\^done\")\n\n # Breakpoint inside first scope\n line = line_number('main.cpp', '// BP_first')\n self.runCmd(\"-break-insert --file main.cpp:%d\" % line)\n self.expect(\"\\^done,bkpt={number=\\\"\\d+\\\"\")\n\n # Breakpoint inside second scope\n line = line_number('main.cpp', '// BP_second')\n self.runCmd(\"-break-insert --file main.cpp:%d\" % line)\n self.expect(\"\\^done,bkpt={number=\\\"\\d+\\\"\")\n\n # Run to the first scope\n self.runCmd(\"-exec-run\")\n self.expect(\"\\^running\")\n self.expect(\"\\*stopped,reason=\\\"breakpoint-hit\\\"\")\n\n # Check that only variables a and b exist with expected values\n self.runCmd(\"-stack-list-locals --thread 1 --frame 0 --all-values\")\n self.expect(\"\\^done,locals=\\[{name=\\\"a\\\",value=\\\"1\\\"},{name=\\\"b\\\",value=\\\"2\\\"}\\]\")\n\n # Create variable object for local variable b\n self.runCmd(\"-var-create - * \\\"b\\\"\")\n self.expect(\n \"\\^done,name=\\\"var\\d+\\\",numchild=\\\"0\\\",value=\\\"2\\\",type=\\\"int\\\",thread-id=\\\"1\\\",has_more=\\\"0\\\"\")\n\n # Run to the second scope\n self.runCmd(\"-exec-continue\")\n self.expect(\"\\^running\")\n self.expect(\"\\*stopped,reason=\\\"breakpoint-hit\\\"\")\n\n # Check that only variables a and b exist with expected values,\n # but variable b is different from previous breakpoint\n self.runCmd(\"-stack-list-variables --thread 1 --frame 0 --all-values\")\n self.expect(\"\\^done,variables=\\[{name=\\\"a\\\",value=\\\"1\\\"},{name=\\\"b\\\",value=\\\"3\\\"}\\]\")\n\n # Create variable object for local variable b\n self.runCmd(\"-var-create - * \\\"b\\\"\")\n self.expect(\n \"\\^done,name=\\\"var\\d+\\\",numchild=\\\"0\\\",value=\\\"3\\\",type=\\\"short\\\",thread-id=\\\"1\\\",has_more=\\\"0\\\"\")",
"def check_execution(self, original_circuit: Circuit, transpiled_circuit: Optional[Circuit] = None):\n if transpiled_circuit is None:\n transpiled_circuit, _ = self(original_circuit)\n\n backend = NumpyBackend()\n target_state = backend.execute_circuit(original_circuit).state()\n final_state = backend.execute_circuit(transpiled_circuit).state()\n fidelity = np.abs(np.dot(np.conj(target_state), final_state))\n np.testing.assert_allclose(fidelity, 1.0)\n log.info(\"Transpiler test passed.\")",
"def debugger_add_hw_breakpoint():",
"def test_debugger_api_boundary_condition(self):\n self.dbg.HandleCommand(None)\n self.dbg.SetDefaultArchitecture(None)\n self.dbg.GetScriptingLanguage(None)\n self.dbg.CreateTarget(None)\n self.dbg.CreateTarget(None, None, None, True, lldb.SBError())\n self.dbg.CreateTargetWithFileAndTargetTriple(None, None)\n self.dbg.CreateTargetWithFileAndArch(None, None)\n self.dbg.FindTargetWithFileAndArch(None, None)\n self.dbg.SetInternalVariable(None, None, None)\n self.dbg.GetInternalVariableValue(None, None)\n # FIXME (filcab): We must first allow for the swig bindings to know if\n # a Python callback is set. (Check python-typemaps.swig)\n # self.dbg.SetLoggingCallback(None)\n self.dbg.SetPrompt(None)\n self.dbg.SetCurrentPlatform(None)\n self.dbg.SetCurrentPlatformSDKRoot(None)\n \n fresh_dbg = lldb.SBDebugger()\n self.assertEquals(len(fresh_dbg), 0)",
"def _analyse_stmt_Assert(self, statement: ast.Assert, *, next: CFNode) -> CFNode:\n test_is_constant, test_value = self._expression_as_constant(statement.test)\n\n branches: Dict[str, CFNode] = {}\n if test_is_constant:\n if test_value:\n branches.update(next=next)\n else:\n branches.update(error=self._raise)\n else:\n branches.update(next=next, error=self._raise)\n\n return self._ast_node(statement, **branches)",
"def test_expressions(self):\n self.build()\n lldbutil.run_to_name_breakpoint(self, \"main\")\n exprs = (\"argc + 1\", \"(void)argc\", \"(int)abs(argc)\")\n for expr in exprs:\n self._expect_cmd(f\"dwim-print {expr}\", \"expression\")",
"def test_06_changeBreakpointState(self):\n self.ikpdb.set_breakpoint('debugged_programs/test02_breakpoints.py',\n line_number=7,\n enabled=True)\n self.ikpdb.set_breakpoint('debugged_programs/test02_breakpoints.py',\n line_number=8,\n condition='a_var==1',\n enabled=True)\n self.ikpdb.set_breakpoint('debugged_programs/test02_breakpoints.py',\n line_number=10,\n condition='a_var==60',\n enabled=True)\n\n self.ikpdb.run_script()\n\n # break at line 7\n i_msg = self.ikpdb.receive()\n self.assertEqual(i_msg['command'], \"programBreak\", \"programBreak message not received.\")\n self.assertEqual(i_msg['exception'], None, \"Unexpected exception raised.\")\n top_frame = i_msg['frames'][0]\n self.assertEqual(top_frame['file_path'], \n 'debugged_programs/test02_breakpoints.py', \n \"programBreak on unexpected file.\")\n self.assertEqual(top_frame['line_number'], 7, \"programBreak on unexpected line number.\")\n \n # disable breakpoint at line 8 (second)\n msg_id = self.ikpdb.send('changeBreakpointState', \n breakpoint_number=1,\n enabled=False)\n i_msg = self.ikpdb.receive()\n self.assertEqual(i_msg['_id'], msg_id, \"Unexpected reply to 'clearBreakpoint'.\")\n self.assertEqual(i_msg['commandExecStatus'], \"ok\", \"'changeBreakpoint' command failed.\")\n \n # modify condition on last breakpoint so that it will trigger\n msg_id = self.ikpdb.send('changeBreakpointState', \n breakpoint_number=2,\n enabled=True,\n condition=\"a_var==50\")\n i_msg = self.ikpdb.receive()\n self.assertEqual(i_msg['_id'], msg_id, \"Unexpected reply to 'clearBreakpoint'.\")\n self.assertEqual(i_msg['commandExecStatus'], \"ok\", \"'changeBreakpoint' command failed.\")\n\n bp_list = self.ikpdb.get_breakpoints()\n\n # resume()\n msg_id = self.ikpdb.send('resume')\n i_msg = self.ikpdb.receive()\n self.assertEqual(i_msg['_id'], msg_id, \"Unexpected reply to 'clearBreakpoint'.\")\n self.assertEqual(i_msg['commandExecStatus'], \"ok\", \"'resume' command failed.\")\n self.assertEqual(i_msg['result'].get('executionStatus'), 'running', \"'resume' command failed.\")\n\n # check that last breakpoint triggers\n i_msg = self.ikpdb.receive()\n self.assertEqual(i_msg['command'], \"programBreak\", \"programBreak message not received.\")\n self.assertEqual(i_msg['exception'], None, \"Unexpected exception raised.\")\n top_frame = i_msg['frames'][0]\n self.assertEqual(top_frame['file_path'], \n 'debugged_programs/test02_breakpoints.py', \n \"programBreak on unexpected file.\")\n self.assertEqual(top_frame['line_number'], 10, \"programBreak on unexpected line number.\")",
"def unitTest():\n\tcurve = cmds.curve(d=3, \n\t\tp=[[-3,0,-5], \n\t\t[-2.75,0,-3.916667], \n\t\t[-2.25,0,-1.75], \n\t\t[0,0,0], \n\t\t[2.25,0,1.75], \n\t\t[2.75,0,3.916667], \n\t\t[3,0,5]], \n\t\tk=[0,0,0,1,2,3,4,4,4])\n\t\n\t# test create mode\n\tprint '---TESTING CREATE---'\n\tribbon = cmds.am_ribbon(curve)\n\t\n\t# test edit mode and query mode\n\tdef compareVectors(listVec, tupleVec):\n\t\t\"\"\"Return test result comparing vectors\"\"\"\n\t\treturn listVec[0]==tupleVec[0] and listVec[1]==tupleVec[1] and listVec[2]==tupleVec[2]\n\tdef verifyValues(outNum, rNode, expWid, expTap, expTwb, expTwl, expUpv, expUvs, expUvp):\n\t\t\"\"\"Print test results\"\"\"\n\t\tprint '%s (test %i):'%(rNode, outNum)\n\t\tprint'\\twidth: %s'%(expWid == cmds.am_ribbon(rNode, q=True, w=True))\n\t\tprint'\\ttaper: %s'%(expTap == cmds.am_ribbon(rNode, q=True, t=True))\n\t\tprint'\\ttwBa: %s'%(expTwb == cmds.am_ribbon(rNode, q=True, tb=True))\n\t\tprint'\\ttwLen: %s'%(expTwl == cmds.am_ribbon(rNode, q=True, tl=True))\n\t\tprint'\\tupVec: %s'%(compareVectors(expUpv, cmds.am_ribbon(rNode, q=True, up=True)))\n\t\tprint'\\tuvSca: %s'%(expUvs == cmds.am_ribbon(rNode, q=True, uv=True))\n\t\tprint'\\tuvPin: %s'%(expUvp == cmds.am_ribbon(rNode, q=True, uvp=True))\n\tprint '---TESTING EDIT AND QUERY---'\n\twid = 0.5\n\ttaper = 0.5\n\ttwistBase = -45.0\n\ttwistLength = 135.0\n\tupVec = [0,2,0]\n\tuvScale = 2.0\n\tuvPin = 1\n\tcmds.am_ribbon(ribbon, e=True, w=wid, t=taper, tb=twistBase, tl=twistLength, up=upVec, uv=uvScale, uvp=uvPin)\n\tverifyValues(0, ribbon, wid, taper, twistBase, twistLength, upVec, uvScale, uvPin)\n\tdiv = 15\n\tcmds.am_ribbon(ribbon, e=True, d=div)\n\tprint'\\tdivs: %s'%(div == cmds.am_ribbon(ribbon, q=True, d=True))\n\tdpu = 2.5\n\tcmds.am_ribbon(ribbon, e=True, dp=dpu)\n\tprint'\\tdpu: %s'%(dpu - cmds.am_ribbon(ribbon, q=True, dp=True) < 0.01)",
"def test_add_circuit_noname(self):\n q_program = QuantumProgram()\n qr = q_program.create_quantum_register(size=2)\n cr = q_program.create_classical_register(size=2)\n qc1 = q_program.create_circuit(qregisters=[qr], cregisters=[cr])\n qc2 = q_program.create_circuit(qregisters=[qr], cregisters=[cr])\n qc1.h(qr[0])\n qc1.measure(qr[0], cr[0])\n qc2.measure(qr[1], cr[1])\n new_circuit = qc1 + qc2\n q_program.add_circuit(quantum_circuit=new_circuit)\n backend = 'local_qasm_simulator_py' # cpp simulator rejects non string IDs (FIXME)\n shots = 1024\n result = q_program.execute(backend=backend, shots=shots, seed=78)\n counts = result.get_counts(new_circuit.name)\n target = {'00': shots / 2, '01': shots / 2}\n threshold = 0.04 * shots\n self.assertDictAlmostEqual(counts, target, threshold)\n self.assertRaises(QISKitError, result.get_counts)",
"def test_04_conditionalBreakpoint(self):\n self.ikpdb.set_breakpoint('debugged_programs/test02_breakpoints.py',\n line_number=10,\n enabled=False)\n self.ikpdb.set_breakpoint('debugged_programs/test02_breakpoints.py',\n line_number=10,\n condition='a_var==50',\n enabled=False)\n self.ikpdb.set_breakpoint('debugged_programs/test02_breakpoints.py',\n line_number=11,\n condition='a_var==50',\n enabled=True)\n\n self.ikpdb.run_script()\n \n i_msg = self.ikpdb.receive()\n self.assertEqual(i_msg['command'], \"programBreak\", \"programBreak message not received.\")\n self.assertEqual(i_msg['exception'], None, \"Unexpected exception raised.\")\n top_frame = i_msg['frames'][0]\n self.assertEqual(top_frame['file_path'], \n 'debugged_programs/test02_breakpoints.py', \n \"programBreak on unexpected file.\")\n self.assertEqual(top_frame['line_number'], 11, \"programBreak on unexpected line number.\")\n a_var_dump = filter(lambda e:e['name']=='a_var', top_frame['f_locals'])\n \n self.assertEqual(len(a_var_dump), 1, \"local a_var not found.\")\n self.assertEqual(a_var_dump[0]['value'], '50', \"wrong value for a_var. expecting '50' got '%s'\" % a_var_dump[0]['value'])",
"def test_four_hwx_breakpoint_fail(self):\n TEST_CASE = self\n data = [0]\n\n class TSTBP(windows.debug.HXBreakpoint):\n def __init__(self, addr, expec_before):\n self.addr = addr\n self.expec_before = expec_before\n\n def trigger(self, dbg, exc):\n raise NotImplementedError(\"Should fail before\")\n\n calc = pop_calc_32(dwCreationFlags=DEBUG_PROCESS)\n d = windows.debug.Debugger(calc)\n addr = calc.virtual_alloc(0x1000)\n calc.write_memory(addr, \"\\x90\" * 8 + \"\\xc3\")\n d.add_bp(TSTBP(addr, 0))\n d.add_bp(TSTBP(addr + 1, 1))\n d.add_bp(TSTBP(addr + 2, 2))\n d.add_bp(TSTBP(addr + 3, 3))\n d.add_bp(TSTBP(addr + 4, 4))\n\n calc.create_thread(addr, 0)\n with self.assertRaises(ValueError) as e:\n d.loop()\n self.assertIn(\"DRx\", e.exception.message)\n # Used to verif we actually NOT called the Breakpoints\n TEST_CASE.assertEqual(data[0], 0)",
"def create_breakpoint(self, filename, line, temporary=False):\n self.output('break', filename=filename, line=line, temporary=temporary)",
"def test_breaker_will_raise(testbreakbox):\n breaker = testbreakbox[\"basic\"]\n raisefault(\"basic\", testbreakbox)\n assert breaker.tripped is True\n with pytest.raises(CircuitBroken):\n with circuit_breaker(\"basic\", breakerbox=testbreakbox):\n 1/0",
"def test_analytic_value_with_simple_circuit(self, differentiator, op):\n # Get an expectation op, with this differentiator attached.\n differentiator.refresh()\n op = differentiator.generate_differentiable_op(analytic_op=op)\n qubit = cirq.GridQubit(0, 0)\n circuit = util.convert_to_tensor(\n [cirq.Circuit(cirq.X(qubit)**sympy.Symbol('alpha'))])\n psums = util.convert_to_tensor([[cirq.Z(qubit)]])\n symbol_values_array = np.array([[0.123]], dtype=np.float32)\n # Calculate tfq gradient.\n symbol_values_tensor = tf.convert_to_tensor(symbol_values_array)\n with tf.GradientTape() as g:\n g.watch(symbol_values_tensor)\n expectations = op(circuit, tf.convert_to_tensor(['alpha']),\n symbol_values_tensor, psums)\n grads = g.gradient(expectations, symbol_values_tensor)\n ground_truth_grads = np.array([[-1.1839752]])\n self.assertAllClose(ground_truth_grads, grads, rtol=1e-2, atol=1e-2)"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates a breakpoint, which is a renamed deep copy of the QuantumCircuit, and creates and appends an AssertUniform instruction to its end. If the statistical test passes, the assertion fails; if the test fails, the assertion passes. | def get_breakpoint_not_uniform(self, qubit, cbit, pcrit=0.05):
clone = self.copy(Asserts._new_breakpoint_name())
assertion = AssertUniform(qubit, cbit, pcrit, True)
clone.append(assertion, [assertion._qubit], [assertion._cbit])
return clone | [
"def get_breakpoint_uniform(self, qubit, cbit, pcrit=0.05):\n clone = self.copy(Asserts._new_breakpoint_name())\n assertion = AssertUniform(qubit, cbit, pcrit, False)\n clone.append(assertion, [assertion._qubit], [assertion._cbit])\n return clone",
"def get_breakpoint_product(self, qubit0, cbit0, qubit1, cbit1, pcrit=0.05):\n clone = self.copy(Asserts._new_breakpoint_name())\n assertion = AssertProduct(qubit0, cbit0, qubit1, cbit1, pcrit, False)\n clone.append(assertion, [assertion._qubit], [assertion._cbit])\n return clone",
"def get_breakpoint_not_product(self, qubit0, cbit0, qubit1, cbit1, pcrit=0.05):\n clone = self.copy(Asserts._new_breakpoint_name())\n assertion = AssertProduct(qubit0, cbit0, qubit1, cbit1, pcrit, True)\n clone.append(assertion, [assertion._qubit], [assertion._cbit])\n return clone",
"def assert_valid_circuit(self, transpiled):\n self.assertIsInstance(transpiled, QuantumCircuit)\n self.assertIsNotNone(getattr(transpiled, \"_layout\", None))\n\n def _visit_block(circuit, qubit_mapping=None):\n for instruction in circuit:\n if instruction.operation.name in {\"barrier\", \"measure\"}:\n continue\n self.assertIn(instruction.operation.name, self.basis_gates)\n qargs = tuple(qubit_mapping[x] for x in instruction.qubits)\n if not isinstance(instruction.operation, ControlFlowOp):\n if len(qargs) > 2 or len(qargs) < 0:\n raise Exception(\"Invalid number of qargs for instruction\")\n if len(qargs) == 2:\n self.assertIn(qargs, self.coupling_edge_set)\n else:\n self.assertLessEqual(qargs[0], 26)\n else:\n for block in instruction.operation.blocks:\n self.assertEqual(block.num_qubits, len(instruction.qubits))\n self.assertEqual(block.num_clbits, len(instruction.clbits))\n new_mapping = {\n inner: qubit_mapping[outer]\n for outer, inner in zip(instruction.qubits, block.qubits)\n }\n _visit_block(block, new_mapping)\n\n # Assert routing ran.\n _visit_block(\n transpiled,\n qubit_mapping={qubit: index for index, qubit in enumerate(transpiled.qubits)},\n )",
"def test_lldbmi_var_create_in_sibling_scope(self):\n\n self.spawnLldbMi(args=None)\n\n # Load executable\n self.runCmd(\"-file-exec-and-symbols %s\" % self.myexe)\n self.expect(\"\\^done\")\n\n # Breakpoint inside first scope\n line = line_number('main.cpp', '// BP_first')\n self.runCmd(\"-break-insert --file main.cpp:%d\" % line)\n self.expect(\"\\^done,bkpt={number=\\\"\\d+\\\"\")\n\n # Breakpoint inside second scope\n line = line_number('main.cpp', '// BP_second')\n self.runCmd(\"-break-insert --file main.cpp:%d\" % line)\n self.expect(\"\\^done,bkpt={number=\\\"\\d+\\\"\")\n\n # Run to the first scope\n self.runCmd(\"-exec-run\")\n self.expect(\"\\^running\")\n self.expect(\"\\*stopped,reason=\\\"breakpoint-hit\\\"\")\n\n # Check that only variables a and b exist with expected values\n self.runCmd(\"-stack-list-locals --thread 1 --frame 0 --all-values\")\n self.expect(\"\\^done,locals=\\[{name=\\\"a\\\",value=\\\"1\\\"},{name=\\\"b\\\",value=\\\"2\\\"}\\]\")\n\n # Create variable object for local variable b\n self.runCmd(\"-var-create - * \\\"b\\\"\")\n self.expect(\n \"\\^done,name=\\\"var\\d+\\\",numchild=\\\"0\\\",value=\\\"2\\\",type=\\\"int\\\",thread-id=\\\"1\\\",has_more=\\\"0\\\"\")\n\n # Run to the second scope\n self.runCmd(\"-exec-continue\")\n self.expect(\"\\^running\")\n self.expect(\"\\*stopped,reason=\\\"breakpoint-hit\\\"\")\n\n # Check that only variables a and b exist with expected values,\n # but variable b is different from previous breakpoint\n self.runCmd(\"-stack-list-variables --thread 1 --frame 0 --all-values\")\n self.expect(\"\\^done,variables=\\[{name=\\\"a\\\",value=\\\"1\\\"},{name=\\\"b\\\",value=\\\"3\\\"}\\]\")\n\n # Create variable object for local variable b\n self.runCmd(\"-var-create - * \\\"b\\\"\")\n self.expect(\n \"\\^done,name=\\\"var\\d+\\\",numchild=\\\"0\\\",value=\\\"3\\\",type=\\\"short\\\",thread-id=\\\"1\\\",has_more=\\\"0\\\"\")",
"def test(self):\n self.gdb.command(\"b just_before_write_loop\")\n self.gdb.c()\n write_loop = self.gdb.p(\"&write_loop\")\n self.gdb.command(\"watch data\")\n self.gdb.c()\n # Accept hitting the breakpoint before or after the store instruction.\n assertIn(self.gdb.p(\"$pc\"), [write_loop, write_loop + 4])\n assertEqual(self.gdb.p(\"$a0\"), self.gdb.p(\"&data\"))",
"def debugger_add_hw_breakpoint():",
"def check_execution(self, original_circuit: Circuit, transpiled_circuit: Optional[Circuit] = None):\n if transpiled_circuit is None:\n transpiled_circuit, _ = self(original_circuit)\n\n backend = NumpyBackend()\n target_state = backend.execute_circuit(original_circuit).state()\n final_state = backend.execute_circuit(transpiled_circuit).state()\n fidelity = np.abs(np.dot(np.conj(target_state), final_state))\n np.testing.assert_allclose(fidelity, 1.0)\n log.info(\"Transpiler test passed.\")",
"def test_debugger_api_boundary_condition(self):\n self.dbg.HandleCommand(None)\n self.dbg.SetDefaultArchitecture(None)\n self.dbg.GetScriptingLanguage(None)\n self.dbg.CreateTarget(None)\n self.dbg.CreateTarget(None, None, None, True, lldb.SBError())\n self.dbg.CreateTargetWithFileAndTargetTriple(None, None)\n self.dbg.CreateTargetWithFileAndArch(None, None)\n self.dbg.FindTargetWithFileAndArch(None, None)\n self.dbg.SetInternalVariable(None, None, None)\n self.dbg.GetInternalVariableValue(None, None)\n # FIXME (filcab): We must first allow for the swig bindings to know if\n # a Python callback is set. (Check python-typemaps.swig)\n # self.dbg.SetLoggingCallback(None)\n self.dbg.SetPrompt(None)\n self.dbg.SetCurrentPlatform(None)\n self.dbg.SetCurrentPlatformSDKRoot(None)\n \n fresh_dbg = lldb.SBDebugger()\n self.assertEquals(len(fresh_dbg), 0)",
"def test_06_changeBreakpointState(self):\n self.ikpdb.set_breakpoint('debugged_programs/test02_breakpoints.py',\n line_number=7,\n enabled=True)\n self.ikpdb.set_breakpoint('debugged_programs/test02_breakpoints.py',\n line_number=8,\n condition='a_var==1',\n enabled=True)\n self.ikpdb.set_breakpoint('debugged_programs/test02_breakpoints.py',\n line_number=10,\n condition='a_var==60',\n enabled=True)\n\n self.ikpdb.run_script()\n\n # break at line 7\n i_msg = self.ikpdb.receive()\n self.assertEqual(i_msg['command'], \"programBreak\", \"programBreak message not received.\")\n self.assertEqual(i_msg['exception'], None, \"Unexpected exception raised.\")\n top_frame = i_msg['frames'][0]\n self.assertEqual(top_frame['file_path'], \n 'debugged_programs/test02_breakpoints.py', \n \"programBreak on unexpected file.\")\n self.assertEqual(top_frame['line_number'], 7, \"programBreak on unexpected line number.\")\n \n # disable breakpoint at line 8 (second)\n msg_id = self.ikpdb.send('changeBreakpointState', \n breakpoint_number=1,\n enabled=False)\n i_msg = self.ikpdb.receive()\n self.assertEqual(i_msg['_id'], msg_id, \"Unexpected reply to 'clearBreakpoint'.\")\n self.assertEqual(i_msg['commandExecStatus'], \"ok\", \"'changeBreakpoint' command failed.\")\n \n # modify condition on last breakpoint so that it will trigger\n msg_id = self.ikpdb.send('changeBreakpointState', \n breakpoint_number=2,\n enabled=True,\n condition=\"a_var==50\")\n i_msg = self.ikpdb.receive()\n self.assertEqual(i_msg['_id'], msg_id, \"Unexpected reply to 'clearBreakpoint'.\")\n self.assertEqual(i_msg['commandExecStatus'], \"ok\", \"'changeBreakpoint' command failed.\")\n\n bp_list = self.ikpdb.get_breakpoints()\n\n # resume()\n msg_id = self.ikpdb.send('resume')\n i_msg = self.ikpdb.receive()\n self.assertEqual(i_msg['_id'], msg_id, \"Unexpected reply to 'clearBreakpoint'.\")\n self.assertEqual(i_msg['commandExecStatus'], \"ok\", \"'resume' command failed.\")\n self.assertEqual(i_msg['result'].get('executionStatus'), 'running', \"'resume' command failed.\")\n\n # check that last breakpoint triggers\n i_msg = self.ikpdb.receive()\n self.assertEqual(i_msg['command'], \"programBreak\", \"programBreak message not received.\")\n self.assertEqual(i_msg['exception'], None, \"Unexpected exception raised.\")\n top_frame = i_msg['frames'][0]\n self.assertEqual(top_frame['file_path'], \n 'debugged_programs/test02_breakpoints.py', \n \"programBreak on unexpected file.\")\n self.assertEqual(top_frame['line_number'], 10, \"programBreak on unexpected line number.\")",
"def test_four_hwx_breakpoint_fail(self):\n TEST_CASE = self\n data = [0]\n\n class TSTBP(windows.debug.HXBreakpoint):\n def __init__(self, addr, expec_before):\n self.addr = addr\n self.expec_before = expec_before\n\n def trigger(self, dbg, exc):\n raise NotImplementedError(\"Should fail before\")\n\n calc = pop_calc_32(dwCreationFlags=DEBUG_PROCESS)\n d = windows.debug.Debugger(calc)\n addr = calc.virtual_alloc(0x1000)\n calc.write_memory(addr, \"\\x90\" * 8 + \"\\xc3\")\n d.add_bp(TSTBP(addr, 0))\n d.add_bp(TSTBP(addr + 1, 1))\n d.add_bp(TSTBP(addr + 2, 2))\n d.add_bp(TSTBP(addr + 3, 3))\n d.add_bp(TSTBP(addr + 4, 4))\n\n calc.create_thread(addr, 0)\n with self.assertRaises(ValueError) as e:\n d.loop()\n self.assertIn(\"DRx\", e.exception.message)\n # Used to verif we actually NOT called the Breakpoints\n TEST_CASE.assertEqual(data[0], 0)",
"def test_add_circuit_noname(self):\n q_program = QuantumProgram()\n qr = q_program.create_quantum_register(size=2)\n cr = q_program.create_classical_register(size=2)\n qc1 = q_program.create_circuit(qregisters=[qr], cregisters=[cr])\n qc2 = q_program.create_circuit(qregisters=[qr], cregisters=[cr])\n qc1.h(qr[0])\n qc1.measure(qr[0], cr[0])\n qc2.measure(qr[1], cr[1])\n new_circuit = qc1 + qc2\n q_program.add_circuit(quantum_circuit=new_circuit)\n backend = 'local_qasm_simulator_py' # cpp simulator rejects non string IDs (FIXME)\n shots = 1024\n result = q_program.execute(backend=backend, shots=shots, seed=78)\n counts = result.get_counts(new_circuit.name)\n target = {'00': shots / 2, '01': shots / 2}\n threshold = 0.04 * shots\n self.assertDictAlmostEqual(counts, target, threshold)\n self.assertRaises(QISKitError, result.get_counts)",
"def test_expressions(self):\n self.build()\n lldbutil.run_to_name_breakpoint(self, \"main\")\n exprs = (\"argc + 1\", \"(void)argc\", \"(int)abs(argc)\")\n for expr in exprs:\n self._expect_cmd(f\"dwim-print {expr}\", \"expression\")",
"def _analyse_stmt_Assert(self, statement: ast.Assert, *, next: CFNode) -> CFNode:\n test_is_constant, test_value = self._expression_as_constant(statement.test)\n\n branches: Dict[str, CFNode] = {}\n if test_is_constant:\n if test_value:\n branches.update(next=next)\n else:\n branches.update(error=self._raise)\n else:\n branches.update(next=next, error=self._raise)\n\n return self._ast_node(statement, **branches)",
"def test_breaker_will_raise(testbreakbox):\n breaker = testbreakbox[\"basic\"]\n raisefault(\"basic\", testbreakbox)\n assert breaker.tripped is True\n with pytest.raises(CircuitBroken):\n with circuit_breaker(\"basic\", breakerbox=testbreakbox):\n 1/0",
"def create_breakpoint(self, filename, line, temporary=False):\n self.output('break', filename=filename, line=line, temporary=temporary)",
"def test_04_conditionalBreakpoint(self):\n self.ikpdb.set_breakpoint('debugged_programs/test02_breakpoints.py',\n line_number=10,\n enabled=False)\n self.ikpdb.set_breakpoint('debugged_programs/test02_breakpoints.py',\n line_number=10,\n condition='a_var==50',\n enabled=False)\n self.ikpdb.set_breakpoint('debugged_programs/test02_breakpoints.py',\n line_number=11,\n condition='a_var==50',\n enabled=True)\n\n self.ikpdb.run_script()\n \n i_msg = self.ikpdb.receive()\n self.assertEqual(i_msg['command'], \"programBreak\", \"programBreak message not received.\")\n self.assertEqual(i_msg['exception'], None, \"Unexpected exception raised.\")\n top_frame = i_msg['frames'][0]\n self.assertEqual(top_frame['file_path'], \n 'debugged_programs/test02_breakpoints.py', \n \"programBreak on unexpected file.\")\n self.assertEqual(top_frame['line_number'], 11, \"programBreak on unexpected line number.\")\n a_var_dump = filter(lambda e:e['name']=='a_var', top_frame['f_locals'])\n \n self.assertEqual(len(a_var_dump), 1, \"local a_var not found.\")\n self.assertEqual(a_var_dump[0]['value'], '50', \"wrong value for a_var. expecting '50' got '%s'\" % a_var_dump[0]['value'])",
"def unitTest():\n\tcurve = cmds.curve(d=3, \n\t\tp=[[-3,0,-5], \n\t\t[-2.75,0,-3.916667], \n\t\t[-2.25,0,-1.75], \n\t\t[0,0,0], \n\t\t[2.25,0,1.75], \n\t\t[2.75,0,3.916667], \n\t\t[3,0,5]], \n\t\tk=[0,0,0,1,2,3,4,4,4])\n\t\n\t# test create mode\n\tprint '---TESTING CREATE---'\n\tribbon = cmds.am_ribbon(curve)\n\t\n\t# test edit mode and query mode\n\tdef compareVectors(listVec, tupleVec):\n\t\t\"\"\"Return test result comparing vectors\"\"\"\n\t\treturn listVec[0]==tupleVec[0] and listVec[1]==tupleVec[1] and listVec[2]==tupleVec[2]\n\tdef verifyValues(outNum, rNode, expWid, expTap, expTwb, expTwl, expUpv, expUvs, expUvp):\n\t\t\"\"\"Print test results\"\"\"\n\t\tprint '%s (test %i):'%(rNode, outNum)\n\t\tprint'\\twidth: %s'%(expWid == cmds.am_ribbon(rNode, q=True, w=True))\n\t\tprint'\\ttaper: %s'%(expTap == cmds.am_ribbon(rNode, q=True, t=True))\n\t\tprint'\\ttwBa: %s'%(expTwb == cmds.am_ribbon(rNode, q=True, tb=True))\n\t\tprint'\\ttwLen: %s'%(expTwl == cmds.am_ribbon(rNode, q=True, tl=True))\n\t\tprint'\\tupVec: %s'%(compareVectors(expUpv, cmds.am_ribbon(rNode, q=True, up=True)))\n\t\tprint'\\tuvSca: %s'%(expUvs == cmds.am_ribbon(rNode, q=True, uv=True))\n\t\tprint'\\tuvPin: %s'%(expUvp == cmds.am_ribbon(rNode, q=True, uvp=True))\n\tprint '---TESTING EDIT AND QUERY---'\n\twid = 0.5\n\ttaper = 0.5\n\ttwistBase = -45.0\n\ttwistLength = 135.0\n\tupVec = [0,2,0]\n\tuvScale = 2.0\n\tuvPin = 1\n\tcmds.am_ribbon(ribbon, e=True, w=wid, t=taper, tb=twistBase, tl=twistLength, up=upVec, uv=uvScale, uvp=uvPin)\n\tverifyValues(0, ribbon, wid, taper, twistBase, twistLength, upVec, uvScale, uvPin)\n\tdiv = 15\n\tcmds.am_ribbon(ribbon, e=True, d=div)\n\tprint'\\tdivs: %s'%(div == cmds.am_ribbon(ribbon, q=True, d=True))\n\tdpu = 2.5\n\tcmds.am_ribbon(ribbon, e=True, dp=dpu)\n\tprint'\\tdpu: %s'%(dpu - cmds.am_ribbon(ribbon, q=True, dp=True) < 0.01)",
"def test_analytic_value_with_simple_circuit(self, differentiator, op):\n # Get an expectation op, with this differentiator attached.\n differentiator.refresh()\n op = differentiator.generate_differentiable_op(analytic_op=op)\n qubit = cirq.GridQubit(0, 0)\n circuit = util.convert_to_tensor(\n [cirq.Circuit(cirq.X(qubit)**sympy.Symbol('alpha'))])\n psums = util.convert_to_tensor([[cirq.Z(qubit)]])\n symbol_values_array = np.array([[0.123]], dtype=np.float32)\n # Calculate tfq gradient.\n symbol_values_tensor = tf.convert_to_tensor(symbol_values_array)\n with tf.GradientTape() as g:\n g.watch(symbol_values_tensor)\n expectations = op(circuit, tf.convert_to_tensor(['alpha']),\n symbol_values_tensor, psums)\n grads = g.gradient(expectations, symbol_values_tensor)\n ground_truth_grads = np.array([[-1.1839752]])\n self.assertAllClose(ground_truth_grads, grads, rtol=1e-2, atol=1e-2)"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Geotransform the original map and create an inverse geotransform for the raster. | def _get_inv_gt(self):
# Geotransform the original map
self.in_gt = self.in_ds.GetGeoTransform()
# Create an inverse geotransform for the raster.
# This converts real-world coordinates to pixel offsets.
self.inv_gt = gdal.InvGeoTransform(self.in_gt)
if gdal.VersionInfo()[0] == '1':
if self.inv_gt[0] == 1:
self.inv_gt = self.inv_gt[1]
else:
raise RuntimeError('Inverse geotransform failed')
elif self.inv_gt is None:
raise RuntimeError('Inverse geotransform failed') | [
"def geo_transform(self):\n pass",
"def makeGeoTransform(self):\n geotransform = (self.xMin, self.xRes, 0.0, self.yMax, 0.0, -self.yRes)\n return geotransform",
"def geotransform(self):\n return self._geotransform",
"def geotransform_to_affine(geot):\n c, a, b, f, d, e = list(geot)\n return rio.Affine(a, b, c, d, e, f)",
"def __affine_geo_transformation(x, y, gtr):\n\n # https://gdal.org/user/raster_data_model.html#affine-geotransform\n # Affine transformation rewritten for rasterio:\n gtr_x = gtr[2] + (x + 0.5) * gtr[0] + (y + 0.5) * gtr[1]\n gtr_y = gtr[5] + (x + 0.5) * gtr[3] + (y + 0.5) * gtr[4]\n\n return gtr_x, gtr_y",
"def apply_inverse_map(self, transport_map, sig0):\n # Check input arrays\n transport_map = check_array(transport_map, ndim=2,\n dtype=[np.float64, np.float32])\n sig0 = check_array(sig0, ndim=2, dtype=[np.float64, np.float32],\n force_strictly_positive=True)\n\n # Initialize Radon transforms\n rad0 = radon(sig0, theta=self.theta, circle=False)\n rad1 = np.zeros_like(rad0)\n\n # Check transport map and Radon transforms are the same size\n assert_equal_shape(transport_map, rad0,\n ['transport_map', 'Radon transform of sig0'])\n\n # Loop over angles\n cdt = CDT()\n for i in range(self.theta.size):\n # Convert projection to PDF\n j0 = signal_to_pdf(rad0[:,i], epsilon=1e-8, total=1.)\n\n # Radon transform of sig1 comprised of inverse CDT of projections\n rad1[:,i] = cdt.apply_inverse_map(transport_map[:,i], j0)\n\n # Inverse Radon transform\n sig1_recon = iradon(rad1, self.theta, circle=False, filter='ramp')\n\n # Crop sig1_recon to match sig0\n sig1_recon = match_shape2d(sig0, sig1_recon)\n\n return sig1_recon",
"def inv_projmap(self, img, nside=None):\n pass",
"def apply_geo_transform(one_img, one_mask, trans_mat, size):\r\n new_img = cv2.warpAffine(one_img, trans_mat, size, \r\n flags = cv2.INTER_NEAREST, # this setting is important for preserve original color space\r\n borderMode = cv2.BORDER_CONSTANT, \r\n borderValue = 255) # white background for instance image\r\n new_mask = cv2.warpAffine(one_mask, trans_mat, size, \r\n flags = cv2.INTER_NEAREST, \r\n borderMode = cv2.BORDER_CONSTANT, \r\n borderValue = 0) # black background for mask\r\n return new_img, new_mask",
"def Reproject(cls,inRaster, outRaster,EPSG):\r\n try:\r\n import gdal\r\n except:\r\n raise ImportError(\"Can not import module GDAL\")\r\n try:\r\n dataset = gdal.Open(infile)\r\n out = dataset.GetRasterBand(1)\r\n print dataset.GetMetadata()\r\n return out\r\n except:\r\n raise ImportError(\"Can not read band\")\r\n #if not tmp:\r\n # raise Exception(\"Could not orthorectify the image \")\r\n\r\n com=\" \".join([\"gdalwarp -t_srs EPSG:\"+str(EPSG),InRaster,OutRaster])\r\n tmp=os.system(com)\r\n print tmp\r\n #if not tmp:\r\n # raise Exception(\"Could not reproject the image \")\r\n #os.remove(OutRaster)\r",
"def reproject(self, lon, lat):\n if self.xform is None:\n # if the CRS hasn't been determined yet, we set it from the first image's lat/lon (take the UTM crs)\n utm_i = str(int(math.floor((self.images[0].lon + 180) / 6 ) % 60) + 1).zfill(2)\n epsg_code = int('326' + utm_i) if (self.images[0].lat >= 0) else int('327' + utm_i)\n self.crs_dest = QgsCoordinateReferenceSystem(epsg_code)\n self.xform = QgsCoordinateTransform(self.crs_src, self.crs_dest, QgsProject.instance())\n return self.xform.transform(QgsPointXY(lon, lat))",
"def _build_geotransform(self, i, j):\n assert isinstance(i, int), (\"i is not an integer\")\n assert isinstance(j, int), (\"j is not an integer\")\n x_origin, x_res, x_ignore, y_origin, y_ignore, y_res = (\n self.image_metadata.geotransform)\n # integer conversion to reduce floating point error\n new_x_origin = self._calculate_origin(x_origin, x_res, self.offset, j)\n new_y_origin = self._calculate_origin(y_origin, y_res, self.offset, i)\n geotransform = (new_x_origin, x_res, x_ignore, new_y_origin, \n y_ignore, y_res) \n return geotransform",
"def test_30_supergeom_translate(self):\n proj = 'CAR'\n ra0, dec0 = CRVAL\n res = 0.01 * DEG\n wcs = coords.get_wcs_kernel(proj, ra0, dec0, res)\n\n wcs.wcs.crpix = (60, 70)\n map0 = enmap.zeros((100,200), wcs=wcs)\n map0[2, 3] = 10.\n map0[90, 192] = 11.\n\n # Extracts.\n m1 = map0[:10,:10]\n m2 = map0[-10:,-10:]\n\n # In simple cylindrical projections, there's a degeneracy\n # between crval and crpix in the longitude component -- crval\n # can be anywhere on the equator. It is useful to be able to\n # join maps even if they have different crval[0], provided the\n # pixel centers line up. (The same is not true of crval[1],\n # which tips the native equator relative to the celestial\n # equator.)\n\n for axis, should_work in [(0, True), (1, False)]:\n dpix = 10.5\n m2 = map0[-10:,-10:]\n m2.wcs.wcs.crpix[axis] += dpix\n m2.wcs.wcs.crval[axis] += dpix * m2.wcs.wcs.cdelt[axis]\n\n if should_work:\n sg = coords.get_supergeom((m1.shape, m1.wcs), (m2.shape, m2.wcs))\n mapx = enmap.zeros(*sg)\n mapx.insert(m1)\n mapx.insert(m2)\n self.assertTupleEqual(map0.shape, mapx.shape,\n msg=\"Reconstructed map shape.\")\n self.assertTrue(np.all(mapx==map0),\n msg=\"Reconstructed map data.\")\n\n else:\n msg = \"Translating crval in dec should cause \"\\\n \"coord consistency check failure.\"\n with self.assertRaises(ValueError, msg=msg):\n sg = coords.get_supergeom((m1.shape, m1.wcs), (m2.shape, m2.wcs))",
"def reproject_GeoGrid(geogrid_in, srs_string,\n out_xdim=None, out_ydim=None, out_geotransform=None,\n out_nodata_value=None, interp_method=None):\n src = geogrid_as_gdalInMem(geogrid_in)\n\n out_srs = osr.SpatialReference()\n assign_projection_to_srs(out_srs, srs_string)\n out_wkt = out_srs.ExportToWkt()\n\n dst_gdal_datatype = get_gdal_datatype(geogrid_in.data_array.dtype)\n\n try:\n dst = gdal.GetDriverByName('MEM').Create(\n '',\n out_xdim,\n out_ydim,\n 1,\n dst_gdal_datatype,\n )\n dst.SetGeoTransform(out_geotransform)\n dst.SetProjection(out_wkt)\n except ValueError:\n raise ValueError('Error creating dst in reproject_GeoGrid()')\n except AttributeError:\n raise ValueError('AttributeError in dst creation')\n\n\n gdal_interp_method = getGdalInterpMethod(interp_method)\n res = gdal.ReprojectImage(src,\n dst,\n src.GetProjection(),\n dst.GetProjection(),\n gdal_interp_method,\n )\n\n\n return geogrid_from_gdalInMem(dst)",
"def get_geotransform(dem_par):\n return dem_par.corner_east, dem_par.post_east, 0, dem_par.corner_north, 0, dem_par.post_north",
"def reproject(geom, from_epsg, to_epsg):\n # Note: this is currently only accurate for the U.S.\n source = osr.SpatialReference()\n source.ImportFromEPSG(from_epsg)\n\n target = osr.SpatialReference()\n target.ImportFromEPSG(to_epsg)\n\n transform = osr.CoordinateTransformation(source, target)\n\n geom.Transform(transform)\n\n return geom",
"def _affine(self):\n from rasterio.transform import from_origin\n affine = from_origin(self.grid.cloud.data.min[0], self.grid.cloud.data.max[1], self.grid.cell_size, self.grid.cell_size)\n return affine",
"def inverse_warp_wrapper(matrix):\n warp_image, _ = (\n project.inverse_warp(\n tf.expand_dims(base_warping, axis=0),\n tf.expand_dims(target_depth[batch_s], axis=0),\n tf.expand_dims(matrix, axis=0),\n tf.expand_dims(self.intrinsic_mat[\n batch_s, selected_scale, :, :], axis=0),\n tf.expand_dims(self.intrinsic_mat_inv[\n batch_s, selected_scale, :, :], axis=0)))\n return warp_image",
"def XPLMMapUnproject(projection,\n mapX, mapY,\n outLatitude, outLongitude):\n pass",
"def geotransform(self):\n return self.dataset.GetGeoTransform() if self.dataset else None"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
get clip location in array. | def _get_clip_loc_in_array(self):
# coordinates of upperleft and lowerright points of binding box
box_ulx, box_uly, box_lrx, box_lry = self.clip_box[0][0], self.clip_box[0][1], \
self.clip_box[1][0], self.clip_box[1][1]
# Get the offsets that correspond to the bounding box corner coordinates.
offsets_ul = gdal.ApplyGeoTransform(self.inv_gt, box_ulx, box_uly)
offsets_lr = gdal.ApplyGeoTransform(self.inv_gt, box_lrx, box_lry)
# The offsets are returned as floating point, but we need integers.
self.off_ulx, self.off_uly = map(int, offsets_ul)
self.off_lrx, self.off_lry = map(int, offsets_lr)
# Compute the numbers of rows and columns to extract, based on the offsets.
self.row = self.off_lry - self.off_uly
self.column = self.off_lrx - self.off_ulx | [
"def clip(self):\r\n\t\treturn self._clip",
"def get_marker_absolute_pos(marker_position, clip):\n marker_x = (marker_position[\"x\"] * clip.w) - marker_image.w / 2\n marker_y = (marker_position[\"y\"] * clip.h) - marker_image.h / 2\n return marker_x, marker_y",
"def location_of(self, index):\n img_w, img_h = self.conv_dims()\n \n x = (index % img_w) * self.stride\n y = (index // img_w) * self.stride\n \n return x, y",
"def origin(self):\n slices = self.slices_large\n return np.array([slices[0].start, slices[1].start])",
"def get_roi_coords(self, roi):\n if self.is_4d():\n data = self._data[..., self._time_point]\n else:\n data = self._data\n coord = (data==roi).nonzero()\n #return (data==roi).nonzero()\n return (coord[1], self._y_shift - coord[0], coord[2])",
"def get_clip(self, idx):\n if idx >= self.num_clips():\n raise IndexError(\"Index {} out of range \"\n \"({} number of clips)\".format(idx, self.num_clips()))\n video_idx, clip_idx = self.get_clip_location(idx)\n video_path = self.video_paths[video_idx]\n clip_pts = self.clips[video_idx][clip_idx]\n\n # from torchvision import get_video_backend\n backend = 'pyav' #xiaodan: hard coded to be pyav\n\n if backend == \"pyav\":\n # check for invalid options\n if self._video_width != 0:\n raise ValueError(\"pyav backend doesn't support _video_width != 0\")\n if self._video_height != 0:\n raise ValueError(\"pyav backend doesn't support _video_height != 0\")\n if self._video_min_dimension != 0:\n raise ValueError(\"pyav backend doesn't support _video_min_dimension != 0\")\n if self._audio_samples != 0:\n raise ValueError(\"pyav backend doesn't support _audio_samples != 0\")\n\n if backend == \"pyav\":\n start_pts = clip_pts[0].item()\n end_pts = clip_pts[-1].item()\n video, audio, info = read_video(video_path, start_pts, end_pts)\n else:\n info = _probe_video_from_file(video_path)\n video_fps = info[\"video_fps\"]\n audio_fps = None\n\n video_start_pts = clip_pts[0].item()\n video_end_pts = clip_pts[-1].item()\n\n audio_start_pts, audio_end_pts = 0, -1\n audio_timebase = Fraction(0, 1)\n if \"audio_timebase\" in info:\n audio_timebase = info[\"audio_timebase\"]\n audio_start_pts = pts_convert(\n video_start_pts,\n info[\"video_timebase\"],\n info[\"audio_timebase\"],\n math.floor,\n )\n audio_end_pts = pts_convert(\n video_end_pts,\n info[\"video_timebase\"],\n info[\"audio_timebase\"],\n math.ceil,\n )\n audio_fps = info[\"audio_sample_rate\"]\n video, audio, info = _read_video_from_file(\n video_path,\n video_width=self._video_width,\n video_height=self._video_height,\n video_min_dimension=self._video_min_dimension,\n video_pts_range=(video_start_pts, video_end_pts),\n video_timebase=info[\"video_timebase\"],\n audio_samples=self._audio_samples,\n audio_pts_range=(audio_start_pts, audio_end_pts),\n audio_timebase=audio_timebase,\n )\n\n info = {\"video_fps\": video_fps}\n if audio_fps is not None:\n info[\"audio_fps\"] = audio_fps\n\n if self.frame_rate is not None:\n resampling_idx = self.resampling_idxs[video_idx][clip_idx]\n if isinstance(resampling_idx, torch.Tensor):\n resampling_idx = resampling_idx - resampling_idx[0]\n video = video[resampling_idx]\n info[\"video_fps\"] = self.frame_rate\n assert len(video) == self.num_frames, \"{} x {}\".format(video.shape, self.num_frames)\n return video, audio, info, video_idx",
"def ArrayCoords(self) :\n \n def GetX(i,j) : \n return self.Extent.Xmin+((j)*self.PixelShape[0])+0.5*self.PixelShape[0]\n def GetY(i,j) : \n return self.Extent.Ymax-((i)*self.PixelShape[1])-0.5*self.PixelShape[1]\n\n X = np.fromfunction(GetX,self.shape,dtype=float)\n Y = np.fromfunction(GetY,self.shape,dtype=float)\n return SpArray(X,self.Src,self.Extent.List()),SpArray(Y,self.Src,self.Extent.List())",
"def player_location(self):\n x = 0\n y = 0\n for line in self.grid:\n for i in line:\n if i == \"P\":\n return x, y\n \n y+=1\n x += 1\n y = 0",
"def coords(self):\n if self._mask is not None:\n return self._coords[np.where(self._mask == 1)]\n return self._coords",
"def cursor_on_image_pixcoords_and_value(self, p):\n #p = self.mapToScene(e.pos())\n ix, iy = int(floor(p.x())), int(floor(p.y()))\n v = None\n arr = self.arr\n if ix<0\\\n or iy<0\\\n or iy>arr.shape[0]-1\\\n or ix>arr.shape[1]-1: pass\n else: v = self.arr[iy,ix]\n return ix, iy, v",
"def pos(self):\n x = (self.ec._win._mouse_x -\n self.ec._win.width / 2.) / (self.ec._win.width / 2.)\n y = (self.ec._win._mouse_y -\n self.ec._win.height / 2.) / (self.ec._win.height / 2.)\n return np.array([x, y])",
"def coordinates(self, mask):\n y,x = mask.nonzero()\n return list(zip(x,y))",
"def get_origin(array, plot_origin):\n if plot_origin:\n return array.origin\n else:\n return None",
"def get_coords(self, cell):\n\n coords = (-1, -1)\n\n for i in self.laberinto:\n if self.laberinto[i] is cell:\n coords = (i[0], i[1])\n break\n \n return coords",
"def get_local_xy(self, chip):",
"def get_prev_clip(self, wrap=False, allow_gaps=True):\n clips = self.track.clips\n index = clips.index(self)\n clip_range = []\n for n in range(index, len(clips)):\n if clips[n] is None:\n if not allow_gaps:\n break\n else:\n clip_range.append(clips[n])\n for n in reversed(list(range(0, index))):\n if clips[n] is None:\n if not allow_gaps:\n break\n else:\n clip_range.insert(0, clips[n])\n\n index = clip_range.index(self)\n prev_index = index - 1\n if wrap and prev_index < 0:\n prev_index += len(clip_range)\n if prev_index >= 0:\n return clip_range[prev_index]\n return None",
"def where_to_crop(self):\n \n\n self.show()\n crop_window = plt.ginput(2)\n x1 = int(crop_window[0][0])\n x2 = int(crop_window[1][0])\n y1 = int(crop_window[0][1])\n y2 = int(crop_window[1][1])\n\n return (x1, x2, y1, y2)",
"def scenicToWebotsPosition(pos, y=0):\n x, z = pos\n return [x, y, -z]",
"def __get_position(self, value, state):\n coords = np.argwhere(state == value).flatten()\n return coords"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Calcul de la division de deux polynomes A / B Retourne [Q,R] le quotient et le reste de telle façon que A = BQ+R | def polydiv(A,B):
Q = [0] # quotient
R = A # reste
while (polydegre(R) >= polydegre(B)):
#print ("degre R = {}".format(polydegre(R)))
#print ("degre B = {}".format(polydegre(B)))
P = monome(R[polydegre(R)],polydegre(R)-polydegre(B))
#print ("P = {}".format(P))
R = polysomme(R,polyproduit(polymul(-1,P),B))
#print ("R = {}".format(R))
Q = polysomme(Q,P)
#print ("Q = {}".format(Q))
#raw_input()
return Q,R | [
"def division(self, first_value, second_value):",
"def exquo(self, a, b):\n return a / b",
"def get_divide_ab(a, b): # IN= 2'int' / OUT= 1'foat'\n return float(a/b)",
"def division(self, a, b):\n if not check_arguments(a, b): # check if arguments are numbers\n self.last_result = a / b",
"def div(self):\n a = self.nums()\n x = LibraryFunctions.per(a, 0.9) - LibraryFunctions.per(a, 0.1)\n return x / 2.58",
"def division(operand1, operand2):\n return operand1/operand2",
"def divide(self, a, b):\n return a / b",
"def divr(a, b):\n if b < 0: (a, b) = (-a, -b)\n if a < 0:\n a = -a\n return -int((a + a + b) // (b + b))\n else:\n return int((a + a + b) // (b + b))",
"def divide_a_b(self, a, b):\n return a / b",
"def old_div(a, b):\n if isinstance(a, numbers.Integral) and isinstance(b, numbers.Integral):\n return a // b\n else:\n return a / b",
"def div(a, b):\r\n if type(b) in inttypes_set:\r\n if not b:\r\n return Infinity(a)\r\n raise ZeroDivisionError('%r / %r' % (a, b))\r\n if b == 1:\r\n return a\r\n if type(a) in inttypes_set:\r\n return normalized_fraction(a, b)\r\n return a / b",
"def dividir(self):\n self.resultado = self.valor_1 / self.valor_2",
"def divide_by(q_1: Q, q_2: Q) -> Q:\n\n q_1.check_representations(q_2)\n\n end_q_type = f\"{q_1.q_type}/{q_2.q_type}\"\n\n q_div = product(q_1, inverse(q_2))\n q_div.q_type = end_q_type\n q_div.representation = q_1.representation\n\n return q_div",
"def div_numbers(a: int, b: int) -> int:\n return a / b",
"def ratio_func(a, b):\n return a / b",
"def divide(num1, num2):\n return float(num1) / float(num2)",
"def div_roundup(self,a, b):\r\n return (int(a) + int(b) - 1) / int(b)",
"def divide(numerator, denominator):\n ensure_divisibility(numerator, denominator)\n return numerator // denominator",
"def divide(num1, num2):\n return num1 / num2"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Unique class is stored as self.unique_class. Total number of classes is stored as self.total_classes_number. Total number of each class is stored in self.class_number_dict. Total number of unique words is stored as self.unique_word_number. Total number of a word in a class is stored in self.class_word_number_dict. otal number of a word in a class is stored in self.class_total_words_dict. | def __init__(self):
self.unique_classes = []
self.total_classes_number = 0
self.class_number_dict = {}
self.unique_word_number = 0
self.class_word_number_dict = {}
self.class_total_words_dict = {} | [
"def classInfo(self):\n n = len(self.data.instances)\n sum = 0\n classDic = {}\n className = self.data.className\n # Count the occurances of all class values\n for entry in self.data.instances:\n if entry[className] not in classDic.keys():\n # Class value not yet added\n classDic[entry[className]] = 1\n else:\n num = classDic[entry[className]]\n classDic[entry[className]] = num + 1\n\n # Calculate information\n for key in classDic.keys():\n x = float(classDic[key])/float(n)\n sum -= x*log(x, 2)\n\n return sum",
"def teach_classifier(self):\n for i in self.used_classes:\n self.teach_one_class(i)\n self.all_words_count = 0\n for i in self.words_count.keys():\n self.all_words_count += self.words_count[i]",
"def _count_classes_in_selected_feat(self)->None:\n _uniqueClasses = set(self._expresion_calculator('value'))\n self._uniqueClasses = _uniqueClasses\n self._numberOfUniqueClasses = len(_uniqueClasses)",
"def create_class_dict(self):\r\n self.class_dict = {label: idx for idx,\r\n label in enumerate(sorted(set(self.dataset['y'])))}",
"def wordclasses(self):\n for corpus in self:\n corpus.wordclasses",
"def classes_(self, y):\n self._classes = np.unique(y).shape[0]",
"def classFreqCounter(data, classes):\n classCounts = [0] * 16\n for key in data.keys():\n for i, classy in enumerate(classes):\n if classy == data[key][0]:\n classCounts[i] += 1\n for i, n in enumerate(classCounts):\n if n == 0:\n classCounts[i] = 1\n CLASSSMOOTHING =+ 1\n return classCounts",
"def get_current_class_summary(self):\n class_summary ={}\n for detection in self.detections:\n classification=np.argmax(detection.class_score)\n class_summary[classification]=class_summary.get(classification,0)+1\n return class_summary",
"def summarize_classes(classes):\n u, indices = np.unique(classes,return_inverse=True)\n num_u=len(u)\n print(\"****************************\")\n print(\"Number of samples: {0}\".format(len(classes)))\n print(\"Number of Classes:{0}\".format(num_u))\n for c in u:\n num_c=np.sum(classes==c)\n print(\"Class {0}: {1} Samples\".format(c,num_c))\n print(\"****************************\")",
"def get_class_counts(self, n_classes, log=True):\n if log:\n self.log(\"Counting class occurrences across {} loaded samples...\"\n .format(self.n_loaded))\n counts = {i: 0 for i in range(n_classes)}\n _, y = self.get_all_periods(stack=True)\n cls_ints, cls_counts = np.unique(y, return_counts=True)\n for cls_int, cls_count in zip(cls_ints, cls_counts):\n counts[cls_int] += cls_count\n cls, counts = zip(*counts.items())\n if log:\n self.log(\"Classes: {}\\n\"\n \"Counts: {}\".format(cls, counts))\n return cls, counts",
"def class_distribution(self):\n total_particles = self.number_of_particles()\n unique_classes = self.unique_classes()\n\n particles_per_class = {}\n percentage_per_class = {}\n\n for class_idx in unique_classes:\n particles_per_class[class_idx] = np.sum(self['ref'] == class_idx)\n percentage_per_class[class_idx] = 100 * (particles_per_class[class_idx] / total_particles)\n\n return particles_per_class, percentage_per_class",
"def classesAndFrames(self):\n classes = defaultdict(int)\n with open(self.inputfile) as fin:\n for line in fin:\n arr = line.strip().split()\n y = int(arr[1])\n classes[y] += 1\n return classes",
"def nr_classes(self):\n return self._nr_classes",
"def get_classes(self):\n if self.include_unseen_class and self.fill_unseen_labels:\n return np.append(self.classes_, [self.fill_label_value])\n\n return self.classes_",
"def get_class_distribution(self):\n class_distribution = np.zeros(len(self.training_set.classes))\n for i, batch in enumerate(self.train_loader, 0):\n for label in batch[1]:\n class_distribution[label] += 1\n class_distribution /= len(self.labelled_idx)\n\n return class_distribution.tolist()",
"def _calc_prob_class(self, clazz):\n clazz_count = self.training_set.get_label_value_counts()[clazz]\n return float(clazz_count) / self.training_set.num_samples()",
"def make_classdict(self):\n\t\ttarget_names = self.fetched[\"train\"].target_names\n\t\tself.classdict = {target_names[idx]: idx for idx in range(len(target_names))}",
"def class_label_statistics(self, X, y):\n unique, counts= np.unique(y, return_counts= True)\n self.class_stats= dict(zip(unique, counts))\n self.minority_label= unique[0] if counts[0] < counts[1] else unique[1]\n self.majority_label= unique[1] if counts[0] < counts[1] else unique[0]",
"def classify(self, words):\n\t# Write code here\n\tfemaleProb = 0.0\n\tmaleProb = 0.0\n\tallDocumentCount = sum(self.classCounts.values())\n\n\n\tfemaleProb += math.log(self.classCounts['female']) - math.log(allDocumentCount) #class probabilities\n\tmaleProb += math.log(self.classCounts['male']) - math.log(allDocumentCount)\n\n\tif self.BOOLEAN_NB:\n\t\t\n\t\t#do boolean naive bayes\n\t\tnoDuplicates = []\n\t\tfor i in words:\n\t\t\tif i not in noDuplicates:\n\t\t\t\tnoDuplicates.append(i)\n\t\twords = noDuplicates[:]\n\n\t\ttempfemale = math.log(self.binaryTotalCount['female'] + len(self.allWords))\n\t\ttempmale = math.log(self.binaryTotalCount['male'] + len(self.allWords))\n\t\tfor word in words:\n\t\t\tfemaleProb += math.log(self.binaryWordCounts['female'][word] + 1)\n\t\t\tfemaleProb -= tempfemale\n\n\t\t\tmaleProb += math.log(self.binaryWordCounts['male'][word] + 1)\n\t\t\tmaleProb -= tempmale\n\n\n\telif self.BEST_MODEL:\n\t\tnoDuplicates = []\n\t\tfor i in words:\n\t\t\tif i not in noDuplicates:\n\t\t\t\tnoDuplicates.append(i)\n\t\twords = noDuplicates[:]\n\t\ttempfemale = math.log(self.binaryTotalCount['female'] + 5*len(self.allWords))\n\t\ttempmale = math.log(self.binaryTotalCount['male'] + 5*len(self.allWords))\n\n\t\tfor word in words:\n\t\t\tfemaleProb += math.log(self.binaryWordCounts['female'][word] + 5)\n\t\t\tfemaleProb -= tempfemale\n\n\t\t\tmaleProb += math.log(self.binaryWordCounts['male'][word] + 5)\n\t\t\tmaleProb -= tempmale\n\n\t\t#personal heuristics\n\n\telse:\n\t\tif (self.FILTER_STOP_WORDS):\n\t\t\twords = self.filterStopWords(words)\n\t\t#regular naive bayes\n\n\t\ttempfemale = math.log(self.totalCount['female'] + len(self.allWords))\n\t\ttempmale = math.log(self.totalCount['male'] + len(self.allWords))\n\t\tfor word in words:\n\n\t\t\tfemaleProb += math.log(self.wordCounts['female'][word] + 1) #one-add smoothing\n\t\t\tfemaleProb -= tempfemale\n\n\t\t\tmaleProb += math.log(self.wordCounts['male'][word] + 1) #one-add smoothing\n\t\t\tmaleProb -= tempmale #denominator\n\n\n\tif femaleProb >= maleProb:\n\t\treturn 'female'\n\n\treturn 'male'"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Updates a testing scenario. | def put(self, id):
data = request.json
update_scenario(id, data)
return None, 204 | [
"def test_update_scenario(self):\n pass",
"def update_test_case(self, project, test_case):\n location = {\"item\": test_case.get_parent_id(project)}\n fields = self.assemble_add_update_fields(test_case)\n\n # print(\"Current fields: \", json.dumps(self.jama_client.get_abstract_items(\n # project=[test_case.get_project_id(project)],contains=[test_case.get_test_case_id(project)]), indent=4))\n # print(\"New fields: \", json.dumps(fields, indent=4))\n\n # Call API to update test case\n self.spinner.start(\"Updating test case \" + test_case.name + \" in project \" + project + \" from Jama API\")\n try:\n output = self.jama_client.put_item(test_case.get_project_id(project),\n test_case.get_test_case_id(project),\n self.default_test_case_type,\n self.default_test_case_type,\n location,\n fields)\n except Exception as e:\n print(\"\\n\" + str(e))\n return -1\n self.spinner.stop()\n\n return output",
"def editScenario(self, new_scenario):\n scenario_name = new_scenario[\"scenario_name\"]\n if scenario_name in self.scenarios_dict:\n new_scenario = Scenario(scenario_name).objectFromDictionary(new_scenario)\n self.scenarios_dict[scenario_name] = new_scenario\n self._saveScenarioAsJSON(new_scenario)\n return {\"Response\": True, \"Note\": \"Operation successful\", \"Body\": dict()}\n else:\n return {\"Response\": False, \"Note\": \"Scenario doesn't exist\", \"Body\": dict()}",
"def updateTestRun(self,test_run_id,payload,verbose=False):\r\n # payload = all editable fields + updated fields\r\n resources = \"testruns/%s\"%test_run_id\r\n url = self.base_url + resources\r\n response = requests.put(url, json=payload,auth=(self.username, self.password))\r\n if verbose:\r\n print (response.text)\r\n\r\n return response.status_code",
"def test_story_update(self):\n self.login(admin=True)\n story = self.stories.values()[0]\n new_blurb = story.blurb * 2 if story.blurb else \"Yatcha!\"\n url = reverse('bulletin:plugins:api:story-detail',\n kwargs={'pk': story.id})\n\n # GET to get all fields:\n response = self.client.get(url)\n self.assertEqual(response.status_code, status.HTTP_200_OK,\n response.content)\n\n story_json = json.loads(response.content)\n story_json['blurb'] = new_blurb\n\n response = self.client.put(url, story_json, format='json')\n self.assertEqual(response.status_code, status.HTTP_200_OK,\n response.content)\n\n # We have a dirty story.\n story = Story.objects.get(pk=story.id)\n self.assertEqual(story.blurb, new_blurb)",
"def test_update_case(self):\n pass",
"def put(self, request):\n\n data = request.data\n test_id = data['test_id']\n data.pop(\"test_id\")\n test_data = UserTestHistory.objects.filter(id=test_id)\n\n try:\n test_data.update(**data)\n LOGGER.info(\"Test data updated successfully\")\n return Response({\"status\": \"SUCCESS\", \"message\": \"Record updated successfully\"})\n except Exception, error:\n LOGGER.error(\"Error:%s\", str(error))\n return Response({\"status\": \"FAILED\", \"message\": str(error)})",
"def test_cases_update(self):\n pass",
"def test_partially_update_study(self):\n\n description: str = self.patient1_study.description\n payload = {\n \"description\": \"PAIN IN KNEE\",\n }\n\n # Happy path!\n response = self.client.patch(\n f\"{self.api_url}/{self.patient1_id}/studies/{self.patient1_study.id}/\",\n payload,\n format=\"json\",\n )\n self.assertEqual(response.status_code, status.HTTP_200_OK)\n self.patient1_study.refresh_from_db()\n self.assertNotEqual(self.patient1_study.description, description)",
"def update(self, expectation_suite: es.ExpectationSuite) -> es.ExpectationSuite:\n _client = client.get_instance()\n path_params = [\n \"project\",\n _client._project_id,\n \"featurestores\",\n self._feature_store_id,\n \"featuregroups\",\n self._feature_group_id,\n \"expectationsuite\",\n expectation_suite.id,\n ]\n\n headers = {\"content-type\": \"application/json\"}\n payload = expectation_suite.json()\n\n major, minor = self._variable_api.parse_major_and_minor(\n self._variable_api.get_version(\"hopsworks\")\n )\n method = \"PUT\"\n if major == \"3\" and minor == \"0\":\n method = \"POST\"\n del path_params[-1]\n\n return es.ExpectationSuite.from_response_json(\n _client._send_request(method, path_params, headers=headers, data=payload)\n )",
"def test_update(self):\n pass",
"def test_update_survey(self):\n pass",
"def updateScenario(self, scenario):\n\n if not scenario:\n return\n\n for limb in ['lp', 'rp', 'lm', 'rm']:\n for entry in scenario.entries[limb]:\n if entry:\n uid = entry['uid']\n scenario.setProps(uid, self.getTokenProps(uid))",
"def test_update_workflow_step(self):\n pass",
"def test_update(self):\n # this is tested graphically, as it is UI\n pass",
"def update():\n from peltak_gitflow import logic\n logic.feature.update()",
"def test_update_story_by_id(self):\n pass",
"def test_unit_update(self):\n pass",
"def test_update_goal(self):\n pass"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.