query
stringlengths
10
2k
document
stringlengths
20
51.2k
metadata
dict
negatives
listlengths
0
101
negative_scores
listlengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Set the value of the APIKey input for this Choreo. ((optional, string) The API Key provided by NY Times.)
def set_APIKey(self, value): super(SearchByReviewerInputSet, self)._set_input('APIKey', value)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def SetAPIKey(self, api_key):\n self._api_key = api_key", "def SetAPIKey(self, api_key):\n self._api_key = api_key", "def SetAPIKey(self, api_key):\n self._analyzer.SetAPIKey(api_key)", "def api_key(self, api_key):\n if api_key is None:\n raise ValueError(\"Invalid value for `api_k...
[ "0.77387947", "0.77387947", "0.7587758", "0.71944374", "0.7136153", "0.70880574", "0.7001859", "0.69529235", "0.6687989", "0.6601706", "0.64967805", "0.64608306", "0.64570075", "0.63793164", "0.6373244", "0.6292642", "0.62844735", "0.6282609", "0.6260015", "0.6256157", "0.617...
0.61704254
21
Set the value of the ReviewerName input for this Choreo. ((required, string) The name of the Times reviewer. Reviewer names should be separated by hyphens or dots (i.e. manohladargis or manohla.dargis).)
def set_ReviewerName(self, value): super(SearchByReviewerInputSet, self)._set_input('ReviewerName', value)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reviewer(self, reviewer):\n if not reviewer:\n return\n\n from stalker import User\n\n if not isinstance(reviewer, User):\n raise TypeError(\n \"%s.reviewer should be a stalker.User instance, not %s\"\n % (self.__class__.__name__, reviewe...
[ "0.6245886", "0.5918811", "0.578188", "0.56552565", "0.5481406", "0.5441441", "0.5341635", "0.52642256", "0.52642256", "0.52589244", "0.5250935", "0.5175454", "0.5168574", "0.51138186", "0.5109259", "0.51083016", "0.51083016", "0.50942504", "0.50942504", "0.50942504", "0.5094...
0.7220515
0
Retrieve the value for the "Response" output from this Choreo execution. (The response from the NY Times API.)
def get_Response(self): return self._output.get('Response', None)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_response_variable(self):\n\n return self._response_variable", "def response(self):\n return self._response", "def via_response(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"via_response\")", "def get_response(self):\n result = self.get_response_impl()\n i...
[ "0.67832524", "0.6713529", "0.6577414", "0.6567829", "0.62352496", "0.6215768", "0.621474", "0.61595434", "0.61595434", "0.60139096", "0.6008604", "0.59807426", "0.59376436", "0.5929515", "0.59226876", "0.5870433", "0.5854762", "0.58522713", "0.5850179", "0.58175653", "0.5813...
0.80775344
2
Clean subdomains URLs from noise
def clean(self, urls: List[str]) -> List[str]: subdomains = [] regexp = re.compile(r'(.+://)?(?P<subdomain>(.+)\.{domain})([/?].*)?'.format(domain=self.domain)) for url in urls: match = regexp.match(url) if match and match.group('subdomain'): subdomains.ap...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clean_url(url):\n for noisy_url in noisy_urls:\n url = str(url).replace(noisy_url,\"\").lower()\n return url", "def test_url_subdomain(self):\n subdomains = ct.url_subdomain(\"https://www.bad-actor.services/some/url-thats-long?debug=True\")\n assert isinstance(subdomains, list)\n ...
[ "0.6879082", "0.6852759", "0.67351955", "0.67256755", "0.6666723", "0.6662804", "0.6647166", "0.65970427", "0.65848655", "0.6574983", "0.6569764", "0.6500797", "0.6455961", "0.6436851", "0.6433743", "0.63982385", "0.63818985", "0.6351518", "0.6317288", "0.6311543", "0.6299008...
0.7245642
0
Constructs attributes for player object.
def __init__(self, matches, number, start_date=None, end_date=None): self.matches = matches self.number = number self.start_date = start_date self.end_date = end_date
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_player_attributes(self):\n return Player_Attributes.read_by_player_fifa_api_id(self.player_fifa_api_id)", "def __init__(self, player_name, player_number, player_position):\n self.name = player_name\n self.number = player_number\n self.position = player_position", "def __init...
[ "0.6942275", "0.6776699", "0.64388436", "0.64347607", "0.6352521", "0.63279426", "0.62725", "0.6267806", "0.6186295", "0.61789167", "0.61532885", "0.61439395", "0.6136233", "0.60524255", "0.60478574", "0.6020383", "0.6014765", "0.5999839", "0.59777784", "0.59264416", "0.59179...
0.0
-1
Tries to get a value from the ``root`` section dict_props by the given key.
def get(self, key): if key in self.sections: return self.sections[key] return self['root'].get(key)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get(self, key):\n\n return self.dict_props.get(key)", "def get(key, nodename=None):\n return _get_property(key, nodename, None)", "def __getitem__(self, key):\n if self._root:\n node = self._getItemHelper(key, self._root)\n if node:\n return node.value\...
[ "0.6595018", "0.62437546", "0.6227237", "0.618648", "0.61702305", "0.61613923", "0.6096253", "0.60777193", "0.6034422", "0.60072714", "0.5981619", "0.5957917", "0.5951381", "0.5934923", "0.59291834", "0.59224856", "0.58800465", "0.5866384", "0.58548206", "0.5840659", "0.58342...
0.68412346
0
Returns the string representation of a magic card. The is the Discord way to bolden the text
def __str__(self): # Power/toughness, seen only if it's a creature pt = "" if "power" in self: pt = "{0}/{1}".format(self.power, self.toughness).replace("*", "\*") # Append loyalty to the end of oracle text if the creature is a # plan...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def as_string(self):\n # Remove cards which have no definition\n cards = [card for card in self if card.definition is not None]\n # Remove cards which have no word\n cards = [card for card in cards if card.word]\n return \"\\n\".join([card.get_flashcard() for card in cards])", ...
[ "0.70162404", "0.6829488", "0.67666095", "0.66929746", "0.66929746", "0.655762", "0.65460056", "0.64103186", "0.64103186", "0.63990885", "0.63924026", "0.63392454", "0.63177973", "0.6309924", "0.6296143", "0.6280601", "0.62713593", "0.62214816", "0.62168616", "0.6212437", "0....
0.5597956
66
Converts a dict into a readable, discord compatible string.
def _format_dict(self, dict): result = "" for k, v in dict.items(): result += "\n{0}: {1}".format(k.capitalize(), v) return result
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_dict_str(d: dict) -> str:\n\treturn str({str(u): str(v) for u, v in d.items()})", "def _dict_to_string(self, dictionary):\n st = ''\n for i in range(len(dictionary)):\n st = st + dictionary[i]\n return st", "def _to_string(self) -> str:\n\n string_list = []\n ...
[ "0.6898656", "0.6635359", "0.6507951", "0.64386535", "0.62157017", "0.6158456", "0.61575603", "0.6125002", "0.6106262", "0.6040144", "0.6039242", "0.60046977", "0.5973235", "0.5908561", "0.58530635", "0.58222765", "0.58170915", "0.57562983", "0.57201576", "0.57032204", "0.569...
0.5800903
17
Iterates over the features of the represented guild. This method is an iterable generator. Yields
def iter_features(self): features = self.features if (features is not None): yield from features
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __iter__(self):\n for feature in self.features:\n yield feature", "async def guild_features(event):\n guild = event.guild\n \n return Embed(\n f'{guild.name}\\'s features',\n ', '.join(sorted(feature.name for feature in guild.iter_features())),\n ).add_thumbnail(\n...
[ "0.70114076", "0.7007166", "0.6814751", "0.6241392", "0.60681885", "0.6040989", "0.59794235", "0.5976737", "0.5967567", "0.5958279", "0.59558195", "0.59321105", "0.59033954", "0.587633", "0.58179486", "0.5814259", "0.57846963", "0.57543933", "0.5733956", "0.57124454", "0.5658...
0.7453079
0
Clip turtle to window
def clip(t): x, y = t.pos() nx = ny = None if x > W / 2: nx = W / 2 elif x < -W / 2: nx = -W / 2 if y > H / 2: ny = H / 2 elif y < -H / 2: ny = -H / 2 if nx is not None: t.setx(nx) if ny is not None: t.sety(ny)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cover_button(self):\r\n t = turtle.Turtle()\r\n t.hideturtle()\r\n t.speed(20)\r\n t.penup()\r\n t.goto(190,-260)\r\n t.setheading(0)\r\n t.color(\"#696969\")\r\n t.pendown()\r\n t.begin_fill()\r\n for y in range(2):\r\n t.forward...
[ "0.6046278", "0.5930236", "0.5876504", "0.5812648", "0.5797123", "0.57065254", "0.56050473", "0.54476386", "0.5442136", "0.5427694", "0.5366388", "0.5338522", "0.53171736", "0.5311554", "0.5288097", "0.5276431", "0.52452725", "0.5231284", "0.5220381", "0.521923", "0.52183264"...
0.5647425
6
Get the relative coordinate of the rightmost edge.
def get_rightmost_edge(self): return self.offset + sum(self.get_screen_widths())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def right(self):\n return self.points['topRight'].x", "def right(self):\n return self.points['topRight'].x", "def right(self):\n return self.left + self.width", "def _rect_right(self):\n\treturn max(self.x, self.x + self.w)", "def topRightCorner(self):\n self._updateExtents()\n ...
[ "0.81333846", "0.81333846", "0.7658497", "0.7583238", "0.7544025", "0.74900025", "0.7464206", "0.7337823", "0.728127", "0.72477967", "0.72196615", "0.715", "0.7144173", "0.7094742", "0.70730054", "0.70055", "0.6980607", "0.6980607", "0.69757575", "0.69654244", "0.68918794", ...
0.83357686
0
Pick a word from the specified type at the point and advance the pointer for that list. When the end of the list is reached it will be shuffled (if self._doShuffles is True) and the pointer will be reset to 0.
def pick(self, wordType): if self._wordTypePositions[wordType] == len(self._wordTypes[wordType]): self._wordTypePositions[wordType] = 0 if self._doShuffles: self._wordTypes[wordType] = sorted(self._wordTypes[wordType], key=lambda k: random.random()) word = self....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def skip(self, word_list, word_type):\n\n while self.peek(word_list) == word_type:\n self.match(word_list, word_type)", "def pick_word(self):\n self.chosen_word = random.choice(self.words_list)\n return self.chosen_word", "def chosen():\n wordList = loadWords()\n w = rando...
[ "0.5997934", "0.58103025", "0.5544544", "0.55107945", "0.53766865", "0.5340726", "0.532483", "0.532483", "0.532483", "0.52692276", "0.5178724", "0.5172112", "0.51571864", "0.5151651", "0.5129144", "0.50692195", "0.5057307", "0.5052408", "0.50425816", "0.5024276", "0.5002662",...
0.7594215
0
Test if Book is in different location.
def test_read_different_location(self): try: self.reader.read(self.books[1], 0, 1) self.fail("Readed book was not in the library") except AssertionError: pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _check_if_so_in_other_box(self, location):\n move_line = self.env[\"stock.move.line\"].search(\n [\n (\"location_dest_id.name\", \"!=\", \"Packing Zone\"),\n (\"location_dest_id\", \"!=\", location),\n (\n \"move_id.picking_id.ba...
[ "0.5809662", "0.5645233", "0.5603496", "0.55706257", "0.5541214", "0.55375296", "0.5525964", "0.55211", "0.54842293", "0.54502064", "0.5443343", "0.54124403", "0.5395622", "0.5321185", "0.5310501", "0.5307334", "0.52833426", "0.52736306", "0.5267147", "0.526115", "0.52604926"...
0.67264634
0
Read the output from MoMC in string and returns the list of nodes corresponding to the MIS (converted to zerobased index)
def parse_MoMC_output(out): for line in out.splitlines(): temp = str(line.decode()) if temp.startswith('M'): return [int(x)-1 for x in temp[2:].split()]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_MoMC_output_full(out):\n for line in out.splitlines():\n temp = str(line.decode())\n\n if temp.startswith('M'):\n MIS = [int(x)-1 for x in temp[2:].split()]\n\n if temp.startswith('s'):\n tempsplit = temp.split()\n assert len(MIS) == int(tempsplit[...
[ "0.5958136", "0.5915736", "0.58012897", "0.5705464", "0.56851405", "0.56541646", "0.5650839", "0.54453987", "0.53487253", "0.5305744", "0.5304972", "0.52953905", "0.52279013", "0.5212241", "0.5206144", "0.51946205", "0.5168869", "0.5164616", "0.5145319", "0.51448655", "0.5127...
0.7002612
0
2D Scatter plotting using tSNE and PCA in sklearn
def scatterplot(x, c, label, square=False): z_c = _scatter_centroids(c, square) z_x, zrmax = _scatter_x_near_centroid(x, c, z_c, label) return z_x, z_c, zrmax
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tSNE_plot2(features, labels):\n model = TSNE(n_components=2, random_state=0)\n transformed = model.fit_transform(features)\n\n print(\"Data transformed, now plotting...\")\n\n # Plotting\n x = transformed[:, 0]\n y = transformed[:, 1]\n colors = labels\n\n ...
[ "0.72767", "0.6727377", "0.6669148", "0.66626513", "0.66313", "0.652723", "0.63369304", "0.6245499", "0.6194817", "0.6064313", "0.60025436", "0.59979546", "0.5964166", "0.5961221", "0.5945186", "0.5885957", "0.5877971", "0.5848572", "0.5821637", "0.5798856", "0.57658076", "...
0.0
-1
Crop the input tensor.
def crop_scope(self, x, yin_start, scope_shift): return torch.stack( [ x[ i, yin_start + scope_shift[i] : yin_start + self.yin_scope + scope_shift[i], :, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def crop(X,size_crop=_size_crop):\n b = size_crop//2\n shape = tf.shape(X)\n cx= shape[0]//2\n cy= shape[1]//2\n return X[cx-b:cx+b,cy-b:cy+b,...]", "def crop_random_img(self,input_img):\n #TODO Task 1.2\n\n img_with_missing = tf.identity(input_img)\n #print(\"IMG_MISSING_CROP...
[ "0.7352608", "0.65765417", "0.6573579", "0.6542811", "0.65126413", "0.64360434", "0.63330144", "0.6323358", "0.62709725", "0.6258", "0.6249547", "0.62355465", "0.6210445", "0.62067527", "0.61945504", "0.61858344", "0.6107443", "0.6105336", "0.6089955", "0.60847354", "0.607942...
0.0
-1
Get the available colors for a given item
def get_known_colors(self, itemid, itemtypeid)->pd.DataFrame: colors = self.rc.get_known_colors(itemid, itemtypeid) df = pd.DataFrame.from_dict(colors, orient="columns") df['color_name'] = df['color_id'].apply(lambda x: legoColors[x]) df = df.set_index(['color_id']) return df
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def colors(self):\n return self[\"colors\"]", "def colors(self):\n return self[\"colors\"]", "def colors(self):\r\n\t\treturn self._colors", "def getColors():\n return ['#8c99fc', '#cacefd', '#fff1d7', '#feda98', '#fda85a', '#fc6647']", "def get_available_colors(self):\n\n # Get rep...
[ "0.6734083", "0.6734083", "0.65515375", "0.65158427", "0.64834964", "0.64317036", "0.6265956", "0.6195585", "0.6195448", "0.61856735", "0.6183788", "0.6169778", "0.6154797", "0.6145483", "0.6136217", "0.6113444", "0.6100109", "0.6093442", "0.6089876", "0.60671717", "0.6055489...
0.64385164
5
Returns a list of cells in the same row / col / local square of the form [(a, b), ... , (c, d)] Does not include reference cell itself (i, j)
def find_affected_cells(i, j): GRID_SIZE = 9 MINI_GRID_SIZE = 3 cells = set() # Cells in same row for row_idx in range(GRID_SIZE): cells.add((row_idx, j)) # Cells in same col for col_idx in range(GRID_SIZE): cells.add((i, col_idx)) # Cells in local square top_l...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cells(self):\n return ((row, col) for row in self.rows for col in self.cols)", "def cells_list(self):\n xx, yy = np.meshgrid(self.x_spacings, self.y_spacings)\n return np.vstack([yy.ravel(), xx.ravel()]).transpose()", "def cell_list(self):\n lst_of_idx = []\n height = self.__...
[ "0.753438", "0.73400885", "0.7324571", "0.7315915", "0.71164674", "0.6962689", "0.69010097", "0.68636763", "0.68394077", "0.6776887", "0.6693367", "0.66782373", "0.666874", "0.6637965", "0.6633843", "0.654155", "0.6534992", "0.65260655", "0.651808", "0.64719623", "0.6461861",...
0.68700314
7
When running Lettuce tests using examples (i.e. "Confirmation is shown on save" in coursesettings.feature), the normal hooks aren't called between examples. reset_data should run before each scenario to flush the test database. When this doesn't happen we get errors due to trying to insert a nonunique entry. So instead...
def reset_the_db(_step): reset_data(None)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clear_db():\n from example_data import ExampleDataLoader\n ExampleDataLoader.clean_db()", "def reset_data(scenario):\r\n LOGGER.debug(\"Flushing the test database...\")\r\n call_command('flush', interactive=False, verbosity=0)\r\n world.absorb({}, 'scenario_dict')", "def tearDown(self):\n ...
[ "0.708386", "0.68588537", "0.68216586", "0.680493", "0.680493", "0.680493", "0.680493", "0.680493", "0.680493", "0.68032414", "0.6799012", "0.6799012", "0.6799012", "0.6799012", "0.6799012", "0.6799012", "0.6799012", "0.6799012", "0.6799012", "0.67773503", "0.67367804", "0....
0.70215327
1
Prepare for tests by creating a course with a section, subsection, and unit.
def create_course_with_unit(): world.clear_courses() course = world.CourseFactory.create() world.scenario_dict['COURSE'] = course section = world.ItemFactory.create(parent_location=course.location) world.ItemFactory.create( parent_location=section.location, category='sequentia...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setUp(self):\r\n self.course = CourseFactory.create(display_name=self.COURSE_NAME, number=self.COURSE_SLUG)\r\n self.chapter1 = ItemFactory.create(\r\n parent_location=self.course.location,\r\n display_name=\"chapter1\",\r\n category='chapter')\r\n self.sec...
[ "0.73332375", "0.73124665", "0.7035657", "0.69811064", "0.6968634", "0.68034035", "0.6773041", "0.67514", "0.6728603", "0.6686018", "0.6630045", "0.66207194", "0.6615894", "0.6593965", "0.65756625", "0.65631694", "0.65463364", "0.6504882", "0.64999473", "0.64626014", "0.64570...
0.7525936
0
Set the field to the specified value.
def set_field_value(index, value): elem = world.css_find('.metadata_edit div.wrapper-comp-setting input.setting-input')[index] elem.value = value elem.type(Keys.TAB)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_value(self, field, value):\n field = self.find_first(field)\n if field is not None:\n field.value = value", "def _setValue(self, field, value):\n self._contents[field] = value", "def setfield(self, field, value):\n self.__setitem__(field, value)", "def set_value...
[ "0.8807467", "0.83670175", "0.8257049", "0.7556789", "0.7556789", "0.7556789", "0.7531811", "0.7509278", "0.7470909", "0.74446833", "0.74446833", "0.73317915", "0.72618157", "0.7252488", "0.7245919", "0.7197914", "0.7188131", "0.718528", "0.71626914", "0.7139209", "0.70630217...
0.655928
63
Smoke test for creating a version 1 archive from a version 0.
def test_version1_archive(self): call_command('export_convert_format', self.version0, self.temp_dir) output = path(self.temp_dir) / 'Version0_drafts_version_1.tar.gz' self.assertTrue(self._verify_archive_equality(output, self.version1))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_version0_archive(self):\r\n call_command('export_convert_format', self.version1, self.temp_dir)\r\n output = path(self.temp_dir) / 'Version1_drafts_version_0.tar.gz'\r\n self.assertTrue(self._verify_archive_equality(output, self.version0))", "def test_archive_run(self):\n pas...
[ "0.7716179", "0.7055421", "0.6988589", "0.64881456", "0.6415799", "0.63867867", "0.63459206", "0.63090354", "0.62893933", "0.62818915", "0.6201461", "0.61764103", "0.61636966", "0.61479837", "0.6146423", "0.61242247", "0.6116066", "0.6105214", "0.6100868", "0.6100639", "0.608...
0.78204894
0
Creates the test course.
def setUp(self): super(ForumTestCase, self).setUp() self.course = CourseFactory.create(org='testX', number='727', display_name='Forum Course')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_create_course(self):\r\n self.assert_created_course()", "def make_course(self, **kwargs):\r\n self.course = CourseFactory.create(**kwargs)\r\n user = UserFactory.create()\r\n CourseEnrollmentFactory.create(user=user, course_id=self.course.id)\r\n self.client.login(user...
[ "0.81679255", "0.7982984", "0.7730142", "0.7700838", "0.7678283", "0.7595566", "0.7366904", "0.7337337", "0.72811043", "0.72727233", "0.72699165", "0.7121768", "0.70748824", "0.70570207", "0.70274824", "0.69975615", "0.6990448", "0.69876397", "0.69704556", "0.69638795", "0.69...
0.68641555
25
Test that a course which has HTML that has style formatting is preserved in export/import
def test_html_export_roundtrip(self): module_store = modulestore('direct') content_store = contentstore() import_from_xml(module_store, 'common/test/data/', ['toy']) course_id = SlashSeparatedCourseKey('edX', 'toy', '2012_Fall') # Export the course root_dir = ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_export_html(self):\r\n resp = self.client.get_html(self.url)\r\n self.assertEquals(resp.status_code, 200)\r\n self.assertContains(resp, \"Export My Course Content\")", "def test_style_maintained(self):\n test_string = \"<p><font style='color: red'></p>\"\n cleaned = sa...
[ "0.6630094", "0.6551414", "0.6340285", "0.59900135", "0.5955256", "0.5948341", "0.5893933", "0.5876529", "0.5801027", "0.57768697", "0.5774304", "0.5746391", "0.5732657", "0.5705142", "0.5666676", "0.5665467", "0.5663711", "0.56372803", "0.5629766", "0.5624272", "0.5615733", ...
0.65690804
1
These tests need a user in the DB so that the django Test Client can log them in. They inherit from the ModuleStoreTestCase class so that the mongodb collection will be cleared out before each test case execution and deleted afterwards.
def setUp(self): uname = 'testuser' email = 'test+courses@edx.org' password = 'foo' # Create the use so we can log them in. self.user = User.objects.create_user(uname, email, password) # Note that we do not actually need to do anything # for registratio...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setUp(self):\n self.client = Client()\n #creamos un usuario en la db\n self.user = User.objects.create_user('super', 'lennon@thebeatles.com', 'super')", "def setUp(self):\r\n super(SysadminBaseTestCase, self).setUp()\r\n self.user = UserFactory.create(username='test_user',\...
[ "0.7304307", "0.70889574", "0.700872", "0.7006511", "0.69746554", "0.6970943", "0.6969809", "0.6926403", "0.6915506", "0.6903875", "0.6897007", "0.68840337", "0.6875517", "0.68688333", "0.6854009", "0.6851336", "0.6850283", "0.6846306", "0.68429357", "0.6841768", "0.68378294"...
0.0
-1
Checks that the course was created properly.
def assert_created_course(self, number_suffix=None): test_course_data = {} test_course_data.update(self.course_data) if number_suffix: test_course_data['number'] = '{0}_{1}'.format(test_course_data['number'], number_suffix) course_key = _get_course_id(test_course_data) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_create_course(self):\r\n self.assert_created_course()", "def _create_course(self):\r\n # If the course already exists, this will respond\r\n # with a 200 and an error message, which we ignore.\r\n response = self.session.post(\r\n STUDIO_BASE_URL + '/course/',\r\n ...
[ "0.7750751", "0.7484464", "0.73191345", "0.72933096", "0.72821856", "0.72697175", "0.7113373", "0.6959229", "0.6890062", "0.6833764", "0.6817307", "0.67832017", "0.66644", "0.66195494", "0.6618508", "0.66052127", "0.6575816", "0.6556131", "0.65473884", "0.6481473", "0.6470626...
0.6897712
8
Checks that the course not created.
def assert_create_course_failed(self, error_message): resp = self.client.ajax_post('/course/', self.course_data) self.assertEqual(resp.status_code, 400) data = parse_json(resp) self.assertEqual(data['error'], error_message)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_course_not_available(self):\n \n user1 = User.objects.create(username=\"user1\", password=\"1234\", email=\"user1@example.com\")\n user2 = User.objects.create(username=\"user2\", password=\"1234\", email=\"user1@example.com\")\n \n course = Course.objects.first()\n ...
[ "0.73048496", "0.7213484", "0.71405834", "0.71154076", "0.7067151", "0.7057502", "0.7002306", "0.6993867", "0.6795597", "0.6706711", "0.6689855", "0.6626613", "0.6624255", "0.6617462", "0.65946865", "0.6551235", "0.6517898", "0.65086555", "0.6494595", "0.6460936", "0.6460394"...
0.58880687
72
Test new course creation and verify forum unseeding when there are multiple courses
def test_forum_unseeding_with_multiple_courses(self): test_course_data = self.assert_created_course(number_suffix=uuid4().hex) second_course_data = self.assert_created_course(number_suffix=uuid4().hex) # unseed the forums for the first course course_id = _get_course_id(test_course_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_create_course_check_forum_seeding(self):\r\n test_course_data = self.assert_created_course(number_suffix=uuid4().hex)\r\n self.assertTrue(are_permissions_roles_seeded(_get_course_id(test_course_data)))", "def test_create_course(self):\r\n self.assert_created_course()", "def testCo...
[ "0.82253295", "0.8148599", "0.7671948", "0.76110476", "0.7602065", "0.7454406", "0.74536574", "0.7444317", "0.7397183", "0.72531086", "0.71958345", "0.71666825", "0.7164218", "0.7162519", "0.71378535", "0.71227074", "0.711699", "0.70259416", "0.7019571", "0.69667935", "0.6948...
0.77039796
2
Test new course creation error path
def test_create_course_duplicate_course(self): self.client.ajax_post('/course/', self.course_data) self.assert_course_creation_failed('There is already a course defined with the same organization, course number, and course run. Please change either organization or course number to be unique.')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_create_course(self):\r\n self.assert_created_course()", "def test_create_with_non_existent_course(self):\n\n permissions = Permission.objects.filter(name__in=('Can add course mode', 'Can change course mode'))\n for permission in permissions:\n self.user.user_permissions.a...
[ "0.7660427", "0.70428675", "0.69207776", "0.686231", "0.6832381", "0.6697079", "0.66841686", "0.6658129", "0.6646023", "0.66047424", "0.65732116", "0.65721494", "0.64824563", "0.63933337", "0.6392601", "0.635672", "0.6341049", "0.63119364", "0.63090247", "0.6301493", "0.62868...
0.70411897
2
Checks that the course did not get created
def assert_course_creation_failed(self, error_message): test_enrollment = False try: course_id = _get_course_id(self.course_data) initially_enrolled = CourseEnrollment.is_enrolled(self.user, course_id) test_enrollment = True except InvalidKeyError: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_new_curriculum_courses(self, curriculum_courses):\n\n for cur in curriculum_courses:\n # check to make sure its in the general courses table\n self.db_cursor.execute(\"\"\"SELECT COUNT(*) FROM Course WHERE name = %s\"\"\", (cur,))\n ct = self.db_cursor.fetchone(...
[ "0.72936594", "0.72804856", "0.7181808", "0.7165586", "0.6961223", "0.6876023", "0.68658036", "0.68622124", "0.67237514", "0.6712417", "0.6695011", "0.6687603", "0.66694486", "0.6664919", "0.6630811", "0.661756", "0.66150796", "0.66147846", "0.6574573", "0.6567646", "0.648290...
0.6295611
31
Test new course creation error path
def test_create_course_duplicate_number(self): self.client.ajax_post('/course/', self.course_data) self.course_data['display_name'] = 'Robot Super Course Two' self.course_data['run'] = '2013_Summer' self.assert_course_creation_failed('There is already a course defined with the same...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_create_course(self):\r\n self.assert_created_course()", "def test_create_with_non_existent_course(self):\n\n permissions = Permission.objects.filter(name__in=('Can add course mode', 'Can change course mode'))\n for permission in permissions:\n self.user.user_permissions.a...
[ "0.7660427", "0.70428675", "0.70411897", "0.69207776", "0.686231", "0.6832381", "0.6697079", "0.66841686", "0.6658129", "0.6646023", "0.66047424", "0.65732116", "0.65721494", "0.64824563", "0.6392601", "0.635672", "0.6341049", "0.63119364", "0.63090247", "0.6301493", "0.62868...
0.63933337
14
Test new course creation error path due to case insensitive name equality
def test_create_course_case_change(self): self.course_data['number'] = 'capital' self.client.ajax_post('/course/', self.course_data) cache_current = self.course_data['org'] self.course_data['org'] = self.course_data['org'].lower() self.assert_course_creation_failed('There is...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_create_course_with_bad_organization(self):\r\n self.course_data['org'] = 'University of California, Berkeley'\r\n self.assert_course_creation_failed(\r\n r\"(?s)Unable to create course 'Robot Super Course'.*: Invalid characters in u'University of California, Berkeley'\")", "def ...
[ "0.68851244", "0.67455167", "0.6693483", "0.66730535", "0.6494077", "0.6457109", "0.64565074", "0.6447661", "0.644017", "0.62229866", "0.6222872", "0.6174235", "0.61484724", "0.6049806", "0.60429496", "0.6021245", "0.6013766", "0.6003561", "0.5997122", "0.59921795", "0.597663...
0.638097
9
Test new course creation course creation disabled, but staff access.
def test_create_course_with_course_creation_disabled_staff(self): with mock.patch.dict('django.conf.settings.FEATURES', {'DISABLE_COURSE_CREATION': True}): self.assert_created_course()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_create_course_with_course_creation_disabled_not_staff(self):\r\n with mock.patch.dict('django.conf.settings.FEATURES', {'DISABLE_COURSE_CREATION': True}):\r\n self.user.is_staff = False\r\n self.user.save()\r\n self.assert_course_permission_denied()", "def test_co...
[ "0.8560743", "0.824099", "0.817146", "0.79403204", "0.7694574", "0.757729", "0.74911135", "0.74372625", "0.7405881", "0.71402323", "0.71276057", "0.7103038", "0.7039565", "0.7038319", "0.7004498", "0.69976044", "0.68808615", "0.6848623", "0.68415827", "0.6834868", "0.68117094...
0.8443992
1
Test new course creation error path for course creation disabled, not staff access.
def test_create_course_with_course_creation_disabled_not_staff(self): with mock.patch.dict('django.conf.settings.FEATURES', {'DISABLE_COURSE_CREATION': True}): self.user.is_staff = False self.user.save() self.assert_course_permission_denied()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_create_course(self):\r\n self.assert_created_course()", "def test_create_with_non_existent_course(self):\n\n permissions = Permission.objects.filter(name__in=('Can add course mode', 'Can change course mode'))\n for permission in permissions:\n self.user.user_permissions.a...
[ "0.7235151", "0.68234646", "0.66773516", "0.6553791", "0.65413773", "0.64267087", "0.64180046", "0.64155126", "0.63390875", "0.6329385", "0.6314405", "0.63126254", "0.6305413", "0.6302207", "0.62964255", "0.62825066", "0.6256574", "0.624376", "0.62080973", "0.61943376", "0.61...
0.63787323
8
Test that the course factory works correctly.
def test_course_factory(self): course = CourseFactory.create() self.assertIsInstance(course, CourseDescriptor)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_create_course(self):\r\n self.assert_created_course()", "def testCourses(self):\n self.person.invokeFactory(type_name=\"FSDCourse\", id=\"test-course\")\n self.failUnless('test-course' in self.person.contentIds())\n self.failUnless('test-course' in [c.id for c in self.person....
[ "0.8628793", "0.8424366", "0.7941117", "0.79025203", "0.7836772", "0.7582189", "0.7567306", "0.7489393", "0.7453256", "0.7418933", "0.7370491", "0.7328281", "0.73095536", "0.7251859", "0.72041124", "0.7203792", "0.71714425", "0.7165403", "0.7161095", "0.7159521", "0.71477", ...
0.8475108
1
Test viewing the index page with an existing course
def test_course_index_view_with_course(self): CourseFactory.create(display_name='Robot Super Educational Course') resp = self.client.get_html('/course/') self.assertContains( resp, '<h3 class="course-title">Robot Super Educational Course</h3>', status_co...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_course_index_view_with_no_courses(self):\r\n # Create a course so there is something to view\r\n resp = self.client.get_html('/course/')\r\n self.assertContains(\r\n resp,\r\n '<h1 class=\"page-header\">My Courses</h1>',\r\n status_code=200,\r\n ...
[ "0.8121903", "0.7740417", "0.76574373", "0.76229036", "0.76037353", "0.74684846", "0.7366442", "0.73300624", "0.73296905", "0.73190093", "0.7291552", "0.7162369", "0.71383244", "0.7128398", "0.70743114", "0.70736146", "0.70529383", "0.69686013", "0.69641924", "0.6884979", "0....
0.85362464
0
Test that a problem treats markdown specially.
def test_capa_module(self): course = _course_factory_create_course() problem_data = { 'parent_locator': unicode(course.location), 'category': 'problem' } resp = self.client.ajax_post(reverse_url('xblock_handler'), problem_data) self.assertEqual(...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_style(fixture_file, options, tmp_path):\n file_path = tmp_path / \"test_markdown.md\"\n cases = read_fixture_file(Path(__file__).parent / \"data\" / fixture_file)\n for case in cases:\n line, title, text, expected = case\n file_path.write_bytes(text.encode())\n assert mdforma...
[ "0.66425383", "0.64691925", "0.64583373", "0.64488274", "0.6448508", "0.64049464", "0.64049095", "0.6392023", "0.6370133", "0.6321087", "0.62867945", "0.6281305", "0.6281305", "0.6278989", "0.6270516", "0.6258208", "0.62496966", "0.6247308", "0.6242146", "0.6226867", "0.62159...
0.0
-1
Show the course overview page.
def _show_course_overview(self, course_key): resp = self.client.get_html(get_url('course_handler', course_key, 'course_key_string')) _test_no_locations(self, resp) return resp
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def course_index(request, course_key):\r\n course_module = _get_course_module(course_key, request.user, depth=3)\r\n lms_link = get_lms_link_for_item(course_module.location)\r\n sections = course_module.get_children()\r\n\r\n\r\n return render_to_response('overview.html', {\r\n 'context_course':...
[ "0.7675806", "0.7501893", "0.7351849", "0.72501373", "0.7151773", "0.7139157", "0.7102211", "0.7018699", "0.68928945", "0.68753064", "0.6782968", "0.67160463", "0.6692798", "0.66653717", "0.6656531", "0.66259223", "0.6624151", "0.6583562", "0.6537821", "0.6489128", "0.6416316...
0.7486592
2
When creating a course a unique wiki_slug should be set.
def test_wiki_slug(self): course_key = _get_course_id(self.course_data) _create_course(self, course_key, self.course_data) course_module = modulestore('direct').get_course(course_key) self.assertEquals(course_module.wiki_slug, 'MITx.999.2013_Spring')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def course_wiki_slug(course):\r\n slug = course.wiki_slug\r\n\r\n # Django-wiki expects article slug to be non-numerical. In case the\r\n # course number is numerical append an underscore.\r\n if slug_is_numerical(slug):\r\n slug = slug + \"_\"\r\n\r\n return slug", "def course_wiki_redirec...
[ "0.7311821", "0.6580294", "0.6319249", "0.63141036", "0.6220873", "0.62158906", "0.62070566", "0.62070566", "0.6195181", "0.61827296", "0.61308795", "0.6129569", "0.6071277", "0.6071277", "0.6030071", "0.59390044", "0.59149957", "0.58618206", "0.5861216", "0.58391595", "0.583...
0.71485174
1
Create dummy course with 'CourseFactory' and role (instructor/staff) groups
def _create_course_with_access_groups(self, course_location, user=None): course = CourseFactory.create( org=course_location.org, number=course_location.course, run=course_location.run ) if user is not None: for role in [CourseInstructorRol...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _course_factory_create_course():\r\n return CourseFactory.create(org='MITx', course='999', display_name='Robot Super Course')", "def make_course(self, **kwargs):\r\n self.course = CourseFactory.create(**kwargs)\r\n user = UserFactory.create()\r\n CourseEnrollmentFactory.create(user=us...
[ "0.79885596", "0.77366066", "0.7210613", "0.69987357", "0.68914914", "0.68695414", "0.6851281", "0.68196404", "0.6818989", "0.67992306", "0.67921895", "0.6767523", "0.6755404", "0.67291737", "0.6691634", "0.6674937", "0.66360354", "0.66346705", "0.6631505", "0.66295475", "0.6...
0.67161596
14
Test getting courses with invalid course location (course deleted from modulestore).
def test_get_course_list_with_invalid_course_location(self): request = self.factory.get('/course') request.user = self.user course_key = SlashSeparatedCourseKey('Org', 'Course', 'Run') self._create_course_with_access_groups(course_key, self.user) # get courses through it...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_retrieve_invalid_course(self):\n path = reverse('commerce_api:v1:courses:retrieve_update', args=['a/b/c'])\n response = self.client.get(path, content_type=JSON_CONTENT_TYPE)\n assert response.status_code == 404", "def test_course_does_not_exist(self):\n self.client.login(user...
[ "0.77587473", "0.7527095", "0.75082314", "0.7504525", "0.7461707", "0.7427496", "0.7419068", "0.7405281", "0.7294741", "0.72819877", "0.72208047", "0.7105987", "0.70917773", "0.7039527", "0.7028351", "0.7019787", "0.7009616", "0.7008291", "0.69789654", "0.6940598", "0.6936350...
0.839487
0
Test getting courses with same id but with different name case. Then try to delete one of them and check that it is properly deleted and other one is accessible
def test_get_course_list_with_same_course_id(self): # create and log in a non-staff user self.user = UserFactory() request = self.factory.get('/course') request.user = self.user self.client.login(username=self.user.username, password='test') course_location_caps =...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_removing_course(self):\n a_user = User.objects.create(first_name=\"2\", last_name=\"test\", username=\"test\")\n user = VSBUser.objects.create(user=a_user)\n inst = Institution.objects.create(name = \"UVA\")\n c1 = Course.objects.create(name = \"CS 3240\", institution= inst)\n ...
[ "0.77542394", "0.7559177", "0.73907804", "0.72863585", "0.71381456", "0.7105517", "0.70850027", "0.70548457", "0.7023806", "0.6981765", "0.6904369", "0.6828257", "0.6720074", "0.6654972", "0.6601844", "0.6569309", "0.65353405", "0.6531965", "0.6524895", "0.6486992", "0.646757...
0.78278583
0
Test getting a specific grading type record.
def test_get(self): resp = self.client.get_json(self.url + '/0') self.assertEqual(resp.status_code, 200) obj = json.loads(resp.content) self.assertEqual(self.starting_graders[0], obj)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_record(self):\n pass", "def testTheType(self, theTestType):\n \n pass", "def test_grade(self, grade):\n self.client.login(username=self.student.username, password=self.password)\n with patch('lms.djangoapps.grades.course_grade_factory.CourseGradeFactory.read') as moc...
[ "0.6244872", "0.59875244", "0.5916269", "0.5897594", "0.566312", "0.54822314", "0.5481534", "0.5449029", "0.5443469", "0.5395668", "0.5382463", "0.5371207", "0.53601223", "0.53527844", "0.5346155", "0.533939", "0.533078", "0.5330753", "0.5321862", "0.53020877", "0.5263953", ...
0.0
-1
Setup test course, user, and url.
def setUp(self): super(TestExportGit, self).setUp() self.course_module = modulestore().get_course(self.course.id) self.test_url = reverse_course_url('export_git', self.course.id)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setUp(self):\r\n uname = 'testuser'\r\n email = 'test+courses@edx.org'\r\n password = 'foo'\r\n\r\n # Create the use so we can log them in.\r\n self.user = User.objects.create_user(uname, email, password)\r\n\r\n # Note that we do not actually need to do anything\r\n ...
[ "0.7733141", "0.7703957", "0.7616434", "0.7569561", "0.7505422", "0.7114343", "0.7109047", "0.7088147", "0.70155084", "0.69433355", "0.6911628", "0.68892276", "0.68830234", "0.6868085", "0.6854017", "0.6835663", "0.6771139", "0.6766386", "0.6766386", "0.6741096", "0.67390734"...
0.73093677
5
These tests need a user in the DB so that the django Test Client can log them in. They inherit from the ModuleStoreTestCase class so that the mongodb collection will be cleared out before each test case execution and deleted afterwards.
def setUp(self): self.uname = 'testuser' self.email = 'test+courses@edx.org' self.password = 'foo' # Create the use so we can log them in. self.user = User.objects.create_user(self.uname, self.email, self.password) # Note that we do not actually need to do anyth...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setUp(self):\n self.client = Client()\n #creamos un usuario en la db\n self.user = User.objects.create_user('super', 'lennon@thebeatles.com', 'super')", "def setUp(self):\r\n super(SysadminBaseTestCase, self).setUp()\r\n self.user = UserFactory.create(username='test_user',\...
[ "0.7304307", "0.70889574", "0.700872", "0.7006511", "0.69746554", "0.6970943", "0.6969809", "0.6926403", "0.6915506", "0.6903875", "0.6897007", "0.68840337", "0.6875517", "0.68688333", "0.6854009", "0.6851336", "0.6850283", "0.6846306", "0.68429357", "0.6841768", "0.68378294"...
0.0
-1
Test that old mongo finds the orphans
def test_mongo_orphan(self): orphans = json.loads( self.client.get( self.orphan_url, HTTP_ACCEPT='application/json' ).content ) self.assertEqual(len(orphans), 3, "Wrong # {}".format(orphans)) location = self.course.location....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_mongo_orphan(self):\r\n orphans = self.old_mongo.get_orphans(self.old_course_key)\r\n self.assertEqual(len(orphans), 3, \"Wrong # {}\".format(orphans))\r\n location = self.old_course_key.make_usage_key('chapter', name='OrphanChapter')\r\n self.assertIn(location.to_deprecated_st...
[ "0.76557106", "0.76553106", "0.6820571", "0.65045714", "0.62482643", "0.61683047", "0.61096334", "0.6010656", "0.6007425", "0.59727925", "0.59520775", "0.5915541", "0.5883634", "0.5877788", "0.58766073", "0.58474076", "0.58434767", "0.58387196", "0.58383524", "0.57930446", "0...
0.73093486
2
Test that old mongo deletes the orphans
def test_mongo_orphan_delete(self): self.client.delete(self.orphan_url) orphans = json.loads( self.client.get(self.orphan_url, HTTP_ACCEPT='application/json').content ) self.assertEqual(len(orphans), 0, "Orphans not deleted {}".format(orphans))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_delete_orphans(self, default_store, max_mongo_calls, min_mongo_calls):\n course = self.create_course_with_orphans(default_store)\n orphan_url = reverse_course_url('orphan_handler', course.id)\n\n with check_mongo_calls_range(max_mongo_calls, min_mongo_calls):\n self.client....
[ "0.72426534", "0.7126013", "0.68161124", "0.6783059", "0.67518747", "0.6731692", "0.6731203", "0.6718298", "0.6678793", "0.66017234", "0.65532136", "0.65288824", "0.64851743", "0.64543", "0.6370761", "0.63671404", "0.63614875", "0.6358029", "0.6355507", "0.63500476", "0.63300...
0.8017275
0
Test that auth restricts get and delete appropriately
def test_not_permitted(self): test_user_client, test_user = self.create_non_staff_authed_user_client() CourseEnrollment.enroll(test_user, self.course.id) response = test_user_client.get(self.orphan_url) self.assertEqual(response.status_code, 403) response = test_user_client....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_unauthenticated_get(self):\n url = reverse('edit-list')\n\n response = self.client.get(url)\n self.assertEqual(403, response.status_code)\n self.assertEqual('Forbidden', response.status_text)\n self.assertTrue(\n 'credentials were not provided.' in response.da...
[ "0.75319856", "0.7424455", "0.73408103", "0.7208054", "0.7112452", "0.70674604", "0.70493424", "0.7007222", "0.6995473", "0.6993244", "0.69699675", "0.69343144", "0.6933057", "0.69326437", "0.6920444", "0.6877365", "0.687599", "0.6850054", "0.68386906", "0.6830981", "0.682741...
0.0
-1
Checks that student answer requests submitted to cms's "/event" url via GET are correctly returned as 204s
def test_get_answers_to_log(self): requests = [ {"event": "my_event", "event_type": "my_event_type", "page": "my_page"}, {"event": "{'json': 'object'}", "event_type": unichr(512), "page": "my_page"} ] with mock.patch.dict('django.conf.settings.FEATURES', {'ENABLE_SQL...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_no_event_response(response: HTTPResponse) -> bool:\n return response.status_code == 404", "def test_nonexisting_event(self):\n response = self.client.get(\"/events/1\")\n self.assertEqual(response.status_code, 404)", "def test_empty_request_returns_an_error(self, patch_process_event_...
[ "0.66865927", "0.62881064", "0.6278869", "0.62601054", "0.6141565", "0.6040152", "0.60062796", "0.5998232", "0.59942865", "0.5957325", "0.5914982", "0.58990514", "0.58303064", "0.5820722", "0.58041483", "0.58025944", "0.5801821", "0.5800612", "0.5796414", "0.5787869", "0.5775...
0.0
-1
Test that creating same course again after deleting it gives user his default forum role "Student" for that course
def test_user_role_on_course_recreate(self): # check that user has enrollment and his default "Student" forum role for this course self.assertTrue(CourseEnrollment.is_enrolled(self.user, self.course_key)) self.assertTrue(self.user.roles.filter(name="Student", course_id=self.course_key)) # py...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_user_forum_default_role_on_course_deletion(self):\r\n # check that user has enrollment for this course\r\n self.assertTrue(CourseEnrollment.is_enrolled(self.user, self.course_key))\r\n\r\n # check that user has his default \"Student\" forum role for this course\r\n self.assertT...
[ "0.8024661", "0.76826394", "0.75194275", "0.7243006", "0.7213288", "0.71840215", "0.7132855", "0.711528", "0.70616186", "0.70092434", "0.6985986", "0.69591933", "0.695522", "0.6830236", "0.669181", "0.66730464", "0.66171247", "0.6583884", "0.65609384", "0.6541153", "0.6485631...
0.7945897
1
Get URL for about page, no marketing site
def about_page_test(self): # default for ENABLE_MKTG_SITE is False. self.assertEquals(self.get_about_page_link(), "//localhost:8000/courses/mitX/101/test/about")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_about_page_link(self):\r\n course_key = SlashSeparatedCourseKey('mitX', '101', 'test')\r\n return utils.get_lms_link_for_about_page(course_key)", "def about(self):\n return dict(page='about')", "def about(self):\n return dict(page='about')", "def about(self):\n retu...
[ "0.7734797", "0.6880981", "0.6880981", "0.6880981", "0.6880981", "0.6785586", "0.67523974", "0.67281044", "0.67047894", "0.6690924", "0.6639301", "0.6593521", "0.6569902", "0.65192115", "0.65079", "0.64968246", "0.6486653", "0.6450372", "0.64468867", "0.642684", "0.64169264",...
0.70938927
1
Get URL for about page, marketing root present.
def about_page_marketing_site_test(self): with mock.patch.dict('django.conf.settings.FEATURES', {'ENABLE_MKTG_SITE': True}): self.assertEquals(self.get_about_page_link(), "//dummy-root/courses/mitX/101/test/about") with mock.patch.dict('django.conf.settings.FEATURES', {'ENABLE_MKTG_SITE':...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_about_page_link(self):\r\n course_key = SlashSeparatedCourseKey('mitX', '101', 'test')\r\n return utils.get_lms_link_for_about_page(course_key)", "def about_page_test(self):\r\n # default for ENABLE_MKTG_SITE is False.\r\n self.assertEquals(self.get_about_page_link(), \"//loca...
[ "0.76832414", "0.70883256", "0.691203", "0.691203", "0.691203", "0.691203", "0.6714596", "0.6647012", "0.6628294", "0.66210264", "0.66055065", "0.6563736", "0.6537981", "0.6531198", "0.6530571", "0.6526488", "0.65195924", "0.65180695", "0.65180695", "0.65180695", "0.65180695"...
0.0
-1
Returns a mock course object with a tabs attribute.
def get_course_with_tabs(self, tabs=None): if tabs is None: tabs = [] course = collections.namedtuple('MockCourse', ['tabs']) if isinstance(tabs, basestring): course.tabs = self.get_tab_type_dicts(tabs) else: course.tabs = tabs return c...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_tab_by_methods(self):\r\n self.course.tabs = self.all_valid_tab_list\r\n for tab in self.course.tabs:\r\n\r\n # get tab by type\r\n self.assertEquals(tabs.CourseTabList.get_tab_by_type(self.course.tabs, tab.type), tab)\r\n\r\n # get tab by id\r\n ...
[ "0.6131536", "0.6046137", "0.5942875", "0.5868191", "0.5826552", "0.58166504", "0.57442975", "0.56419784", "0.55749905", "0.5567157", "0.55599034", "0.5513154", "0.55003047", "0.54819703", "0.5423093", "0.5415128", "0.5400822", "0.53776264", "0.52749085", "0.5263761", "0.5254...
0.80245316
0
Tests if a tab can be removed from a course tab list.
def test_remove_extra_panel_tab(self): for tab_type in utils.EXTRA_TAB_PANELS.keys(): tab = utils.EXTRA_TAB_PANELS.get(tab_type) # test removing with changed = True tab_test_setup = [ [tab], [tab, self.get_tab_type_dicts('x,y,z')], ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_extra_panel_tab(tab_type, course):\r\n # Copy course tabs\r\n course_tabs = copy.copy(course.tabs)\r\n changed = False\r\n # Check to see if open ended panel is defined in the course\r\n\r\n tab_panel = EXTRA_TAB_PANELS.get(tab_type)\r\n if tab_panel in course_tabs:\r\n # Add pa...
[ "0.6208827", "0.6198857", "0.6105022", "0.6102085", "0.5924644", "0.5914341", "0.58516246", "0.5850757", "0.5837051", "0.5817999", "0.58085763", "0.57428336", "0.57378507", "0.5733062", "0.57259154", "0.5707097", "0.5681328", "0.56547046", "0.5643359", "0.55955034", "0.559069...
0.6617974
0
These tests need a user in the DB so that the django Test Client can log them in. They inherit from the ModuleStoreTestCase class so that the mongodb collection will be cleared out before each test case execution and deleted afterwards.
def setUp(self): uname = 'testuser' email = 'test+courses@edx.org' password = 'foo' # Create the user so we can log them in. self.user = User.objects.create_user(uname, email, password) # Note that we do not actually need to do anything # for registrati...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setUp(self):\n self.client = Client()\n #creamos un usuario en la db\n self.user = User.objects.create_user('super', 'lennon@thebeatles.com', 'super')", "def setUp(self):\r\n super(SysadminBaseTestCase, self).setUp()\r\n self.user = UserFactory.create(username='test_user',\...
[ "0.7304307", "0.70889574", "0.700872", "0.7006511", "0.69746554", "0.6970943", "0.6969809", "0.6926403", "0.6915506", "0.6903875", "0.6897007", "0.68840337", "0.6875517", "0.68688333", "0.6854009", "0.6851336", "0.6850283", "0.6846306", "0.68429357", "0.6841768", "0.68378294"...
0.64876443
89
Returns an LMS link to the course with a jump_to to the provided location.
def get_lms_link_for_item(location, preview=False): assert(isinstance(location, Location)) if settings.LMS_BASE is None: return None if preview: lms_base = settings.FEATURES.get('PREVIEW_LMS_BASE') else: lms_base = settings.LMS_BASE return u"//{lms_base}/courses...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _jump_location_for_block(self, course_id, location):\n return reverse('jump_to', kwargs={'course_id': str(course_id), 'location': str(location)})", "def jump_to(request, course_id, location):\r\n try:\r\n course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id)\r\n usage...
[ "0.7354476", "0.67932355", "0.5813291", "0.55581236", "0.5531668", "0.54571736", "0.5449946", "0.54252106", "0.53421026", "0.5293685", "0.52584875", "0.52542233", "0.5253493", "0.52349454", "0.5110757", "0.5109469", "0.5062373", "0.50303024", "0.5017389", "0.4998675", "0.4972...
0.72087216
1
Return True if user allowed to access this course_id Note that the CMS permissions model is with respect to courses There is a superadmin permissions if user.is_staff is set Also, since we're unifying the user database between LMS and CAS, I'm presuming that the course instructor (formally known as admin) will not be i...
def has_course_access(user, course_key, role=CourseStaffRole): if GlobalStaff().has_user(user): return True return auth.has_access(user, role(course_key))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def have_permission(self, user, course_id):\n \"\"\"\n any([\n request.user.is_staff,\n CourseStaffRole(course_key).has_user(request.user),\n CourseInstructorRole(course_key).has_user(request.user)\n ])\n \"\"\"\n try:\n course_key = Co...
[ "0.7656988", "0.72760385", "0.7032005", "0.70202184", "0.6909985", "0.68928295", "0.6810983", "0.67863894", "0.6673236", "0.666978", "0.6624062", "0.6622626", "0.660802", "0.65862733", "0.65853745", "0.6555679", "0.65432173", "0.65432173", "0.6534138", "0.64613837", "0.645422...
0.7420068
1
List all courses available to the logged in user by iterating through all the courses
def _accessible_courses_list(request): courses = modulestore('direct').get_courses() # filter out courses that we don't have access to def course_filter(course): """ Get courses to which this user has access """ if GlobalStaff().has_user(request.user): r...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def course_listing(request):\r\n if GlobalStaff().has_user(request.user):\r\n # user has global access so no need to get courses from django groups\r\n courses = _accessible_courses_list(request)\r\n else:\r\n try:\r\n courses = _accessible_courses_list_from_groups(request)\r\...
[ "0.77574277", "0.76306665", "0.75440437", "0.74922025", "0.7427972", "0.73571897", "0.7306954", "0.73057514", "0.72690755", "0.72607094", "0.7230087", "0.7220387", "0.7159612", "0.714305", "0.7137631", "0.70632964", "0.7034862", "0.695829", "0.6904291", "0.68789583", "0.68118...
0.75729865
2
Returns the xblock that is the parent of the specified xblock, or None if it has no parent.
def get_parent_xblock(xblock): locator = xblock.location parent_locations = modulestore().get_parent_locations(locator,) if len(parent_locations) == 0: return None elif len(parent_locations) > 1: logging.error('Multiple parents have been found for %s', unicode(locator)) retu...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_parent(self):\n if self.parent:\n return self.parent()\n else:\n return None", "def get_parent(self):\n return BinaryNode.or_none(self.parent)", "def parent(self):\n if self._parent is not None:\n return self._parent()\n else:\n ...
[ "0.75751776", "0.74060917", "0.7267976", "0.703227", "0.69922054", "0.697867", "0.69064915", "0.68733263", "0.6864564", "0.6844111", "0.6841357", "0.68279415", "0.6778116", "0.6709119", "0.6704929", "0.6699876", "0.66408974", "0.6623355", "0.6622318", "0.6621685", "0.66181636...
0.86765325
0
Returns true if the specified xblock is a vertical that is treated as a unit. A unit is a vertical that is a direct child of a sequential (aka a subsection).
def is_unit(xblock): if xblock.category == 'vertical': parent_xblock = get_parent_xblock(xblock) parent_category = parent_xblock.category if parent_xblock else None return parent_category == 'sequential' return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_vertical(self):\n return self.start.y == self.end.y", "def xblock_has_own_studio_page(xblock):\r\n category = xblock.category\r\n\r\n if is_unit(xblock):\r\n return True\r\n elif category == 'vertical':\r\n parent_xblock = get_parent_xblock(xblock)\r\n return is_unit(p...
[ "0.6370668", "0.62590516", "0.60571074", "0.6011706", "0.5977037", "0.5969595", "0.5909437", "0.58994836", "0.5847695", "0.57373834", "0.5671345", "0.56585413", "0.56382114", "0.5606421", "0.5559394", "0.54478264", "0.54346997", "0.54096", "0.5407468", "0.5390406", "0.5374691...
0.8673918
0
View for handling orphan related requests. GET gets all of the current orphans. DELETE removes all orphans (requires is_staff access) An orphan is a block whose category is not in the DETACHED_CATEGORY list, is not the root, and is not reachable from the root via children
def orphan_handler(request, course_key_string): course_usage_key = CourseKey.from_string(course_key_string) if request.method == 'GET': if has_course_access(request.user, course_usage_key): return JsonResponse(modulestore().get_orphans(course_usage_key)) else: raise...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_mongo_orphan_delete(self):\r\n self.client.delete(self.orphan_url)\r\n orphans = json.loads(\r\n self.client.get(self.orphan_url, HTTP_ACCEPT='application/json').content\r\n )\r\n self.assertEqual(len(orphans), 0, \"Orphans not deleted {}\".format(orphans))", "def ...
[ "0.6024273", "0.5823454", "0.5687219", "0.5575355", "0.54789495", "0.54785293", "0.53066766", "0.52850163", "0.528204", "0.5264427", "0.5259968", "0.52466667", "0.513499", "0.50998235", "0.5083866", "0.507783", "0.5067476", "0.50606924", "0.49258888", "0.49126676", "0.4904673...
0.66706073
0
Returns true if the specified xblock is in the set of reorderable xblocks.
def _is_xblock_reorderable(xblock, context): return xblock.location in context['reorderable_items']
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def contains(self, block_):\n return block_ in self._inventory", "def reorder(self) -> bool:\n return bool(self._parser[self._key]['Reorder'])", "def _has_blocks_to_place(self, exclude=None):\n for block_ in self._inventory:\n if block_ != exclude:\n return True\n...
[ "0.6138349", "0.5898237", "0.58168286", "0.56957686", "0.55855304", "0.54648983", "0.54425824", "0.5403491", "0.53926337", "0.5386456", "0.5383076", "0.53356874", "0.53127664", "0.5308597", "0.52819514", "0.5277434", "0.52565503", "0.52447385", "0.5237897", "0.5235723", "0.52...
0.822594
0
Creates the test course.
def setUp(self): super(ChecklistTestCase, self).setUp() self.course = CourseFactory.create(org='mitX', number='333', display_name='Checklists Course') self.checklists_url = self.get_url()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_create_course(self):\r\n self.assert_created_course()", "def make_course(self, **kwargs):\r\n self.course = CourseFactory.create(**kwargs)\r\n user = UserFactory.create()\r\n CourseEnrollmentFactory.create(user=user, course_id=self.course.id)\r\n self.client.login(user...
[ "0.81679255", "0.7982984", "0.7730142", "0.7700838", "0.7678283", "0.7595566", "0.7366904", "0.7337337", "0.72811043", "0.72727233", "0.72699165", "0.7121768", "0.70748824", "0.70570207", "0.70274824", "0.69975615", "0.6990448", "0.69876397", "0.69704556", "0.69638795", "0.69...
0.6057229
72
Tests getting the HTML template for the checklists page).
def test_get_checklists_html(self): response = self.client.get(self.checklists_url, HTTP_ACCEPT='text/html') self.assertContains(response, "Getting Started With Studio") # The HTML generated will define the handler URL (for use by the Backbone model). self.assertContains(response, se...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get(self):\n response = self.client.get(self.url)\n\n # Standard response\n self.assertEqual(response.status_code, 200)\n self.assertTemplateUsed(\"td_biblio/entry_list.html\")", "def test_jc_view_list(self):\n \n test_response = self.client.get('/journal-club')...
[ "0.71062964", "0.687516", "0.68512386", "0.68461454", "0.68323356", "0.6818343", "0.68062866", "0.68062866", "0.66583884", "0.66469824", "0.6615012", "0.6585282", "0.64852595", "0.6469629", "0.6457404", "0.64320904", "0.64245987", "0.64208746", "0.64076316", "0.6400575", "0.6...
0.8375248
0
Add a course with odd characters in the fields
def setUp(self): super(TestCourseIndex, self).setUp() # had a problem where index showed course but has_access failed to retrieve it for non-staff self.odd_course = CourseFactory.create( org='test.org_1-2', number='test-2.3_course', display_name='dotted....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add():\n prev_courses = Course._file.read_db()\n course_name = input(\"Please, type course name >\")\n # check course for uniqueness/ instantiating blank class with one attribute\n c = Course(course_name)\n if c.is_course_exists():\n print(\"{} is already exists\"....
[ "0.6858193", "0.6553335", "0.6503176", "0.63983834", "0.63618886", "0.6221758", "0.6172086", "0.6148672", "0.6123605", "0.60864884", "0.60851014", "0.6059907", "0.60383654", "0.60129833", "0.59934986", "0.5844165", "0.58260006", "0.5814512", "0.5801554", "0.5785542", "0.57840...
0.0
-1
Test getting the list of courses and then pulling up their outlines
def check_index_and_outline(self, authed_client): index_url = '/course/' index_response = authed_client.get(index_url, {}, HTTP_ACCEPT='text/html') parsed_html = lxml.html.fromstring(index_response.content) course_link_eles = parsed_html.find_class('course-link') self.assert...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_course_list(self):\r\n request = self.factory.get('/course/')\r\n request.user = self.user\r\n\r\n course_location = SlashSeparatedCourseKey('Org1', 'Course1', 'Run1')\r\n self._create_course_with_access_groups(course_location, self.user)\r\n\r\n # get courses throug...
[ "0.7190278", "0.69108903", "0.6882419", "0.68466127", "0.6845148", "0.6808612", "0.6805149", "0.67477274", "0.66648674", "0.66631746", "0.6643098", "0.6594935", "0.65391845", "0.6534254", "0.6471445", "0.6464817", "0.64629585", "0.64183927", "0.6375251", "0.635674", "0.634955...
0.64934194
14
Make and register course_staff and ensure they can access the courses
def test_course_staff_access(self): course_staff_client, course_staff = self.create_non_staff_authed_user_client() for course in [self.course, self.odd_course]: permission_url = reverse_course_url('course_team_handler', course.id, kwargs={'email': course_staff.email}) self....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _check_staff(self, course):\r\n names = ['about_course', 'instructor_dashboard', 'progress']\r\n urls = self._reverse_urls(names, course)\r\n urls.extend([\r\n reverse('book', kwargs={'course_id': course.id.to_deprecated_string(),\r\n 'book_ind...
[ "0.70601666", "0.70054054", "0.69798744", "0.6927268", "0.6924122", "0.6710958", "0.6703854", "0.66779864", "0.6656873", "0.6630447", "0.66118187", "0.64916164", "0.64565134", "0.6450486", "0.6429216", "0.6377733", "0.6371229", "0.63478094", "0.6328286", "0.6277297", "0.62711...
0.73632693
0
Check that course is imported successfully in existing course and users have their access roles
def test_import_in_existing_course(self): # Create a non_staff user and add it to course staff only __, nonstaff_user = self.create_non_staff_authed_user_client(authenticate=False) auth.add_users(self.user, CourseStaffRole(self.course.id), nonstaff_user) course = self.store.get_cou...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_course_role(self):\r\n self.assertFalse(\r\n CourseStaffRole(self.course_key).has_user(self.student),\r\n \"Student has premature access to {}\".format(self.course_key)\r\n )\r\n CourseStaffRole(self.course_key).add_users(self.student)\r\n self.assertTrue(...
[ "0.65962934", "0.6315831", "0.6310669", "0.6183173", "0.61595726", "0.6120806", "0.6101824", "0.6099591", "0.60829186", "0.60530686", "0.60358083", "0.60356295", "0.60182637", "0.5992517", "0.59633094", "0.593728", "0.5934827", "0.59287196", "0.5901567", "0.58896446", "0.5888...
0.75724995
0
Get the item referenced by the UsageKey from the modulestore
def get_item_from_modulestore(usage_key, draft=False): store = modulestore('draft') if draft else modulestore('direct') return store.get_item(usage_key)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_item(self, usage_key, depth=0):\r\n store = self._get_modulestore_for_courseid(usage_key.course_key)\r\n return store.get_item(usage_key, depth)", "def get_item(self, usage_key, depth=0):\r\n try:\r\n return self.modules[usage_key.course_key][usage_key]\r\n except K...
[ "0.803646", "0.7903674", "0.7744498", "0.7548047", "0.6698435", "0.64615315", "0.643112", "0.6369471", "0.63381714", "0.63316506", "0.62985563", "0.62750745", "0.6216752", "0.62082964", "0.6136628", "0.6135334", "0.61137784", "0.61137784", "0.61066496", "0.6103757", "0.610139...
0.81675154
0
Creates the test course structure and a couple problems to 'edit'.
def setUp(self): super(TestEditItem, self).setUp() # create a chapter display_name = 'chapter created' resp = self.create_xblock(display_name=display_name, category='chapter') chap_usage_key = self.response_usage_key(resp) resp = self.create_xblock(parent_usage_key=...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize_course(self):\r\n self.module_store = editable_modulestore()\r\n\r\n # Create the course\r\n self.course = CourseFactory.create(org=TEST_COURSE_ORG,\r\n number=TEST_COURSE_NUMBER,\r\n display_nam...
[ "0.7018381", "0.6996799", "0.6938441", "0.69122815", "0.67263716", "0.66862714", "0.664583", "0.65468436", "0.6450929", "0.6422974", "0.6392716", "0.6382438", "0.636202", "0.6342081", "0.63231784", "0.6304903", "0.62673163", "0.6266121", "0.62348986", "0.6203075", "0.61973363...
0.6188529
21
Test deleting a child.
def test_delete_child(self): # Create 2 children of main course. resp_1 = self.create_xblock(display_name='child 1', category='chapter') resp_2 = self.create_xblock(display_name='child 2', category='chapter') chapter1_usage_key = self.response_usage_key(resp_1) chapter2_usag...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_user_delete_reddit_child(self):\n with app.app_context():\n with self.client:\n self.create_user()\n self.login_user()\n # link a reddit child model to test\n reddit_usr = Reddit_User(username=\"reddit_child\",\n ...
[ "0.7269696", "0.7150223", "0.71280277", "0.7073642", "0.7062418", "0.69919246", "0.688326", "0.6852254", "0.6839865", "0.68145704", "0.6787687", "0.6780783", "0.67622125", "0.67304665", "0.6686135", "0.6636123", "0.6597268", "0.65930104", "0.65794873", "0.6571691", "0.6544449...
0.7765915
0
Test reordering children that can be in the draft store.
def test_reorder_children(self): # Create 2 child units and re-order them. There was a bug about @draft getting added # to the IDs. unit_1_resp = self.create_xblock(parent_usage_key=self.seq_usage_key, category='vertical') unit_2_resp = self.create_xblock(parent_usage_key=self.seq_us...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_update_children(self):\r\n locator = BlockUsageLocator(\r\n CourseLocator(org='testx', offering='GreekHero', branch='draft'), 'chapter', 'chapter3'\r\n )\r\n block = modulestore().get_item(locator)\r\n pre_def_id = block.definition_locator.definition_id\r\n pr...
[ "0.6577329", "0.6518447", "0.6455369", "0.6165993", "0.61177516", "0.6009022", "0.5885912", "0.5833951", "0.57945186", "0.575732", "0.57532585", "0.57273424", "0.57218975", "0.5710531", "0.570882", "0.5686664", "0.5666127", "0.56481016", "0.5647712", "0.5629735", "0.5583546",...
0.66837627
0
Test creating a draft version of a public problem.
def test_make_draft(self): # Make problem public. self.client.ajax_post( self.problem_update_url, data={'publish': 'make_public'} ) self.assertIsNotNone(self.get_item_from_modulestore(self.problem_usage_key, False)) # Now make it draft, which means ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_make_public(self):\r\n # When the problem is first created, it is only in draft (because of its category).\r\n with self.assertRaises(ItemNotFoundError):\r\n self.get_item_from_modulestore(self.problem_usage_key, False)\r\n self.client.ajax_post(\r\n self.problem...
[ "0.7645153", "0.75474584", "0.71718425", "0.69222724", "0.68094856", "0.67921114", "0.65938973", "0.6283202", "0.6236917", "0.6183282", "0.6155887", "0.60976434", "0.60176694", "0.6015337", "0.59866476", "0.5983853", "0.59290695", "0.5895277", "0.5889469", "0.58538634", "0.58...
0.8243062
0
Test for calling get_preview_html. This test used to be specifically about Locators (ensuring that they did not get translated to Locations). The test now has questionable value.
def test_preview_fragment(self): course = CourseFactory.create() html = ItemFactory.create( parent_location=course.location, category="html", data={'data': "<html>foobar</html>"} ) request = RequestFactory().get('/dummy-url') request....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_tab_preview_html(self):\r\n preview_url = '/xblock/{}/student_view'.format(self.test_tab.location)\r\n\r\n resp = self.client.get(preview_url, HTTP_ACCEPT='application/json')\r\n self.assertEqual(resp.status_code, 200)\r\n resp_content = json.loads(resp.content)\r\n html...
[ "0.679996", "0.6470852", "0.6442356", "0.6406727", "0.63473344", "0.6330915", "0.62769324", "0.62417495", "0.61903113", "0.6158357", "0.6146106", "0.61105186", "0.60818624", "0.59712726", "0.59696233", "0.5946931", "0.5934959", "0.5934946", "0.5919753", "0.5919153", "0.591607...
0.6577575
1
Verify that a draft xblock's preview returns the expected HTML.
def test_draft_component_preview_html(self): modulestore('draft').convert_to_draft(self.vertical.location) draft_video = modulestore('draft').convert_to_draft(self.video.location) self.validate_preview_html(draft_video, 'student_view', can_edit=True, can_re...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_draft_container_preview_html(self):\r\n draft_unit = modulestore('draft').convert_to_draft(self.vertical.location)\r\n draft_child_container = modulestore('draft').convert_to_draft(self.child_container.location)\r\n draft_child_vertical = modulestore('draft').convert_to_draft(self.chi...
[ "0.79248405", "0.7910098", "0.74155086", "0.720898", "0.72029537", "0.71955", "0.71480775", "0.71013755", "0.7088378", "0.7068174", "0.6990248", "0.696258", "0.68916875", "0.68491536", "0.6802228", "0.6726791", "0.6671835", "0.65536153", "0.65401596", "0.65288323", "0.6500369...
0.776695
2
Asserts that self.ext_user is enrolled in self.course.
def assert_enrolled(self): self.assertTrue( CourseEnrollment.is_enrolled(self.ext_user, self.course.id), 'User ext_user should have been enrolled in the course' )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def assert_not_enrolled(self):\r\n self.assertFalse(\r\n CourseEnrollment.is_enrolled(self.ext_user, self.course.id),\r\n 'Did not expect ext_user to be enrolled in course'\r\n )", "def test_user_enrolled_to_classroom(self):\n self.client.force_authenticate(self.global_...
[ "0.73995084", "0.69607234", "0.67939365", "0.6661031", "0.6597933", "0.656861", "0.64343613", "0.63745004", "0.6346121", "0.63380015", "0.63207567", "0.62988734", "0.6291586", "0.62832373", "0.6252996", "0.6228883", "0.62266773", "0.6224496", "0.6157433", "0.61340237", "0.612...
0.8848327
0
User has requested course creation access.
def request_course_creator(request): user_requested_access(request.user) return JsonResponse({"Status": "OK"})
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_create_with_permissions(self):\n permissions = Permission.objects.filter(name__in=('Can add course mode', 'Can change course mode'))\n for permission in permissions:\n self.user.user_permissions.add(permission)\n\n self.assert_can_create_course()", "def _add_user(user, st...
[ "0.71359307", "0.69959563", "0.6974597", "0.68372804", "0.6832555", "0.6779414", "0.6763509", "0.6760642", "0.67405516", "0.6724685", "0.6634495", "0.6533061", "0.6511196", "0.64591885", "0.6420882", "0.63884664", "0.63836366", "0.6317964", "0.6311778", "0.63084114", "0.63065...
0.75073606
0
Return a package resource for the specified XBlock.
def xblock_resource(request, block_type, uri): # pylint: disable=unused-argument try: xblock_class = XBlock.load_class(block_type, settings.XBLOCK_SELECT_FUNCTION) content = xblock_class.open_local_resource(uri) except IOError: log.info('Failed to load xblock resource', exc_info=Tr...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def xblock_resource_pkg(block):\n # XModules are a special case because they map to different dirs for\n # sub-modules.\n module_name = block.__module__\n if module_name.startswith('xmodule.'):\n return module_name\n\n return module_name.rsplit('.', 1)[0]", "def xblock_resource(request, blo...
[ "0.7584072", "0.589946", "0.581237", "0.5676023", "0.5659006", "0.5594816", "0.53200305", "0.52900904", "0.5251955", "0.52289414", "0.52049756", "0.5172312", "0.5102771", "0.50852406", "0.50852406", "0.50852406", "0.49761835", "0.49324977", "0.49170926", "0.48867318", "0.4835...
0.5838558
2
Adds a user to the course creator table with status 'granted'. If appropriate, this method also adds the user to the course creator group maintained by authz.py. Caller must have staff permissions. If the user is already in the table, this method is a noop (state will not be changed). If the user is marked as is_staff,...
def add_user_with_status_granted(caller, user): if _add_user(user, CourseCreator.GRANTED): update_course_creator_group(caller, user, True)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _add_user(user, state):\r\n if not user.is_staff and CourseCreator.objects.filter(user=user).count() == 0:\r\n entry = CourseCreator(user=user, state=state)\r\n entry.save()\r\n return True\r\n\r\n return False", "def create(self, request, *args, **kwargs):\n user = request....
[ "0.7045582", "0.69607013", "0.67260396", "0.6401875", "0.63515174", "0.63192236", "0.6234535", "0.6234283", "0.6226579", "0.62146103", "0.6127801", "0.61241114", "0.611851", "0.603447", "0.59980774", "0.59920496", "0.5960388", "0.59308314", "0.5919645", "0.5915431", "0.590638...
0.82827884
0
Returns the status for a particular user, or None if user is not in the table.
def get_course_creator_status(user): user = CourseCreator.objects.filter(user=user) if user.count() == 0: return None else: # User is defined to be unique, can assume a single entry. return user[0].state
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_status(self, user_name):\n uri = self.base_uri + '/status'\n response = requests.get(uri)\n if response.status_code == 404:\n return None\n return response.json()", "def by_user_name(cls, user_name, status=None, db_session=None): # pylint: disable=W0237,W0221\n ...
[ "0.7386233", "0.67538995", "0.64258575", "0.63435566", "0.6295776", "0.61060494", "0.6090281", "0.605888", "0.6039517", "0.6014934", "0.5990273", "0.5990132", "0.59138733", "0.59129906", "0.5908832", "0.5898844", "0.5891553", "0.5866801", "0.58409977", "0.5838047", "0.5796307...
0.6065589
7
User has requested course creator access. This changes the user state to CourseCreator.PENDING, unless the user state is already CourseCreator.GRANTED, in which case this method is a noop.
def user_requested_access(user): user = CourseCreator.objects.get(user=user) if user.state != CourseCreator.GRANTED: user.state = CourseCreator.PENDING user.save()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_course_creator_status(user):\r\n if user.is_staff:\r\n course_creator_status = 'granted'\r\n elif settings.FEATURES.get('DISABLE_COURSE_CREATION', False):\r\n course_creator_status = 'disallowed_for_this_site'\r\n elif settings.FEATURES.get('ENABLE_CREATOR_GROUP', False):\r\n ...
[ "0.72248966", "0.6726453", "0.66918606", "0.6596017", "0.65390193", "0.63108706", "0.61151266", "0.5907333", "0.58677197", "0.5854878", "0.58098066", "0.57775885", "0.576442", "0.5752597", "0.5685052", "0.5631291", "0.5628691", "0.5624487", "0.5613671", "0.5575426", "0.556892...
0.7794705
0
Decode the json into CourseGradingModel and save any changes. Returns the modified model. Probably not the usual path for updates as it's too coarse grained.
def update_from_json(course_key, jsondict, user): descriptor = modulestore('direct').get_course(course_key) graders_parsed = [CourseGradingModel.parse_grader(jsonele) for jsonele in jsondict['graders']] descriptor.raw_grader = graders_parsed descriptor.grade_cutoffs = jsondict['g...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_grader_from_json(course_key, grader, user):\r\n descriptor = modulestore('direct').get_course(course_key)\r\n\r\n # parse removes the id; so, grab it before parse\r\n index = int(grader.get('id', len(descriptor.raw_grader)))\r\n grader = CourseGradingModel.parse_grader(grader...
[ "0.5649817", "0.5570373", "0.550537", "0.51513", "0.51344603", "0.4979744", "0.49745756", "0.49474314", "0.48933777", "0.4882083", "0.48600295", "0.4855213", "0.485155", "0.4825", "0.48127502", "0.4806406", "0.48033172", "0.4799812", "0.4798929", "0.47937593", "0.4785157", ...
0.7259386
0
Create or update the grade cutoffs for the given course. Returns sent in cutoffs (ie., no extra db fetch).
def update_cutoffs_from_json(course_key, cutoffs, user): descriptor = modulestore('direct').get_course(course_key) descriptor.grade_cutoffs = cutoffs modulestore('direct').update_item(descriptor, user.id) return cutoffs
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_course(self):\n # ensure that updating course is exists\n if self.is_course_exists():\n db = Course._file.read_db()\n for crs_i in range(len(db[\"courses\"])):\n if db[\"courses\"][crs_i][\"course_name\"] == self._course_name:\n\n # e...
[ "0.51846194", "0.51745105", "0.50548244", "0.49404442", "0.49351117", "0.48037493", "0.4752631", "0.47008052", "0.46755433", "0.46601358", "0.46269387", "0.4617657", "0.45919478", "0.4588561", "0.45523727", "0.4539934", "0.45314094", "0.45313957", "0.4525174", "0.44920963", "...
0.66991794
0
Get a list of all the cohorts in the given course.
def get_course_cohorts(course_key): return list(CourseUserGroup.objects.filter( course_id=course_key, group_type=CourseUserGroup.COHORT ))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def all_cohorts(self):\n\n with sqlite3.connect(self.db_path) as conn:\n conn.row_factory = lambda cursor, row: Cohort(row [1])\n\n db_cursor = conn.cursor()\n\n db_cursor.execute(\"\"\"\n select c.id,\n c.name\n \n from c...
[ "0.72178966", "0.71379817", "0.6503931", "0.6002485", "0.5745192", "0.5733698", "0.57297593", "0.572106", "0.5678094", "0.56237936", "0.5594237", "0.55874753", "0.5529663", "0.5499779", "0.54439884", "0.54244393", "0.5407849", "0.5359507", "0.5290353", "0.52855694", "0.524121...
0.75227463
0
Add a cohort to a course. Raises ValueError if a cohort of the same name already exists.
def add_cohort(course_key, name): log.debug("Adding cohort %s to %s", name, course_key) if CourseUserGroup.objects.filter(course_id=course_key, group_type=CourseUserGroup.COHORT, name=name).exists(): raise ValueError("Can't...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_user_to_course_cohort(cohort_name, course_id, user):\n if cohort_name is not None:\n cohort = get_cohort_by_name(course_id, cohort_name)\n try:\n add_user_to_cohort(cohort, user)\n except ValueError:\n # user already in cohort, probably because they were un-enr...
[ "0.7411559", "0.6575758", "0.5786237", "0.55977887", "0.535708", "0.52517265", "0.5121339", "0.5109515", "0.4891846", "0.4873132", "0.4830319", "0.48068598", "0.4799947", "0.476845", "0.4714299", "0.4659609", "0.46565044", "0.46412566", "0.4627862", "0.45428395", "0.45071676"...
0.8046251
0
Given a course with no discussion set up, add the discussions and set the cohort config appropriately.
def config_course_cohorts(course, discussions, cohorted, cohorted_discussions=None, auto_cohort=None, auto_cohort_groups=None): def to_id(name): return TestCohorts.topic_name...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_auto_cohorting(self):\r\n course = modulestore().get_course(self.toy_course_key)\r\n self.assertFalse(course.is_cohorted)\r\n\r\n user1 = User.objects.create(username=\"test\", email=\"a@b.com\")\r\n user2 = User.objects.create(username=\"test2\", email=\"a2@b.com\")\r\n ...
[ "0.5887558", "0.5800319", "0.5650519", "0.5624122", "0.5586286", "0.5522197", "0.5503554", "0.5482938", "0.53706926", "0.535655", "0.5355799", "0.5347338", "0.52852714", "0.5241532", "0.5207386", "0.5179276", "0.5115453", "0.50200117", "0.49382794", "0.49276686", "0.4920305",...
0.6328577
0
Make sure get_cohort() does the right thing when the course is cohorted
def test_get_cohort(self): course = modulestore().get_course(self.toy_course_key) self.assertEqual(course.id, self.toy_course_key) self.assertFalse(course.is_cohorted) user = User.objects.create(username="test", email="a@b.com") other_user = User.objects.create(username="t...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_auto_cohorting(self):\r\n course = modulestore().get_course(self.toy_course_key)\r\n self.assertFalse(course.is_cohorted)\r\n\r\n user1 = User.objects.create(username=\"test\", email=\"a@b.com\")\r\n user2 = User.objects.create(username=\"test2\", email=\"a2@b.com\")\r\n ...
[ "0.75483507", "0.71042997", "0.67360514", "0.65798897", "0.6390478", "0.63433707", "0.6252458", "0.62388825", "0.61808205", "0.61731297", "0.6044916", "0.60406697", "0.5922586", "0.59072816", "0.58652526", "0.5830274", "0.5692265", "0.56910527", "0.56442904", "0.56329745", "0...
0.8326423
0
Split a string both by commas and whitespice. Returns a list.
def split_by_comma_and_whitespace(s): return re.split(r'[\s,]+', s)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def split_by_comma(s):\n return s.strip().split(\",\")", "def separate_comma(s):\n return s.split(',')", "def split(self, text):\n\n return [x.strip() for x in text.split(\",\")]", "def split_by_comma_and_whitespace(a_str):\r\n return re.split(r'[\\s,]', a_str)", "def split(text, delim=',')...
[ "0.816652", "0.7900309", "0.7797788", "0.7789005", "0.75599337", "0.74911696", "0.73764133", "0.7239977", "0.71966535", "0.71398956", "0.7094939", "0.7080222", "0.6858236", "0.68579817", "0.6789871", "0.6789245", "0.67791945", "0.6742892", "0.6726954", "0.672431", "0.6710972"...
0.80035305
1
Returns the nonexpired modes for a particular course as a dictionary with the mode slug as the key
def modes_for_course_dict(cls, course_id): return {mode.slug: mode for mode in cls.modes_for_course(course_id)}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def modes_for_course(cls, course_id):\r\n now = datetime.now(pytz.UTC)\r\n found_course_modes = cls.objects.filter(Q(course_id=course_id) &\r\n (Q(expiration_datetime__isnull=True) |\r\n Q(expiration_datetim...
[ "0.7232235", "0.63168055", "0.6103397", "0.5985326", "0.59787464", "0.5808463", "0.5735897", "0.55788696", "0.55125767", "0.5469249", "0.54340094", "0.5136047", "0.5058511", "0.50214475", "0.50200707", "0.5008902", "0.5000589", "0.49389744", "0.49258047", "0.49217954", "0.491...
0.73644745
0
Assert that the HTML_ACCEPT_LANGUAGE header in request is equal to value
def assertAcceptEquals(self, value, request): self.assertEquals( value, request.META.get('HTTP_ACCEPT_LANGUAGE', UNSET) )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_00_i18n_anonymous(self):\r\n # First default 'en' locale\r\n with self.app as c:\r\n err_msg = \"The page should be in English\"\r\n res = c.get('/', headers=[('Accept-Language', 'en')])\r\n assert \"Community\" in res.data, err_msg\r\n # Second with '...
[ "0.70019895", "0.6895065", "0.644286", "0.64406085", "0.6400266", "0.6361503", "0.6160545", "0.61283016", "0.60634065", "0.6015266", "0.6003633", "0.59594256", "0.5931071", "0.59233546", "0.5793865", "0.5793741", "0.5791206", "0.5748254", "0.57411987", "0.57391906", "0.567280...
0.8174936
0
Assert that the 'django_language' set in request.session is equal to value
def assertSessionLangEquals(self, value, request): self.assertEquals( value, request.session.get('django_language', UNSET) )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def testLanguage(self):\n if self.language in tools.LANGUAGES:\n self.assertEqual(\n self.language,\n self.config.language\n )\n else:\n self.assertNotEqual(\n self.language,\n self.config.language\n ...
[ "0.70539224", "0.69873303", "0.68148124", "0.6618676", "0.650155", "0.64081067", "0.636695", "0.6145281", "0.60734427", "0.60436296", "0.6028737", "0.60234886", "0.60087025", "0.5995479", "0.59859586", "0.597668", "0.5973735", "0.59586847", "0.5881438", "0.58729535", "0.58487...
0.8901172
0
Checks if a csv string of IP addresses contains valid values. If not, raises a ValidationError.
def _valid_ip_addresses(self, addresses): if addresses == '': return '' error_addresses = [] for addr in addresses.split(','): address = addr.strip() if not self._is_valid_ip(address): error_addresses.append(address) if error_ad...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_ip_address(data, valid_values=None):\n\n msg = None\n try:\n # netaddr.core.ZEROFILL is only applicable to IPv4.\n # it will remove leading zeros from IPv4 address octets.\n ip = netaddr.IPAddress(validate_no_whitespace(data),\n flags=netaddr.co...
[ "0.652854", "0.6286738", "0.616148", "0.61436814", "0.61333036", "0.6101916", "0.609976", "0.59218544", "0.59144664", "0.590527", "0.587627", "0.5869379", "0.5830833", "0.58259165", "0.5823761", "0.58082837", "0.58034104", "0.5786053", "0.5778254", "0.57737106", "0.5770012", ...
0.74840534
0
Returns whether or not the given course id is embargoed. If course has not been explicitly embargoed, returns False.
def is_embargoed(cls, course_id): try: record = cls.objects.get(course_id=course_id) return record.embargoed except cls.DoesNotExist: return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_cid(self):\n return hasattr(self, 'cid')", "def is_editable(self):\n return self.load_model().is_editable_in_committee()", "def is_course_based_activity(self):\n return False", "def isCourseObject(self):\n return 'Course' == self.ecparent.Type()", "def is_indeed(self) ->...
[ "0.571564", "0.5700311", "0.56206816", "0.5574749", "0.55014163", "0.5458043", "0.54189885", "0.54026985", "0.5291921", "0.5282455", "0.5270996", "0.526089", "0.5256232", "0.5224539", "0.5202132", "0.52005875", "0.51998496", "0.5164968", "0.5153223", "0.5147451", "0.5143384",...
0.8100279
0
Test for 403 error code when the namespace of the request is invalid
def test_invalid_namespace(self): self.attempt_login(403, ns="http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_no_permission(self):\n self.assertStatusCode(self.url, 403)", "def test_no_permission(self):\n self.assertStatusCode(self.url, 403)", "def test_no_permission(self):\n self.assertStatusCode(self.url, 403)", "def test_no_permission(self):\n self.assertStatusCode(self.url, 4...
[ "0.7064615", "0.7064615", "0.7064615", "0.7064615", "0.68873537", "0.68602246", "0.6800279", "0.67830783", "0.6674247", "0.65473664", "0.6533414", "0.6531262", "0.650604", "0.64331985", "0.6380802", "0.6375254", "0.6371384", "0.62913907", "0.62800556", "0.6251612", "0.6238318...
0.7225206
0
Tests that we get the error page when there is no REMOTE_USER or ShibIdentityProvider in request.META
def test_exception_shib_login(self): no_remote_user_request = self.request_factory.get('/shib-login') no_remote_user_request.META.update({'Shib-Identity-Provider': IDP}) no_remote_user_response = shib_login(no_remote_user_request) self.assertEqual(no_remote_user_response.status_code,...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_unknown_user(self):\n self.sign_in()\n response = self.client.get(reverse('backend:user_details', args=(0,)))\n self.assertEqual(response.status_code, 404)", "def test_no_user(self):\n self.request.user = None\n result = user_id_get_view(self.request)['d']\n sel...
[ "0.65883374", "0.6355012", "0.6320179", "0.6320179", "0.6320179", "0.62937874", "0.62937874", "0.62937874", "0.62937874", "0.6243052", "0.6243052", "0.6168418", "0.61602145", "0.61124283", "0.60756344", "0.60743517", "0.6044747", "0.60415435", "0.6037775", "0.6005141", "0.600...
0.6977676
0
Returns the current request's microsite configuration
def get_configuration(): if not hasattr(CURRENT_REQUEST_CONFIGURATION, 'data'): return {} return CURRENT_REQUEST_CONFIGURATION.data
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_request_in_microsite():\r\n return get_configuration()", "def get_config(site='self'):\n path='/sites/%s/configuration' % (site)\n return _api_request('GET', path)", "def _set_current_microsite(microsite_config_key, subdomain, domain):\r\n config = settings.MICROSITE_CONFIGURATION[microsite_...
[ "0.75670743", "0.68367827", "0.65291166", "0.6349067", "0.62205786", "0.6142121", "0.59721845", "0.59165907", "0.5885853", "0.5795082", "0.5740817", "0.5732817", "0.5732817", "0.57301784", "0.57049394", "0.57049394", "0.57049394", "0.57049394", "0.57049394", "0.57049394", "0....
0.60350794
6
Returns a boolean, True if the course is currently asking for reverification, else False.
def window_open_for_course(cls, course_id): now = datetime.now(pytz.UTC) return cls.get_window(course_id, now) is not None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def IsRerun(self):\n return self.prev_test_context is not None", "def refundable(self):\r\n course_mode = CourseMode.mode_for_course(self.course_id, 'verified')\r\n if course_mode is None:\r\n return False\r\n else:\r\n return True", "def verify(self) -> Optional[p...
[ "0.66717744", "0.6571183", "0.6417172", "0.6361787", "0.6287003", "0.6275021", "0.6230713", "0.62212384", "0.6202278", "0.616559", "0.6150642", "0.6148816", "0.61302567", "0.60884106", "0.60347724", "0.6034685", "0.6034685", "0.60331064", "0.60262495", "0.60262495", "0.600172...
0.0
-1
Fake course ids, since we don't have to have full django settings (common tests run without the lms settings imported)
def setUp(self): self.full_id = 'edX/full/2012_Fall' self.toy_id = 'edX/toy/2012_Fall'
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_course_list_with_same_course_id(self):\r\n # create and log in a non-staff user\r\n self.user = UserFactory()\r\n request = self.factory.get('/course')\r\n request.user = self.user\r\n self.client.login(username=self.user.username, password='test')\r\n\r\n cou...
[ "0.6922666", "0.66794384", "0.6479081", "0.64218354", "0.6421512", "0.6382538", "0.6350001", "0.63125557", "0.6271653", "0.6226286", "0.6139685", "0.6139685", "0.6136524", "0.61311406", "0.6119131", "0.6103456", "0.607585", "0.60752445", "0.60687196", "0.6065809", "0.6051397"...
0.0
-1
Check whether this user has access to this role (either direct or implied)
def has_access(user, role): if not user.is_active: return False # do cheapest check first even tho it's not the direct one if GlobalStaff().has_user(user): return True # CourseCreator is odd b/c it can be disabled via config if isinstance(role, CourseCreatorRole): # c...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def current_user_has_access(self):\n return self.user_has_access(users.get_current_user())", "def has_access(self, user):\n if user.is_superuser:\n return True\n return self.user_objects(user).filter(id=self.id).exists()", "def is_accessible(self):\n return current_user.is_au...
[ "0.80095404", "0.77857006", "0.74254054", "0.74254054", "0.74188846", "0.74188846", "0.7417059", "0.7395089", "0.73769945", "0.7344698", "0.7311758", "0.72921556", "0.7271156", "0.72625476", "0.72544855", "0.7249851", "0.7239227", "0.72230434", "0.7220766", "0.72075987", "0.7...
0.7508032
2
Internal function to check whether the caller has authority to manipulate this role
def _check_caller_authority(caller, role): if not (caller.is_authenticated() and caller.is_active): raise PermissionDenied # superuser if GlobalStaff().has_user(caller): return if isinstance(role, (GlobalStaff, CourseCreatorRole)): raise PermissionDenied elif isinst...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_role(self, role):\n return False", "def is_administrator(self):\n return False", "def _validate_override_role_called(self):\n was_called = self.__override_role_called\n self.__override_role_called = False\n return was_called", "def has_permission(self):\n ret...
[ "0.6995449", "0.69282985", "0.68762815", "0.6835787", "0.67969644", "0.67969644", "0.6786872", "0.6740768", "0.67352164", "0.67352164", "0.6734431", "0.6698017", "0.6656726", "0.6656726", "0.6649501", "0.6592356", "0.6569191", "0.65643847", "0.65643847", "0.65600437", "0.6547...
0.75040823
0