function
stringlengths
11
56k
repo_name
stringlengths
5
60
features
list
def test_region(self): regions = Region.objects.all()[:2] params = {'region_id': [regions[0].pk, regions[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'region': [regions[0].slug, regions[1].slug]} self.assertEqual(self.filterset(params, s...
digitalocean/netbox
[ 12158, 2099, 12158, 303, 1456755346 ]
def test_power_panel_id(self): power_panels = PowerPanel.objects.all()[:2] params = {'power_panel_id': [power_panels[0].pk, power_panels[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
digitalocean/netbox
[ 12158, 2099, 12158, 303, 1456755346 ]
def test_cabled(self): params = {'cabled': 'true'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'cabled': 'false'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1)
digitalocean/netbox
[ 12158, 2099, 12158, 303, 1456755346 ]
def parse_requirements(self, network_configuration=None): # type: (Optional[NetworkConfiguration]) -> Iterable[ParsedRequirement] parsed_requirements = [] # type: List[ParsedRequirement] if self.requirements: parsed_requirements.extend(parse_requirement_strings(self.requirements)) ...
pantsbuild/pex
[ 2269, 235, 2269, 149, 1405962372 ]
def _one_hot(index): onehot = np.zeros([go.N * go.N + 1], dtype=np.float32) onehot[index] = 1 return onehot
mlperf/training_results_v0.7
[ 11, 25, 11, 1, 1606268455 ]
def write_tf_examples(filename, tf_examples, serialize=True): """ Args: filename: Where to write tf.records tf_examples: An iterable of tf.Example serialize: whether to serialize the examples. """ with tf.python_io.TFRecordWriter( filename, options=TF_RECORD_CONFIG) as writer: ...
mlperf/training_results_v0.7
[ 11, 25, 11, 1, 1606268455 ]
def read_tf_records(batch_size, tf_records, num_repeats=1, shuffle_records=True, shuffle_examples=True, shuffle_buffer_size=None, interleave=True, filter_amount=1.0): """ Args: batch_size: batch size to return tf_records: a list of tf_rec...
mlperf/training_results_v0.7
[ 11, 25, 11, 1, 1606268455 ]
def get_input_tensors(batch_size, feature_layout, tf_records, num_repeats=1, shuffle_records=True, shuffle_examples=True, shuffle_buffer_size=None, filter_amount=0.05...
mlperf/training_results_v0.7
[ 11, 25, 11, 1, 1606268455 ]
def get_tpu_bt_input_tensors(games, games_nr, batch_size, feature_layout, num_repeats=1, number_of_games=500e3, fresh_fraction=0.05, ...
mlperf/training_results_v0.7
[ 11, 25, 11, 1, 1606268455 ]
def make_dataset_from_sgf(sgf_filename, tf_record): pwcs = sgf_wrapper.replay_sgf_file(sgf_filename) tf_examples = map(_make_tf_example_from_pwc, pwcs) write_tf_examples(tf_record, tf_examples)
mlperf/training_results_v0.7
[ 11, 25, 11, 1, 1606268455 ]
def __init__(self): # get the model, will download if it's not available locally self.__model_filename = get_corpus_path(_MODEL_NAME) loader = torch.load(self.__model_filename, map_location=device) INPUT_DIM, E_EMB_DIM, E_HID_DIM, E_DROPOUT = loader["encoder_params"] OUTPUT_DIM...
PyThaiNLP/pythainlp
[ 786, 237, 786, 35, 1466693846 ]
def g2p(self, text: str) -> str: """ :param str text: Thai text to be romanized :return: English (more or less) text that spells out how the Thai text should be pronounced. """ input_tensor = self._prepare_sequence_in(text).view(1, -1) input_length = [len...
PyThaiNLP/pythainlp
[ 786, 237, 786, 35, 1466693846 ]
def __init__( self, vocabulary_size, embedding_size, hidden_size, dropout=0.5
PyThaiNLP/pythainlp
[ 786, 237, 786, 35, 1466693846 ]
def forward(self, sequences, sequences_lengths): # sequences: (batch_size, sequence_length=MAX_LENGTH) # sequences_lengths: (batch_size) batch_size = sequences.size(0) self.hidden = self.init_hidden(batch_size) sequences_lengths = np.sort(sequences_lengths)[::-1] index...
PyThaiNLP/pythainlp
[ 786, 237, 786, 35, 1466693846 ]
def __init__(self, method, hidden_size): super(Attn, self).__init__() self.method = method self.hidden_size = hidden_size if self.method == "general": self.attn = nn.Linear(self.hidden_size, hidden_size) elif self.method == "concat": self.attn = nn.Line...
PyThaiNLP/pythainlp
[ 786, 237, 786, 35, 1466693846 ]
def __init__( self, vocabulary_size, embedding_size, hidden_size, dropout=0.5
PyThaiNLP/pythainlp
[ 786, 237, 786, 35, 1466693846 ]
def forward(self, input_character, last_hidden, encoder_outputs, mask): """"Defines the forward computation of the decoder""" # input_character: (batch_size, 1) # last_hidden: (batch_size, hidden_dim) # encoder_outputs: (batch_size, sequence_len, hidden_dim) # mask: (batch_size,...
PyThaiNLP/pythainlp
[ 786, 237, 786, 35, 1466693846 ]
def __init__( self, encoder, decoder, target_start_token, target_end_token, max_length,
PyThaiNLP/pythainlp
[ 786, 237, 786, 35, 1466693846 ]
def create_mask(self, source_seq): mask = source_seq != self.pad_idx return mask
PyThaiNLP/pythainlp
[ 786, 237, 786, 35, 1466693846 ]
def mock_device(device_id, name, is_online=True, device_type_name=None): """Mock Canary Device class.""" device = MagicMock() type(device).device_id = PropertyMock(return_value=device_id) type(device).name = PropertyMock(return_value=name) type(device).is_online = PropertyMock(return_value=is_online...
tchellomello/home-assistant
[ 7, 1, 7, 6, 1467778429 ]
def mock_mode(mode_id, name): """Mock Canary Mode class.""" mode = MagicMock() type(mode).mode_id = PropertyMock(return_value=mode_id) type(mode).name = PropertyMock(return_value=name) type(mode).resource_url = PropertyMock(return_value=f"/v1/modes/{mode_id}") return mode
tchellomello/home-assistant
[ 7, 1, 7, 6, 1467778429 ]
def ansible_ping_func(modules): if "ansible.system.ping" in modules: # we need to go by getattr() because salt's loader will try to find "system" in the dictionary and fail # The ansible hack injects, in this case, "system.ping" as an attribute to the loaded module return getattr(modules.ans...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def pack(self, packer: Packer) -> None: packer.pack_int(self.value)
StellarCN/py-stellar-base
[ 328, 158, 328, 6, 1443187561 ]
def unpack(cls, unpacker: Unpacker) -> "LedgerUpgradeType": value = unpacker.unpack_int() return cls(value)
StellarCN/py-stellar-base
[ 328, 158, 328, 6, 1443187561 ]
def from_xdr_bytes(cls, xdr: bytes) -> "LedgerUpgradeType": unpacker = Unpacker(xdr) return cls.unpack(unpacker)
StellarCN/py-stellar-base
[ 328, 158, 328, 6, 1443187561 ]
def from_xdr(cls, xdr: str) -> "LedgerUpgradeType": xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes)
StellarCN/py-stellar-base
[ 328, 158, 328, 6, 1443187561 ]
def __init__(self, value): self.value = value
zahodi/ansible-mikrotik
[ 93, 34, 93, 17, 1484089137 ]
def __init__(self, api): self.api = api
zahodi/ansible-mikrotik
[ 93, 34, 93, 17, 1484089137 ]
def length_to_bytes(self, length): if length < 0x80: return self.to_bytes(length) elif length < 0x4000: length |= 0x8000 return self.to_bytes(length, 2) elif length < 0x200000: length |= 0xC00000 return self.to_bytes(length, 3) ...
zahodi/ansible-mikrotik
[ 93, 34, 93, 17, 1484089137 ]
def _unpack(self, times, i): temp1 = self.to_bytes(i) temp2 = self.api.read_bytes(times) try: temp3 = temp2.decode('utf-8') except: try: temp3 = temp2.decode('windows-1252') except Exception: print("Cannot decode respons...
zahodi/ansible-mikrotik
[ 93, 34, 93, 17, 1484089137 ]
def from_bytes(self, data): data_values = [ord(char) for char in data] value = 0 for byte_value in data_values: value <<= 8 value += byte_value return value
zahodi/ansible-mikrotik
[ 93, 34, 93, 17, 1484089137 ]
def from_bytes(self, data): return int.from_bytes(data, 'big')
zahodi/ansible-mikrotik
[ 93, 34, 93, 17, 1484089137 ]
def __init__(self, socket): self.socket = socket self.length_utils = RosApiLengthUtils(self)
zahodi/ansible-mikrotik
[ 93, 34, 93, 17, 1484089137 ]
def talk(self, words): if self.write_sentence(words) == 0: return output = [] while True: input_sentence = self.read_sentence() if not len(input_sentence): continue attrs = {} reply = input_sentence.pop(0) fo...
zahodi/ansible-mikrotik
[ 93, 34, 93, 17, 1484089137 ]
def read_sentence(self): sentence = [] while True: word = self.read_word() if not len(word): return sentence sentence.append(word)
zahodi/ansible-mikrotik
[ 93, 34, 93, 17, 1484089137 ]
def read_word(self): word = self.read_bytes(self.length_utils.read_length()) logger.debug('<<< %s' % word) return word
zahodi/ansible-mikrotik
[ 93, 34, 93, 17, 1484089137 ]
def read_bytes(self, length): received_overal = b'' while len(received_overal) < length: try: received = self.socket.recv( length - len(received_overal)) except socket.error as e: raise RosAPIConnectionError(str(e)) ...
zahodi/ansible-mikrotik
[ 93, 34, 93, 17, 1484089137 ]
def __init__(self, api, namespace): self.api = api self.namespace = namespace
zahodi/ansible-mikrotik
[ 93, 34, 93, 17, 1484089137 ]
def _prepare_arguments(is_query, **kwargs): command_arguments = [] for key, value in kwargs.items(): if key in ['id', 'proplist']: key = '.%s' % key key = key.replace('_', '-') selector_char = '?' if is_query else '=' command_arguments.appe...
zahodi/ansible-mikrotik
[ 93, 34, 93, 17, 1484089137 ]
def _remove_first_char_from_keys(dictionary): elements = [] for key, value in dictionary.items(): key = key.decode('ascii') if key in ['.id', '.proplist']: key = key[1:] elements.append((key, value)) return dict(elements)
zahodi/ansible-mikrotik
[ 93, 34, 93, 17, 1484089137 ]
def detailed_get(self, **kwargs): return self.call('print', {'detail': b''}, kwargs)
zahodi/ansible-mikrotik
[ 93, 34, 93, 17, 1484089137 ]
def add(self, **kwargs): return self.call('add', kwargs)
zahodi/ansible-mikrotik
[ 93, 34, 93, 17, 1484089137 ]
def detailed_get(self, **kwargs): return self.call('print', {'detail': ''}, kwargs)
zahodi/ansible-mikrotik
[ 93, 34, 93, 17, 1484089137 ]
def _encode_kwargs(self, kwargs): return dict((k, v.encode('ascii')) for k, v in kwargs.items())
zahodi/ansible-mikrotik
[ 93, 34, 93, 17, 1484089137 ]
def __init__(self, host, username='api', password='', port=8728, ssl=False): self.host = host self.username = username self.password = password self.socket = None self.port = port self.ssl = ssl self.reconnect()
zahodi/ansible-mikrotik
[ 93, 34, 93, 17, 1484089137 ]
def __exit__(self, _, __, ___): self.close_connection()
zahodi/ansible-mikrotik
[ 93, 34, 93, 17, 1484089137 ]
def connect(self): sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.settimeout(15.0) sock.connect((self.host, self.port)) set_keepalive(sock, after_idle_sec=10) if self.ssl: try: self.socket = ssl.wrap_socket(sock) except ssl.S...
zahodi/ansible-mikrotik
[ 93, 34, 93, 17, 1484089137 ]
def get_resource(self, namespace): return RouterboardResource(self, namespace)
zahodi/ansible-mikrotik
[ 93, 34, 93, 17, 1484089137 ]
def close_connection(self): self.socket.close()
zahodi/ansible-mikrotik
[ 93, 34, 93, 17, 1484089137 ]
def __init__(self, hostname, username, password): self.hostname = hostname self.username = username self.password = password
zahodi/ansible-mikrotik
[ 93, 34, 93, 17, 1484089137 ]
def talk(self, talk_command): r = self.login() response = r.talk(talk_command) return(response)
zahodi/ansible-mikrotik
[ 93, 34, 93, 17, 1484089137 ]
def api_add(self, base_path, params): command = [base_path + '/add'] for key, value in params.iteritems(): item = b'=' + key + '=' + str(value) command.append(item) return self.talk(command)
zahodi/ansible-mikrotik
[ 93, 34, 93, 17, 1484089137 ]
def api_remove(self, base_path, remove_id): command = [ base_path + '/remove', b'=.id=' + remove_id ] return self.talk(command)
zahodi/ansible-mikrotik
[ 93, 34, 93, 17, 1484089137 ]
def __init__(self, env, scope=None, mpi_context=None, **kwargs): self.scope = scope self.env = env self.mpi_context = mpi_context self._n_experiences = 0 self.step = 0 self._saver = None
e2crawfo/dps
[ 1, 2, 1, 3, 1491848389 ]
def n_experiences(self): return self._n_experiences
e2crawfo/dps
[ 1, 2, 1, 3, 1491848389 ]
def _build_graph(self): raise Exception("NotImplemented")
e2crawfo/dps
[ 1, 2, 1, 3, 1491848389 ]
def _update(self, batch_size): raise Exception("NotImplemented")
e2crawfo/dps
[ 1, 2, 1, 3, 1491848389 ]
def _evaluate(self, batch_size, mode): raise Exception("NotImplemented")
e2crawfo/dps
[ 1, 2, 1, 3, 1491848389 ]
def save(self, filename): path = self.saver.save(tf.get_default_session(), filename) return path
e2crawfo/dps
[ 1, 2, 1, 3, 1491848389 ]
def trainable_variables(self, for_opt): return []
e2crawfo/dps
[ 1, 2, 1, 3, 1491848389 ]
def _update(self, batch_size): return dict()
e2crawfo/dps
[ 1, 2, 1, 3, 1491848389 ]
def save(self, session, filename): return ''
e2crawfo/dps
[ 1, 2, 1, 3, 1491848389 ]
def __init__(self, env, f, **kwargs): assert hasattr(env, 'build'), ( "Environments used with DifferentiableUpdater must possess " "a method called `build` which builds returns a dictionary of scalar tensors." ) self.f = f super(DifferentiableUpdater, self).__ini...
e2crawfo/dps
[ 1, 2, 1, 3, 1491848389 ]
def _build_graph(self): self.recorded_tensors = self.env.build(self.f) self.loss = self.recorded_tensors['loss'] tvars = self.trainable_variables(for_opt=True) if self.l2_weight is not None: self.loss += self.l2_weight * sum(tf.nn.l2_loss(v) for v in tvars if 'weights' in v....
e2crawfo/dps
[ 1, 2, 1, 3, 1491848389 ]
def _evaluate(self, batch_size, mode): if mode == "val": feed_dict = self.env.data_manager.do_val() elif mode == "test": feed_dict = self.env.data_manager.do_test() else: raise Exception("Unknown evaluation mode: {}".format(mode)) sess = tf.get_defaul...
e2crawfo/dps
[ 1, 2, 1, 3, 1491848389 ]
def __init__(self, env, scope=None, **kwargs): self.obs_shape = env.obs_shape *other, self.image_height, self.image_width, self.image_depth = self.obs_shape self.n_frames = other[0] if other else 0 self.network = cfg.build_network(env, self, scope="network") super(VideoUpdater, ...
e2crawfo/dps
[ 1, 2, 1, 3, 1491848389 ]
def _update(self, batch_size): if cfg.get('no_gradient', False): return dict() feed_dict = self.data_manager.do_train() sess = tf.get_default_session() _, record, train_record = sess.run( [self.train_op, self.recorded_tensors, self.train_records], feed_dict=feed...
e2crawfo/dps
[ 1, 2, 1, 3, 1491848389 ]
def _build_graph(self): self.data_manager = DataManager(datasets=self.env.datasets) self.data_manager.build_graph() data = self.data_manager.iterator.get_next() self.inp = data["image"] network_outputs = self.network(data, self.data_manager.is_training) network_tensors ...
e2crawfo/dps
[ 1, 2, 1, 3, 1491848389 ]
def record_tensors(self, **kwargs): for k, v in kwargs.items(): self.recorded_tensors[k] = tf.reduce_mean(tf.to_float(v))
e2crawfo/dps
[ 1, 2, 1, 3, 1491848389 ]
def recorded_tensors(self): if self._recorded_tensors is None: self._recorded_tensors = {} return self._recorded_tensors
e2crawfo/dps
[ 1, 2, 1, 3, 1491848389 ]
def __init__(self, train=None, val=None, test=None, datasets=None, **kwargs): self.datasets = {} self.datasets.update(train=train, val=val, test=test) self.datasets.update(datasets) assert ( self.datasets['train'] is not None or self.datasets['val'] is not None ...
e2crawfo/dps
[ 1, 2, 1, 3, 1491848389 ]
def build_iterator(self, name, base_dataset_name, batch_size, repeat, shuffle_buffer_size): base_dataset = self.datasets[base_dataset_name] if batch_size is None: batch_size = self.batch_size if isinstance(base_dataset, tf.data.Dataset): dset = base_dataset elif...
e2crawfo/dps
[ 1, 2, 1, 3, 1491848389 ]
def do_val(self, is_training=False): return self.do('val', is_training)
e2crawfo/dps
[ 1, 2, 1, 3, 1491848389 ]
def do(self, name, is_training=False): """ Initialize iterator (unless it's the `train` iterator, which is handled slightly differently) and return a feed_dict populated with the appropriate handle for the requested iterator. """ iterator, handle = self.iterators_and_handles[name] s...
e2crawfo/dps
[ 1, 2, 1, 3, 1491848389 ]
def __call__(self, fetched, updater): return {}
e2crawfo/dps
[ 1, 2, 1, 3, 1491848389 ]
def __init__(self, functions, tensors, updater): self._functions = functions self._tensors = tensors # Force evaluation to happen at with the default feed_dict functions["dummy"] = DummyFunc() self.updater = updater self.functions = defaultdict(list) self.feed_...
e2crawfo/dps
[ 1, 2, 1, 3, 1491848389 ]
def main(_): print(_CONFIG.value)
google/ml_collections
[ 676, 26, 676, 14, 1597899148 ]
def __init__(self, account, requests_options=()): super(Export, self).__init__(account=account, requests_options=requests_options)
icoxfog417/pykintone
[ 21, 11, 21, 8, 1435900514 ]
def get_user_organization_titles(self, code): url = "https://{0}.cybozu.com/v1/user/organizations.json".format(self.account.domain) params = { "code": code } resp = self._request("GET", url, params_or_data=params) r = ur.UserOrganizationTitlesResult(resp) re...
icoxfog417/pykintone
[ 21, 11, 21, 8, 1435900514 ]
def setUp(self): super().setUp() self._test_dir = os.path.join( os.environ.get('TEST_UNDECLARED_OUTPUTS_DIR', self.get_temp_dir()), self._testMethodName)
tensorflow/tfx
[ 1905, 649, 1905, 157, 1549300476 ]
def test_anonymous_watch_with_email(self): form = WatchQuestionForm( AnonymousUser(), data={"email": "wo@ot.com", "event_type": "reply"} ) assert form.is_valid() eq_("wo@ot.com", form.cleaned_data["email"])
mozilla/kitsune
[ 1110, 779, 1110, 26, 1264532037 ]
def test_registered_watch_with_email(self): form = WatchQuestionForm(UserFactory(), data={"email": "wo@ot.com", "event_type": "reply"}) assert form.is_valid() assert not form.cleaned_data["email"]
mozilla/kitsune
[ 1110, 779, 1110, 26, 1264532037 ]
def setUp(self): super(TestNewQuestionForm, self).setUp()
mozilla/kitsune
[ 1110, 779, 1110, 26, 1264532037 ]
def create(kernel): result = Tangible() result.template = "object/tangible/loot/loot_schematic/shared_spear_rack_schematic.iff" result.attribute_template_id = -1 result.stfName("craft_item_ingredients_n","spear_rack")
anhstudios/swganh
[ 62, 37, 62, 37, 1297996365 ]
def create(kernel): result = Creature() result.template = "object/mobile/shared_dressed_corellia_cec_officer.iff" result.attribute_template_id = 9 result.stfName("npc_name","human_base_male")
anhstudios/swganh
[ 62, 37, 62, 37, 1297996365 ]
def ParseJSONFile(filename): with open(filename) as json_file: try: return json.load(json_file) except ValueError: print "%s is not a valid JSON document" % filename return None
junhuac/MQUIC
[ 2, 1, 2, 1, 1459966120 ]
def filter_queryset(self, request, queryset, view): if request.user.is_staff or request.user.is_support: return queryset return queryset.filter(is_active=True)
opennode/nodeconductor-assembly-waldur
[ 39, 35, 39, 3, 1484854426 ]
def _AccessIdException(command_name, subcommand, synopsis): return CommandException( '%s %s requires an Access ID to be specified as the last argument.\n%s' % (command_name, subcommand, synopsis))
catapult-project/catapult
[ 1835, 570, 1835, 1039, 1429033745 ]
def FormatInfo(name, value, new_line=True): """Format the metadata name-value pair into two aligned columns.""" width = 22 info_str = '\t%-*s %s' % (width, name + ':', value) if new_line: info_str += '\n' return info_str
catapult-project/catapult
[ 1835, 570, 1835, 1039, 1429033745 ]
def _CreateHmacKey(self, thread_state=None): """Creates HMAC key for a service account.""" if self.args: self.service_account_email = self.args[0] else: err_msg = ('%s %s requires a service account to be specified as the ' 'last argument.\n%s') raise CommandException( ...
catapult-project/catapult
[ 1835, 570, 1835, 1039, 1429033745 ]
def _GetHmacKey(self, thread_state=None): """Gets HMAC key from its Access Id.""" if self.args: access_id = self.args[0] else: raise _AccessIdException(self.command_name, self.action_subcommand, _GET_SYNOPSIS) gsutil_api = GetCloudApiInstance(self, thread_stat...
catapult-project/catapult
[ 1835, 570, 1835, 1039, 1429033745 ]
def _UpdateHmacKey(self, thread_state=None): """Update an HMAC key's state.""" if not self.state: raise CommandException( 'A state flag must be supplied for %s %s\n%s' % (self.command_name, self.action_subcommand, _UPDATE_SYNOPSIS)) elif self.state not in _VALID_UPDATE_STATES: ...
catapult-project/catapult
[ 1835, 570, 1835, 1039, 1429033745 ]
def __init__(self, app): """Creates a new script for Java applications. Arguments: - app: the application to create a script for. """ default.Script.__init__(self, app) # Some objects which issue descendant changed events lack # STATE_MANAGES_DESCENDANTS. As a r...
ruibarreira/linuxtrail
[ 2, 2, 2, 1, 1434186057 ]
def getFormatting(self): """Returns the formatting strings for this script.""" return Formatting(self)
ruibarreira/linuxtrail
[ 2, 2, 2, 1, 1434186057 ]
def checkKeyboardEventData(self, keyboardEvent): """Checks the data on the keyboard event. Some toolkits don't fill all the key event fields, and/or fills them out with unexpected data. This method tries to fill in the missing fields and validate/standardize the data we've been given. ...
ruibarreira/linuxtrail
[ 2, 2, 2, 1, 1434186057 ]
def onSelectionChanged(self, event): """Called when an object's selection changes. Arguments: - event: the Event """ # Avoid doing this with objects that manage their descendants # because they'll issue a descendant changed event. (Note: This # equality check is...
ruibarreira/linuxtrail
[ 2, 2, 2, 1, 1434186057 ]
def onValueChanged(self, event): """Called whenever an object's value changes. Arguments: - event: the Event """ # We'll ignore value changed events for Java's toggle buttons since # they also send a redundant object:state-changed:checked event. # ignore...
ruibarreira/linuxtrail
[ 2, 2, 2, 1, 1434186057 ]
def setUp(self): super(ThirdPartyOAuthTestMixin, self).setUp() if self.CREATE_USER: self.user = UserFactory() UserSocialAuth.objects.create(user=self.user, provider=self.BACKEND, uid=self.social_uid) self.oauth_client = self._create_client() if self.BACKEND == 'go...
edx-solutions/edx-platform
[ 12, 19, 12, 9, 1391522577 ]
def _create_client(self): """ Create an OAuth2 client application """ return Application.objects.create( client_id=self.client_id, client_type=Application.CLIENT_PUBLIC, )
edx-solutions/edx-platform
[ 12, 19, 12, 9, 1391522577 ]
def _setup_provider_response_with_body(self, status, body): """ Register a mock response for the third party user information endpoint with given status and body. """ httpretty.register_uri( httpretty.GET, self.USER_URL, body=body, status=s...
edx-solutions/edx-platform
[ 12, 19, 12, 9, 1391522577 ]