function
stringlengths
11
56k
repo_name
stringlengths
5
60
features
list
def prepare_request(next_link=None): if not next_link:
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def extract_data(pipeline_response): deserialized = self._deserialize("BackupPoliciesList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) return None, iter(list_of_elem)
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def get( self, resource_group_name: str, account_name: str, backup_policy_name: str, **kwargs: Any
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def _create_initial( self, resource_group_name: str, account_name: str, backup_policy_name: str, body: "_models.BackupPolicy", **kwargs: Any
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def begin_create( self, resource_group_name: str, account_name: str, backup_policy_name: str, body: "_models.BackupPolicy", **kwargs: Any
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def get_long_running_output(pipeline_response): response = pipeline_response.http_response deserialized = self._deserialize('BackupPolicy', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def _update_initial( self, resource_group_name: str, account_name: str, backup_policy_name: str, body: "_models.BackupPolicyPatch", **kwargs: Any
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def begin_update( self, resource_group_name: str, account_name: str, backup_policy_name: str, body: "_models.BackupPolicyPatch", **kwargs: Any
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def get_long_running_output(pipeline_response): response = pipeline_response.http_response deserialized = self._deserialize('BackupPolicy', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def _delete_initial( self, resource_group_name: str, account_name: str, backup_policy_name: str, **kwargs: Any
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def begin_delete( self, resource_group_name: str, account_name: str, backup_policy_name: str, **kwargs: Any
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {})
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def logic(actions): key = actions['key'] if key == "a": #Here is our one line of text, it will speak when we press a spk(my_name) elif key == "s": #Here is our number, it will speak when we press s spk(my_age) elif key == "d": #Here is our multiline text example. It will speak when we press d spk(my_song)
frastlin/PyAudioGame
[ 5, 4, 5, 2, 1420973210 ]
def get_performance_dashboard(): # All statistics are as of last night this matches the existing performance platform # and avoids the need to query notifications. if request.args: # Is it ok to reuse this? - should probably create a new one validate(request.args, performance_dashboard_request) # If start and end date are not set, we are expecting today's stats. today = str(datetime.utcnow().date()) start_date = datetime.strptime(request.args.get('start_date', today), '%Y-%m-%d').date() end_date = datetime.strptime(request.args.get('end_date', today), '%Y-%m-%d').date() total_for_all_time = get_total_notifications_for_date_range(start_date=None, end_date=None) total_notifications, emails, sms, letters = transform_results_into_totals(total_for_all_time) totals_for_date_range = get_total_notifications_for_date_range(start_date=start_date, end_date=end_date) processing_time_results = get_processing_time_percentage_for_date_range(start_date=start_date, end_date=end_date) services = get_live_services_with_organisation() stats = { "total_notifications": total_notifications, "email_notifications": emails, "sms_notifications": sms, "letter_notifications": letters, "notifications_by_type": transform_into_notification_by_type_json(totals_for_date_range), "processing_time": transform_processing_time_results_to_json(processing_time_results), "live_service_count": len(services), "services_using_notify": transform_services_to_json(services) } return jsonify(stats)
alphagov/notifications-api
[ 56, 23, 56, 6, 1447855037 ]
def transform_into_notification_by_type_json(total_notifications): j = [] for x in total_notifications: j.append({"date": x.bst_date, "emails": x.emails, "sms": x.sms, "letters": x.letters}) return j
alphagov/notifications-api
[ 56, 23, 56, 6, 1447855037 ]
def test_unknown_command(self): """Should fail if the command is not recognized.""" r = support.run_command('alias fake') self.assertTrue(r.failed, 'should have failed') self.assertEqual(r.errors[0].code, 'UNKNOWN_COMMAND')
sernst/cauldron
[ 78, 127, 78, 24, 1461686724 ]
def test_add(self): """...""" p = self.get_temp_path('aliaser') r = support.run_command('alias add test "{}" --temporary'.format(p)) self.assertFalse(r.failed, 'should not have failed')
sernst/cauldron
[ 78, 127, 78, 24, 1461686724 ]
def test_empty(self): """...""" r = support.run_command('alias add') self.assertTrue(r.failed, 'should have failed') self.assertEqual(r.errors[0].code, 'MISSING_ARG')
sernst/cauldron
[ 78, 127, 78, 24, 1461686724 ]
def test_autocomplete_alias(self): """...""" result = support.autocomplete('alias add fake-alias-not-real') self.assertEqual(len(result), 0)
sernst/cauldron
[ 78, 127, 78, 24, 1461686724 ]
def test1(): SINK(SOURCE)
github/codeql
[ 5783, 1304, 5783, 842, 1533054951 ]
def source(): return SOURCE
github/codeql
[ 5783, 1304, 5783, 842, 1533054951 ]
def test3(): t = source() SINK(t)
github/codeql
[ 5783, 1304, 5783, 842, 1533054951 ]
def test5(): t = source() sink(t)
github/codeql
[ 5783, 1304, 5783, 842, 1533054951 ]
def test7(cond): if cond: t = SOURCE else: t = "Safe" if cond: SINK(t)
github/codeql
[ 5783, 1304, 5783, 842, 1533054951 ]
def sink2(arg): sink(arg)
github/codeql
[ 5783, 1304, 5783, 842, 1533054951 ]
def test8(cond): t = source2() sink2(t)
github/codeql
[ 5783, 1304, 5783, 842, 1533054951 ]
def test9(cond): if cond: t = "Safe" else: t = SOURCE sink3(cond, t)
github/codeql
[ 5783, 1304, 5783, 842, 1533054951 ]
def hub(arg): return arg
github/codeql
[ 5783, 1304, 5783, 842, 1533054951 ]
def test12(): t = "safe" t = hub(t) SINK(t)
github/codeql
[ 5783, 1304, 5783, 842, 1533054951 ]
def test13(): t = module.dangerous SINK(t)
github/codeql
[ 5783, 1304, 5783, 842, 1533054951 ]
def test15(): t = module.safe2 SINK(t)
github/codeql
[ 5783, 1304, 5783, 842, 1533054951 ]
def test20(cond): if cond: t = CUSTOM_SOURCE else: t = SOURCE if cond: CUSTOM_SINK(t) else: SINK(t)
github/codeql
[ 5783, 1304, 5783, 842, 1533054951 ]
def test22(cond): if cond: t = CUSTOM_SOURCE else: t = SOURCE t = TAINT_FROM_ARG(t) if cond: CUSTOM_SINK(t) else: SINK(t)
github/codeql
[ 5783, 1304, 5783, 842, 1533054951 ]
def test23(): with SOURCE as t: SINK(t)
github/codeql
[ 5783, 1304, 5783, 842, 1533054951 ]
def test_update_extend(x, y): l = [SOURCE] d = {"key" : SOURCE} x.extend(l) y.update(d) SINK(x[0]) SINK(y["key"]) l2 = list(l) d2 = dict(d)
github/codeql
[ 5783, 1304, 5783, 842, 1533054951 ]
def test_diff_for_humans(): with pendulum.test(pendulum.datetime(2016, 8, 29)): diff_for_humans()
sdispater/pendulum
[ 5366, 323, 5366, 238, 1467070673 ]
def setUp(self): filepath = os.path.join(PymatgenTest.TEST_FILES_DIR, "POSCAR") p = Poscar.from_file(filepath) self.cssr = Cssr(p.structure)
materialsproject/pymatgen
[ 1063, 732, 1063, 235, 1319343039 ]
def test_from_file(self): filename = os.path.join(PymatgenTest.TEST_FILES_DIR, "Si.cssr") cssr = Cssr.from_file(filename) self.assertIsInstance(cssr.structure, Structure)
materialsproject/pymatgen
[ 1063, 732, 1063, 235, 1319343039 ]
def _user_module_changed(self, name, old, new): if self.shell is not None: self.shell.user_module = new
mattvonrocketstein/smash
[ 12, 1, 12, 10, 1321798817 ]
def _user_ns_changed(self, name, old, new): if self.shell is not None: self.shell.user_ns = new self.shell.init_user_ns()
mattvonrocketstein/smash
[ 12, 1, 12, 10, 1321798817 ]
def __init__(self, **kwargs): super(IPythonKernel, self).__init__(**kwargs) # Initialize the InteractiveShell subclass self.shell = self.shell_class.instance(parent=self, profile_dir=self.profile_dir, user_module=self.user_module, user_ns=self.user_ns, kernel=self, ) self.shell.displayhook.session = self.session self.shell.displayhook.pub_socket = self.iopub_socket self.shell.displayhook.topic = self._topic('execute_result') self.shell.display_pub.session = self.session self.shell.display_pub.pub_socket = self.iopub_socket self.shell.data_pub.session = self.session self.shell.data_pub.pub_socket = self.iopub_socket # TMP - hack while developing self.shell._reply_content = None self.comm_manager = CommManager(shell=self.shell, parent=self, kernel=self) self.comm_manager.register_target( 'ipython.widget', Widget.handle_comm_opened) self.shell.configurables.append(self.comm_manager) comm_msg_types = ['comm_open', 'comm_msg', 'comm_close'] for msg_type in comm_msg_types: self.shell_handlers[msg_type] = getattr( self.comm_manager, msg_type)
mattvonrocketstein/smash
[ 12, 1, 12, 10, 1321798817 ]
def banner(self): return self.shell.banner
mattvonrocketstein/smash
[ 12, 1, 12, 10, 1321798817 ]
def set_parent(self, ident, parent): """Overridden from parent to tell the display hook and output streams about the parent message. """ super(IPythonKernel, self).set_parent(ident, parent) self.shell.set_parent(parent)
mattvonrocketstein/smash
[ 12, 1, 12, 10, 1321798817 ]
def _restore_input(self): """Restore raw_input, getpass""" if PY3: builtin_mod.input = self._sys_raw_input else: builtin_mod.raw_input = self._sys_raw_input builtin_mod.input = self._sys_eval_input getpass.getpass = self._save_getpass
mattvonrocketstein/smash
[ 12, 1, 12, 10, 1321798817 ]
def execution_count(self): return self.shell.execution_count
mattvonrocketstein/smash
[ 12, 1, 12, 10, 1321798817 ]
def execution_count(self, value): # Ignore the incrememnting done by KernelBase, in favour of our shell's # execution counter. pass
mattvonrocketstein/smash
[ 12, 1, 12, 10, 1321798817 ]
def do_complete(self, code, cursor_pos): # FIXME: IPython completers currently assume single line, # but completion messages give multi-line context # For now, extract line from cell, based on cursor_pos: if cursor_pos is None: cursor_pos = len(code) line, offset = line_at_cursor(code, cursor_pos) line_cursor = cursor_pos - offset txt, matches = self.shell.complete('', line, line_cursor) return {'matches': matches, 'cursor_end': cursor_pos, 'cursor_start': cursor_pos - len(txt), 'metadata': {}, 'status': 'ok'}
mattvonrocketstein/smash
[ 12, 1, 12, 10, 1321798817 ]
def do_history(self, hist_access_type, output, raw, session=None, start=None, stop=None, n=None, pattern=None, unique=False): if hist_access_type == 'tail': hist = self.shell.history_manager.get_tail(n, raw=raw, output=output, include_latest=True) elif hist_access_type == 'range': hist = self.shell.history_manager.get_range(session, start, stop, raw=raw, output=output) elif hist_access_type == 'search': hist = self.shell.history_manager.search( pattern, raw=raw, output=output, n=n, unique=unique) else: hist = [] return {'history': list(hist)}
mattvonrocketstein/smash
[ 12, 1, 12, 10, 1321798817 ]
def do_is_complete(self, code): status, indent_spaces = self.shell.input_transformer_manager.check_complete( code) r = {'status': status} if status == 'incomplete': r['indent'] = ' ' * indent_spaces return r
mattvonrocketstein/smash
[ 12, 1, 12, 10, 1321798817 ]
def do_clear(self): self.shell.reset(False) return dict(status='ok')
mattvonrocketstein/smash
[ 12, 1, 12, 10, 1321798817 ]
def __init__(self, Asset=None, status=None, *args, **kw_args): """Initialises a new 'ErpInventory' instance. @param Asset: @param status: """ self._Asset = None self.Asset = Asset self.status = status super(ErpInventory, self).__init__(*args, **kw_args)
rwl/PyCIM
[ 68, 33, 68, 7, 1238978196 ]
def getAsset(self):
rwl/PyCIM
[ 68, 33, 68, 7, 1238978196 ]
def setAsset(self, value): if self._Asset is not None: self._Asset._ErpInventory = None self._Asset = value if self._Asset is not None: self._Asset.ErpInventory = None self._Asset._ErpInventory = self
rwl/PyCIM
[ 68, 33, 68, 7, 1238978196 ]
def __init__(self, x): self.val = x self.left = None self.right = None
jiadaizhao/LeetCode
[ 39, 21, 39, 2, 1502171846 ]
def sumEvenGrandparent(self, root: TreeNode) -> int: total = 0 def dfs(root, p, gp): if root is None: return nonlocal total if gp and (gp.val & 1) == 0: total += root.val dfs(root.left, root, p) dfs(root.right, root, p)
jiadaizhao/LeetCode
[ 39, 21, 39, 2, 1502171846 ]
def __init__(self): """ The constructor ... :return: """ # Call the constructor of the base class super(MemoryPlotter, self).__init__() # -- Attributes -- # A data structure to store the memory (de)allocation information self.allocation = None
Stargrazer82301/CAAPR
[ 8, 2, 8, 1, 1453231962 ]
def default_input(): """ This function ... :return: """ return "memory.dat"
Stargrazer82301/CAAPR
[ 8, 2, 8, 1, 1453231962 ]
def prepare_data(self): """ This function ... :return: """ # Inform the user log.info("Preparing the input data into plottable format...") # Get the number of processes ranks = np.unique(self.table["Process rank"]) assert len(ranks) == max(ranks) + 1 processes = len(ranks) # Initialize the data structure to contain the memory usage information in plottable format self.data = [Map({"times": [], "memory": []}) for i in range(processes)] # Loop over the different entries in the memory table for i in range(len(self.table)): # Get the process rank rank = self.table["Process rank"][i] # Get the time and memory usage time = self.table["Simulation time"][i] memory = self.table["Memory usage"][i] # Add the data point to the data structure self.data[rank].times.append(time) self.data[rank].memory.append(memory) # Check whether (de)allocation information is present in the memory table if "Array (de)allocation" in self.table.colnames: # Initialize the data structure for plotting the memory usage of the root process and the memory # allocation curve self.allocation = Map({"times": [], "allocation": [], "cumulative": []}) # Get the mask covering entries that do not contain array (de)allocation information mask = self.table["Array (de)allocation"].mask # Check whether the first entry of the table corresponds to the root process assert self.table["Process rank"][0] == 0 # Create a variable to store the cumulative sum of allocated memory cumulative_sum = 0.0 # Loop over the different entries in the memory table for i in range(len(self.table)): # Get the process rank rank = self.table["Process rank"][i] # Only add the contributions from the root process if rank > 0: break # If the entry is masked because it does not contain memory allocation information, skip it if mask[i]: continue # Get the time and the amount of (de)allocated memory time = self.table["Simulation time"][i] allocation = self.table["Array (de)allocation"][i] # Add the allocated memory to the sum cumulative_sum += allocation # Add the data point to the data structure self.allocation.times.append(time) self.allocation.allocation.append(allocation) self.allocation.cumulative.append(cumulative_sum)
Stargrazer82301/CAAPR
[ 8, 2, 8, 1, 1453231962 ]
def plot(self): """ This function ... :return: """ # Inform the user log.info("Making the plots...") # Make a plot of the memory usage as a function of time self.plot_memory() # Make a plot of the memory (de)allocation information, if present if self.allocation is not None: self.plot_allocation()
Stargrazer82301/CAAPR
[ 8, 2, 8, 1, 1453231962 ]
def plot_memory(self): """ This function ... :return: """ # Determine the path to the plot file plot_path = fs.join(self.output_path, "memory.pdf") # Initialize figure plt.figure() plt.clf() # Loop over the different processes for rank in range(len(self.data)): # Name of the current process process = "P" + str(rank) # Plot the memory usage plt.plot(self.data[rank].times, self.data[rank].memory, label=process) # Set the axis labels plt.xlabel("Time (s)", fontsize='large') plt.ylabel("Memory usage (GB)", fontsize='large') # Set the plot title plt.title("Memory consumption") # Set the legend if len(self.data) > 16: plt.legend(loc='upper center', ncol=8, bbox_to_anchor=(0.5, -0.1), prop={'size': 8}) else: plt.legend(loc='lower right', ncol=4, prop={'size': 8}) # Save the figure plt.savefig(plot_path, bbox_inches='tight', pad_inches=0.25) plt.close()
Stargrazer82301/CAAPR
[ 8, 2, 8, 1, 1453231962 ]
def plot_allocation(self): """ This function ... :return: """ # Determine the path to the plot file plot_path = fs.join(self.output_path, "allocation.pdf") # Initialize figure plt.figure() plt.clf() # Plot the memory usage of the root process plt.plot(self.data[0].times, self.data[0].memory, label="total memory usage") # Plot the memory allocation of the root process plt.step(self.allocation.times, self.allocation.cumulative, where="post", linestyle="--", label="allocated array memory") # Set the axis labels plt.xlabel("Time (s)", fontsize='large') plt.ylabel("Memory usage (GB)", fontsize='large') # Set the plot title plt.title("Memory (de)allocation") # Set the legend plt.legend(loc='lower right', prop={'size': 8}) # Save the figure plt.savefig(plot_path, bbox_inches='tight', pad_inches=0.25) plt.close()
Stargrazer82301/CAAPR
[ 8, 2, 8, 1, 1453231962 ]
def build_get_request( location: str, publisher_name: str, offer: str, skus: str, version: str, subscription_id: str, **kwargs: Any
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def build_list_request( location: str, publisher_name: str, offer: str, skus: str, subscription_id: str, *, expand: Optional[str] = None, top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def build_list_offers_request( location: str, publisher_name: str, subscription_id: str, **kwargs: Any
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def build_list_publishers_request( location: str, subscription_id: str, **kwargs: Any
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def build_list_skus_request( location: str, publisher_name: str, offer: str, subscription_id: str, **kwargs: Any
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def __init__(self, client, config, serializer, deserializer): self._client = client self._serialize = serializer self._deserialize = deserializer self._config = config
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def get( self, location: str, publisher_name: str, offer: str, skus: str, version: str, **kwargs: Any
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def list( self, location: str, publisher_name: str, offer: str, skus: str, expand: Optional[str] = None, top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def list_offers( self, location: str, publisher_name: str, **kwargs: Any
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def list_publishers( self, location: str, **kwargs: Any
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def list_skus( self, location: str, publisher_name: str, offer: str, **kwargs: Any
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def __init__( self, plotly_name="color", parent_name="histogram2dcontour.textfont", **kwargs
plotly/plotly.py
[ 13052, 2308, 13052, 1319, 1385013188 ]
def __init__( self, *, container_host_resource_id: Optional[str] = None, **kwargs
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def __init__( self, **kwargs
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def __init__( self, *, tags: Optional[Dict[str, str]] = None, location: Optional[str] = None, **kwargs
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def __init__( self, *, sku: "Sku", target_container_host_resource_id: str, target_container_host_credentials_base64: str, tags: Optional[Dict[str, str]] = None, location: Optional[str] = None, **kwargs
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def __init__( self, *, orchestrator_specific_connection_details: Optional["OrchestratorSpecificConnectionDetails"] = None, **kwargs
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def __init__( self, *, connection_details_list: Optional[List["ControllerConnectionDetails"]] = None, **kwargs
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def __init__( self, *, value: Optional[List["Controller"]] = None, **kwargs
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def __init__( self, *, tags: Optional[Dict[str, str]] = None, target_container_host_credentials_base64: Optional[str] = None, **kwargs
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def __init__( self, *, error: Optional["ErrorDetails"] = None, **kwargs
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def __init__( self, **kwargs
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def __init__( self, **kwargs
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def __init__( self, *, kube_config: Optional[str] = None, **kwargs
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def __init__( self, *, target_container_host_resource_id: str, **kwargs
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def __init__( self, *, name: Optional[str] = None, display: Optional["ResourceProviderOperationDisplay"] = None, **kwargs
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def __init__( self, *, provider: Optional[str] = None, resource: Optional[str] = None, operation: Optional[str] = None, description: Optional[str] = None, **kwargs
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def __init__( self, *, value: Optional[List["ResourceProviderOperationDefinition"]] = None, **kwargs
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def __init__( self, *, name: Union[str, "SkuName"], tier: Optional[Union[str, "SkuTier"]] = None, **kwargs
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def __init__( self, plotly_name="nticks", parent_name="layout.ternary.baxis", **kwargs
plotly/plotly.py
[ 13052, 2308, 13052, 1319, 1385013188 ]
def setUp(self): self.user = User.objects.create(username='test', email='test@localhost', password='test') self.user2 = User.objects.create(username='test2', email='test2@localhost', password='test') self.user3 = User.objects.create(username='test3', email='test3@localhost', password='test') self.game = Game.new_game(name='test', user=self.user, player_name='storyteller') self.current = self.game.current_round self.player2 = self.game.add_player(self.user2, 'player2') self.player3 = self.game.add_player(self.user3, 'player3')
jminuscula/dixit-online
[ 70, 19, 70, 23, 1465385513 ]
def test_storyteller_can_provide_card(self): story_play = Play(game_round=self.current, player=self.game.storyteller) story_play.provide_card(self.game.storyteller._pick_card(), 'story') self.assertEqual(self.current.plays.count(), 1)
jminuscula/dixit-online
[ 70, 19, 70, 23, 1465385513 ]
def test_players_can_provide_card_after_storyteller(self): Play.play_for_round(self.current, self.game.storyteller, self.game.storyteller._pick_card(), 'story') Play.play_for_round(self.current, self.player2, self.player2._pick_card()) self.assertEqual(self.current.plays.count(), 2)
jminuscula/dixit-online
[ 70, 19, 70, 23, 1465385513 ]
def test_players_can_choose_played_card(self): story_card = self.game.storyteller._pick_card() story_play = Play.play_for_round(self.current, self.game.storyteller, story_card, 'story') play2 = Play.play_for_round(self.current, self.player2, self.player2._pick_card()) play3 = Play.play_for_round(self.current, self.player3, self.player3._pick_card()) self.assertEqual(self.current.status, RoundStatus.VOTING) play2.vote_card(story_card)
jminuscula/dixit-online
[ 70, 19, 70, 23, 1465385513 ]
def test_players_can_not_choose_own_card(self): story_card = self.game.storyteller._pick_card() story_play = Play.play_for_round(self.current, self.game.storyteller, story_card, 'story') card2 = self.player2._pick_card() play2 = Play.play_for_round(self.current, self.player2, card2) with self.assertRaises(GameInvalidPlay): play2.vote_card(card2)
jminuscula/dixit-online
[ 70, 19, 70, 23, 1465385513 ]
def setUp(self): self.user = User.objects.create(username='test', email='test@localhost', password='test') self.user2 = User.objects.create(username='test2', email='test2@localhost', password='test') self.user3 = User.objects.create(username='test3', email='test3@localhost', password='test') self.user4 = User.objects.create(username='test4', email='test4@localhost', password='test') self.game = Game.new_game(name='test', user=self.user, player_name='storyteller') self.current = self.game.current_round self.player2 = self.game.add_player(self.user2, 'player2') self.player3 = self.game.add_player(self.user3, 'player3')
jminuscula/dixit-online
[ 70, 19, 70, 23, 1465385513 ]
def test_round_is_new_when_only_storyteller_has_played(self): story_card = self.game.storyteller._pick_card() Play.play_for_round(self.current, self.game.storyteller, story_card, 'story') self.assertEqual(self.current.status, RoundStatus.NEW)
jminuscula/dixit-online
[ 70, 19, 70, 23, 1465385513 ]
def test_round_is_voting_when_all_players_have_provided_a_card(self): Play.play_for_round(self.current, self.game.storyteller, self.game.storyteller._pick_card(), 'story') players = self.game.players.all().exclude(id=self.game.storyteller.id) for player in players: Play.play_for_round(self.current, player, player._pick_card()) self.assertEqual(self.current.status, RoundStatus.VOTING)
jminuscula/dixit-online
[ 70, 19, 70, 23, 1465385513 ]
def test_round_is_complete_when_all_players_have_voted(self): story_card = self.current.turn._pick_card() Play.play_for_round(self.current, self.game.storyteller, story_card, 'story') players = self.game.players.all().exclude(id=self.game.storyteller.id) for player in players: Play.play_for_round(self.current, player, player._pick_card()) plays = self.current.plays.all().exclude(player=self.game.storyteller) for play in plays: play.vote_card(story_card) self.assertEqual(self.current.status, RoundStatus.COMPLETE)
jminuscula/dixit-online
[ 70, 19, 70, 23, 1465385513 ]