function stringlengths 11 56k | repo_name stringlengths 5 60 | features list |
|---|---|---|
def setUp(self):
super().setUp()
self.url = reverse("accounts_api", kwargs={'username': self.user.username})
self.search_api_url = reverse("accounts_search_emails_api") | edx/edx-platform | [
6290,
3437,
6290,
280,
1369945238
] |
def _verify_full_shareable_account_response(self, response, account_privacy=None, badges_enabled=False):
"""
Verify that the shareable fields from the account are returned
"""
data = response.data
assert 12 == len(data)
# public fields (3)
assert account_privacy ... | edx/edx-platform | [
6290,
3437,
6290,
280,
1369945238
] |
def _verify_full_account_response(self, response, requires_parental_consent=False, year_of_birth=2000):
"""
Verify that all account fields are returned (even those that are not shareable).
"""
data = response.data
assert self.FULL_RESPONSE_FIELD_COUNT == len(data)
# publ... | edx/edx-platform | [
6290,
3437,
6290,
280,
1369945238
] |
def test_unsupported_methods(self):
"""
Test that DELETE, POST, and PUT are not supported.
"""
self.client.login(username=self.user.username, password=TEST_PASSWORD)
assert 405 == self.client.put(self.url).status_code
assert 405 == self.client.post(self.url).status_code
... | edx/edx-platform | [
6290,
3437,
6290,
280,
1369945238
] |
def test_get_account_unknown_user(self, api_client, user):
"""
Test that requesting a user who does not exist returns a 404.
"""
client = self.login_client(api_client, user)
response = client.get(reverse("accounts_api", kwargs={'username': "does_not_exist"}))
assert 404 =... | edx/edx-platform | [
6290,
3437,
6290,
280,
1369945238
] |
def test_regsitration_activation_key(self, api_client, user):
"""
Test that registration activation key has a value.
UserFactory does not auto-generate registration object for the test users.
It is created only for users that signup via email/API. Therefore, activation key has to be te... | edx/edx-platform | [
6290,
3437,
6290,
280,
1369945238
] |
def test_unsuccessful_get_account_by_email(self):
"""
Test that request using email by a normal user fails to retrieve Account Info.
"""
api_client = "client"
user = "user"
client = self.login_client(api_client, user)
self.create_mock_profile(self.user)
se... | edx/edx-platform | [
6290,
3437,
6290,
280,
1369945238
] |
def test_unsuccessful_get_account_by_user_id(self):
"""
Test that requesting using lms user id by a normal user fails to retrieve Account Info.
"""
api_client = "client"
user = "user"
url = reverse("accounts_detail_api")
client = self.login_client(api_client, user... | edx/edx-platform | [
6290,
3437,
6290,
280,
1369945238
] |
def test_get_account_by_user_id_non_integer(self, non_integer_id):
"""
Test that request using a non-integer lms user id by a staff user fails to retrieve Account Info.
"""
api_client = "staff_client"
user = "staff_user"
url = reverse("accounts_detail_api")
client... | edx/edx-platform | [
6290,
3437,
6290,
280,
1369945238
] |
def test_search_emails_with_non_staff_user(self):
client = self.login_client('client', 'user')
json_data = {'emails': [self.user.email]}
response = self.post_search_api(client, json_data=json_data, expected_status=404)
assert response.data == {
'developer_message': "not_found... | edx/edx-platform | [
6290,
3437,
6290,
280,
1369945238
] |
def test_search_emails_with_invalid_param(self):
client = self.login_client('staff_client', 'staff_user')
json_data = {'invalid_key': [self.user.email]}
response = self.post_search_api(client, json_data=json_data, expected_status=400)
assert response.data == {
'developer_mess... | edx/edx-platform | [
6290,
3437,
6290,
280,
1369945238
] |
def test_get_account_different_user_visible(self):
"""
Test that a client (logged in) can only get the shareable fields for a different user.
This is the case when default_visibility is set to "all_users".
"""
self.different_client.login(username=self.different_user.username, pas... | edx/edx-platform | [
6290,
3437,
6290,
280,
1369945238
] |
def test_get_account_different_user_private(self):
"""
Test that a client (logged in) can only get the shareable fields for a different user.
This is the case when default_visibility is set to "private".
"""
self.different_client.login(username=self.different_user.username, passw... | edx/edx-platform | [
6290,
3437,
6290,
280,
1369945238
] |
def test_get_account_private_visibility(self, api_client, requesting_username, preference_visibility):
"""
Test the return from GET based on user visibility setting.
"""
def verify_fields_visible_to_all_users(response):
"""
Confirms that private fields are privat... | edx/edx-platform | [
6290,
3437,
6290,
280,
1369945238
] |
def test_custom_visibility_over_age(self, api_client, requesting_username):
self.create_mock_profile(self.user)
self.create_mock_verified_name(self.user)
# set user's custom visibility preferences
set_user_preference(self.user, ACCOUNT_VISIBILITY_PREF_KEY, CUSTOM_VISIBILITY)
shar... | edx/edx-platform | [
6290,
3437,
6290,
280,
1369945238
] |
def test_custom_visibility_under_age(self, api_client, requesting_username):
self.create_mock_profile(self.user)
self.create_mock_verified_name(self.user)
year_of_birth = self._set_user_age_to_10_years(self.user)
# set user's custom visibility preferences
set_user_preference(sel... | edx/edx-platform | [
6290,
3437,
6290,
280,
1369945238
] |
def verify_get_own_information(queries):
"""
Internal helper to perform the actual assertions
"""
with self.assertNumQueries(queries):
response = self.send_get(self.client)
data = response.data
assert self.FULL_RESPONSE_FIELD_COUNT ... | edx/edx-platform | [
6290,
3437,
6290,
280,
1369945238
] |
def test_get_account_empty_string(self):
"""
Test the conversion of empty strings to None for certain fields.
"""
legacy_profile = UserProfile.objects.get(id=self.user.id)
legacy_profile.country = ""
legacy_profile.state = ""
legacy_profile.level_of_education = ""... | edx/edx-platform | [
6290,
3437,
6290,
280,
1369945238
] |
def test_patch_account_disallowed_user(self, api_client, user):
"""
Test that a client cannot call PATCH on a different client's user account (even with
is_staff access).
"""
client = self.login_client(api_client, user)
self.send_patch(client, {}, expected_status=403) | edx/edx-platform | [
6290,
3437,
6290,
280,
1369945238
] |
def test_patch_account_unknown_user(self, api_client, user):
"""
Test that trying to update a user who does not exist returns a 403.
"""
client = self.login_client(api_client, user)
response = client.patch(
reverse("accounts_api", kwargs={'username': "does_not_exist"}... | edx/edx-platform | [
6290,
3437,
6290,
280,
1369945238
] |
def test_patch_account(self, field, value, fails_validation_value=None, developer_validation_message=None):
"""
Test the behavior of patch, when using the correct content_type.
"""
client = self.login_client("client", "user")
if field == 'account_privacy':
# Ensure t... | edx/edx-platform | [
6290,
3437,
6290,
280,
1369945238
] |
def test_patch_account_noneditable(self):
"""
Tests the behavior of patch when a read-only field is attempted to be edited.
"""
client = self.login_client("client", "user")
def verify_error_response(field_name, data):
"""
Internal helper to check the erro... | edx/edx-platform | [
6290,
3437,
6290,
280,
1369945238
] |
def test_patch_account_empty_string(self):
"""
Tests the behavior of patch when attempting to set fields with a select list of options to the empty string.
Also verifies the behaviour when setting to None.
"""
self.client.login(username=self.user.username, password=TEST_PASSWORD)... | edx/edx-platform | [
6290,
3437,
6290,
280,
1369945238
] |
def get_name_change_info(expected_entries):
"""
Internal method to encapsulate the retrieval of old names used
"""
legacy_profile = UserProfile.objects.get(id=self.user.id)
name_change_info = legacy_profile.get_meta()["old_names"]
assert expected_e... | edx/edx-platform | [
6290,
3437,
6290,
280,
1369945238
] |
def test_patch_email(self):
"""
Test that the user can request an email change through the accounts API.
Full testing of the helper method used (do_email_change_request) exists in the package with the code.
Here just do minimal smoke testing.
"""
client = self.login_clien... | edx/edx-platform | [
6290,
3437,
6290,
280,
1369945238
] |
def test_patch_invalid_email(self, bad_email):
"""
Test a few error cases for email validation (full test coverage lives with do_email_change_request).
"""
client = self.login_client("client", "user")
# Try changing to an invalid email to make sure error messages are appropriate... | edx/edx-platform | [
6290,
3437,
6290,
280,
1369945238
] |
def test_patch_duplicate_email(self, do_email_change_request):
"""
Test that same success response will be sent to user even if the given email already used.
"""
existing_email = "same@example.com"
UserFactory.create(email=existing_email)
client = self.login_client("clie... | edx/edx-platform | [
6290,
3437,
6290,
280,
1369945238
] |
def test_patch_invalid_language_proficiencies(self, patch_value, expected_error_message):
"""
Verify we handle error cases when patching the language_proficiencies
field.
"""
expected_error_message = str(expected_error_message).replace('unicode', 'str')
client = self.log... | edx/edx-platform | [
6290,
3437,
6290,
280,
1369945238
] |
def test_patch_serializer_save_fails(self, serializer_save):
"""
Test that AccountUpdateErrors are passed through to the response.
"""
serializer_save.side_effect = [Exception("bummer"), None]
self.client.login(username=self.user.username, password=TEST_PASSWORD)
error_re... | edx/edx-platform | [
6290,
3437,
6290,
280,
1369945238
] |
def test_convert_relative_profile_url(self):
"""
Test that when TEST_PROFILE_IMAGE_BACKEND['base_url'] begins
with a '/', the API generates the full URL to profile images based on
the URL of the request.
"""
self.client.login(username=self.user.username, password=TEST_PAS... | edx/edx-platform | [
6290,
3437,
6290,
280,
1369945238
] |
def test_parental_consent(self, api_client, requesting_username, has_full_access):
"""
Verifies that under thirteens never return a public profile.
"""
client = self.login_client(api_client, requesting_username)
year_of_birth = self._set_user_age_to_10_years(self.user)
s... | edx/edx-platform | [
6290,
3437,
6290,
280,
1369945238
] |
def setUp(self):
super().setUp()
self.client = APIClient()
self.user = UserFactory.create(password=TEST_PASSWORD)
self.url = reverse("accounts_api", kwargs={'username': self.user.username}) | edx/edx-platform | [
6290,
3437,
6290,
280,
1369945238
] |
def test_update_account_settings_rollback(self, mock_email_change):
"""
Verify that updating account settings is transactional when a failure happens.
"""
# Send a PATCH request with updates to both profile information and email.
# Throw an error from the method that is used to p... | edx/edx-platform | [
6290,
3437,
6290,
280,
1369945238
] |
def setUp(self):
super().setUp()
self.url = reverse('name_change') | edx/edx-platform | [
6290,
3437,
6290,
280,
1369945238
] |
def test_unauthenticated(self):
"""
Test that a name change request fails for an unauthenticated user.
"""
self.send_post(self.client, {'name': 'New Name'}, expected_status=401) | edx/edx-platform | [
6290,
3437,
6290,
280,
1369945238
] |
def test_blank_name(self):
"""
Test that a blank name string fails.
"""
self.client.login(username=self.user.username, password=TEST_PASSWORD)
self.send_post(self.client, {'name': ''}, expected_status=400) | edx/edx-platform | [
6290,
3437,
6290,
280,
1369945238
] |
def test_fails_validation(self, invalid_name):
"""
Test that an invalid name will return an error.
"""
self.client.login(username=self.user.username, password=TEST_PASSWORD)
self.send_post(
self.client,
{'name': invalid_name},
expected_status=4... | edx/edx-platform | [
6290,
3437,
6290,
280,
1369945238
] |
def setUp(self):
super().setUp()
self.service_user = UserFactory(username=self.SERVICE_USERNAME)
self.url = reverse("username_replacement") | edx/edx-platform | [
6290,
3437,
6290,
280,
1369945238
] |
def call_api(self, user, data):
""" Helper function to call API with data """
data = json.dumps(data)
headers = self.build_jwt_headers(user)
return self.client.post(self.url, data, content_type='application/json', **headers) | edx/edx-platform | [
6290,
3437,
6290,
280,
1369945238
] |
def test_bad_schema(self, mapping_data):
""" Verify the endpoint rejects bad data schema """
data = {
"username_mappings": mapping_data
}
response = self.call_api(self.service_user, data)
assert response.status_code == 400 | edx/edx-platform | [
6290,
3437,
6290,
280,
1369945238
] |
def _checkInput(index):
if index < 0:
raise ValueError("Indice negativo non supportato [{}]".format(index))
elif type(index) != int:
raise TypeError("Inserire un intero [tipo input {}]".format(type(index).__name__)) | feroda/lessons-python4beginners | [
2,
12,
2,
3,
1472811971
] |
def fib_from_list(index):
_checkInput(index)
serie = [0,1,1,2,3,5,8]
return serie[index] | feroda/lessons-python4beginners | [
2,
12,
2,
3,
1472811971
] |
def recursion(index):
if index <= 1:
return index
return recursion(index - 1) + recursion(index - 2) | feroda/lessons-python4beginners | [
2,
12,
2,
3,
1472811971
] |
def fib_from_recursion_func(index):
_checkInput(index)
return recursion(index) | feroda/lessons-python4beginners | [
2,
12,
2,
3,
1472811971
] |
def setup(self):
self.robot.light[0].units = "SCALED" | emilydolson/forestcat | [
2,
2,
2,
2,
1370887123
] |
def INIT(engine):
if engine.robot.type not in ['K-Team', 'Pyrobot']:
raise "Robot should have light sensors!"
return Vehicle('Braitenberg2a', engine) | emilydolson/forestcat | [
2,
2,
2,
2,
1370887123
] |
def emit(self, record):
pass | vert-x3/vertx-web | [
1019,
499,
1019,
184,
1415952920
] |
def enableTrace(traceable, handler = logging.StreamHandler()):
"""
turn on/off the traceability.
traceable: boolean value. if set True, traceability is enabled.
"""
global _traceEnabled
_traceEnabled = traceable
if traceable:
_logger.addHandler(handler)
_logger.setLevel(logg... | vert-x3/vertx-web | [
1019,
499,
1019,
184,
1415952920
] |
def error(msg):
_logger.error(msg) | vert-x3/vertx-web | [
1019,
499,
1019,
184,
1415952920
] |
def debug(msg):
_logger.debug(msg) | vert-x3/vertx-web | [
1019,
499,
1019,
184,
1415952920
] |
def isEnabledForError():
return _logger.isEnabledFor(logging.ERROR) | vert-x3/vertx-web | [
1019,
499,
1019,
184,
1415952920
] |
def __init__(self, backup_dir, output_file, compression='none', verbose=False, binary="tar"):
super(TarThread, self).__init__(self.__class__.__name__, compression)
self.compression_method = compression
self.backup_dir = backup_dir
self.output_file = output_file
sel... | Percona-Lab/mongodb_consistent_backup | [
274,
82,
274,
33,
1466066641
] |
def run(self):
if os.path.isdir(self.backup_dir):
if not os.path.isfile(self.output_file):
try:
backup_base_dir = os.path.dirname(self.backup_dir)
backup_base_name = os.path.basename(self.backup_dir)
log_msg = "Archiving... | Percona-Lab/mongodb_consistent_backup | [
274,
82,
274,
33,
1466066641
] |
def garch(X: Matrix,
kmax: int,
momentum: float,
start_stepsize: float,
end_stepsize: float,
start_vicinity: float,
end_vicinity: float,
sim_seed: int,
verbose: bool):
"""
:param X: The input Matrix to apply Arima on.
:param kma... | apache/incubator-systemml | [
948,
427,
948,
18,
1447142406
] |
def test_login(self, mock_login_with_token, mock_input, mock_open_url):
quilt3.login()
url = quilt3.session.get_registry_url()
mock_open_url.assert_called_with(f'{url}/login')
mock_login_with_token.assert_called_with('123456') | quiltdata/quilt-compiler | [
1223,
86,
1223,
59,
1486694763
] |
def test_login_with_token(self, mock_save_credentials, mock_save_auth):
url = quilt3.session.get_registry_url()
mock_auth = dict(
refresh_token='refresh-token',
access_token='access-token',
expires_at=123456789
)
self.requests_mock.add(
r... | quiltdata/quilt-compiler | [
1223,
86,
1223,
59,
1486694763
] |
def test_create_botocore_session(self, mock_load_credentials, mock_save_credentials):
def format_date(date):
return date.replace(tzinfo=datetime.timezone.utc, microsecond=0).isoformat()
# Test good credentials.
future_date = datetime.datetime.utcnow() + datetime.timedelta(hours=1)
... | quiltdata/quilt-compiler | [
1223,
86,
1223,
59,
1486694763
] |
def __init__(self):
"""
Constructor that will appropriately initialize a supervised learning object
@ In, None
@ Out, None
"""
super().__init__()
import sklearn
import sklearn.linear_model
self.model = sklearn.linear_model.LassoLarsIC | idaholab/raven | [
168,
104,
168,
215,
1490297367
] |
def getInputSpecification(cls):
"""
Method to get a reference to a class that specifies the input data for
class cls.
@ In, cls, the class for which we are retrieving the specification
@ Out, inputSpecification, InputData.ParameterInput, class to use for
specifying input of cls.
... | idaholab/raven | [
168,
104,
168,
215,
1490297367
] |
def get_dpo_proto(addr):
if ip_address(addr).version == 6:
return DpoProto.DPO_PROTO_IP6
else:
return DpoProto.DPO_PROTO_IP4 | FDio/vpp | [
923,
525,
923,
24,
1499444980
] |
def __init__(self, addr):
self.addr = addr
self.ip_addr = ip_address(text_type(self.addr)) | FDio/vpp | [
923,
525,
923,
24,
1499444980
] |
def version(self):
return self.ip_addr.version | FDio/vpp | [
923,
525,
923,
24,
1499444980
] |
def address(self):
return self.addr | FDio/vpp | [
923,
525,
923,
24,
1499444980
] |
def length(self):
return self.ip_addr.max_prefixlen | FDio/vpp | [
923,
525,
923,
24,
1499444980
] |
def bytes(self):
return self.ip_addr.packed | FDio/vpp | [
923,
525,
923,
24,
1499444980
] |
def __ne__(self, other):
return not (self == other) | FDio/vpp | [
923,
525,
923,
24,
1499444980
] |
def __init__(self, saddr, gaddr, glen):
self.saddr = saddr
self.gaddr = gaddr
self.glen = glen
if ip_address(self.saddr).version != \
ip_address(self.gaddr).version:
raise ValueError('Source and group addresses must be of the '
'same ad... | FDio/vpp | [
923,
525,
923,
24,
1499444980
] |
def length(self):
return self.glen | FDio/vpp | [
923,
525,
923,
24,
1499444980
] |
def version(self):
return ip_address(self.gaddr).version | FDio/vpp | [
923,
525,
923,
24,
1499444980
] |
def __eq__(self, other):
if isinstance(other, self.__class__):
return (self.glen == other.glen and
self.saddr == other.gaddr and
self.saddr == other.saddr)
elif (hasattr(other, "grp_address_length") and
hasattr(other, "grp_address") and
... | FDio/vpp | [
923,
525,
923,
24,
1499444980
] |
def __init__(self, test, policer_index, is_ip6=False):
self._test = test
self._policer_index = policer_index
self._is_ip6 = is_ip6 | FDio/vpp | [
923,
525,
923,
24,
1499444980
] |
def remove_vpp_config(self):
self._test.vapi.ip_punt_police(policer_index=self._policer_index,
is_ip6=self._is_ip6, is_add=False) | FDio/vpp | [
923,
525,
923,
24,
1499444980
] |
def __init__(self, test, rx_index, tx_index, nh_addr):
self._test = test
self._rx_index = rx_index
self._tx_index = tx_index
self._nh_addr = ip_address(nh_addr) | FDio/vpp | [
923,
525,
923,
24,
1499444980
] |
def add_vpp_config(self):
self._test.vapi.ip_punt_redirect(punt=self.encode(), is_add=True)
self._test.registry.register(self, self._test.logger) | FDio/vpp | [
923,
525,
923,
24,
1499444980
] |
def get_vpp_config(self):
is_ipv6 = True if self._nh_addr.version == 6 else False
return self._test.vapi.ip_punt_redirect_dump(
sw_if_index=self._rx_index, is_ipv6=is_ipv6) | FDio/vpp | [
923,
525,
923,
24,
1499444980
] |
def __init__(self, test, nh, pmtu, table_id=0):
self._test = test
self.nh = nh
self.pmtu = pmtu
self.table_id = table_id | FDio/vpp | [
923,
525,
923,
24,
1499444980
] |
def modify(self, pmtu):
self.pmtu = pmtu
self._test.vapi.ip_path_mtu_update(pmtu={'nh': self.nh,
'table_id': self.table_id,
'path_mtu': self.pmtu})
return self | FDio/vpp | [
923,
525,
923,
24,
1499444980
] |
def query_vpp_config(self):
ds = list(self._test.vapi.vpp.details_iter(
self._test.vapi.ip_path_mtu_get))
for d in ds:
if self.nh == str(d.pmtu.nh) \
and self.table_id == d.pmtu.table_id \
and self.pmtu == d.pmtu.path_mtu:
return Tru... | FDio/vpp | [
923,
525,
923,
24,
1499444980
] |
def looks_like_hash(sha):
return bool(HASH_REGEX.match(sha)) | pantsbuild/pex | [
2269,
235,
2269,
149,
1405962372
] |
def get_base_rev_args(rev):
return [rev] | pantsbuild/pex | [
2269,
235,
2269,
149,
1405962372
] |
def get_git_version(self):
VERSION_PFX = 'git version '
version = self.run_command(
['version'], show_stdout=False, stdout_only=True
)
if version.startswith(VERSION_PFX):
version = version[len(VERSION_PFX):].split()[0]
else:
version = ''
... | pantsbuild/pex | [
2269,
235,
2269,
149,
1405962372
] |
def get_current_branch(cls, location):
"""
Return the current branch, or None if HEAD isn't at a branch
(e.g. detached HEAD).
"""
# git-symbolic-ref exits with empty stdout if "HEAD" is a detached
# HEAD rather than a symbolic ref. In addition, the -q causes the
... | pantsbuild/pex | [
2269,
235,
2269,
149,
1405962372
] |
def get_revision_sha(cls, dest, rev):
"""
Return (sha_or_none, is_branch), where sha_or_none is a commit hash
if the revision names a remote branch or tag, otherwise None.
Args:
dest: the repository directory.
rev: the revision name.
"""
# Pass rev to... | pantsbuild/pex | [
2269,
235,
2269,
149,
1405962372
] |
def _should_fetch(cls, dest, rev):
"""
Return true if rev is a ref or is a commit that we don't have locally.
Branches and tags are not considered in this method because they are
assumed to be always available locally (which is a normal outcome of
``git clone`` and ``git fetch -... | pantsbuild/pex | [
2269,
235,
2269,
149,
1405962372
] |
def resolve_revision(cls, dest, url, rev_options):
# type: (str, HiddenText, RevOptions) -> RevOptions
"""
Resolve a revision to a new RevOptions object with the SHA1 of the
branch, tag, or ref if found.
Args:
rev_options: a RevOptions object.
"""
rev =... | pantsbuild/pex | [
2269,
235,
2269,
149,
1405962372
] |
def is_commit_id_equal(cls, dest, name):
"""
Return whether the current commit hash equals the given name.
Args:
dest: the repository directory.
name: a string name.
"""
if not name:
# Then avoid an unnecessary subprocess call.
return ... | pantsbuild/pex | [
2269,
235,
2269,
149,
1405962372
] |
def switch(self, dest, url, rev_options):
# type: (str, HiddenText, RevOptions) -> None
self.run_command(
make_command('config', 'remote.origin.url', url),
cwd=dest,
)
cmd_args = make_command('checkout', '-q', rev_options.to_args())
self.run_command(cmd_ar... | pantsbuild/pex | [
2269,
235,
2269,
149,
1405962372
] |
def get_remote_url(cls, location):
"""
Return URL of the first remote encountered.
Raises RemoteNotFoundError if the repository does not have a remote
url configured.
"""
# We need to pass 1 for extra_ok_returncodes since the command
# exits with return code 1 if... | pantsbuild/pex | [
2269,
235,
2269,
149,
1405962372
] |
def has_commit(cls, location, rev):
"""
Check if rev is a commit that is available in the local repository.
"""
try:
cls.run_command(
['rev-parse', '-q', '--verify', "sha^" + rev],
cwd=location,
log_failed_cmd=False,
... | pantsbuild/pex | [
2269,
235,
2269,
149,
1405962372
] |
def get_revision(cls, location, rev=None):
if rev is None:
rev = 'HEAD'
current_rev = cls.run_command(
['rev-parse', rev],
show_stdout=False,
stdout_only=True,
cwd=location,
)
return current_rev.strip() | pantsbuild/pex | [
2269,
235,
2269,
149,
1405962372
] |
def get_subdirectory(cls, location):
"""
Return the path to setup.py, relative to the repo root.
Return None if setup.py is in the repo root.
"""
# find the repo root
git_dir = cls.run_command(
['rev-parse', '--git-dir'],
show_stdout=False,
... | pantsbuild/pex | [
2269,
235,
2269,
149,
1405962372
] |
def get_url_rev_and_auth(cls, url):
# type: (str) -> Tuple[str, Optional[str], AuthInfo]
"""
Prefixes stub URLs like 'user@hostname:user/repo.git' with 'ssh://'.
That's required because although they use SSH they sometimes don't
work with a ssh:// scheme (e.g. GitHub). But we nee... | pantsbuild/pex | [
2269,
235,
2269,
149,
1405962372
] |
def update_submodules(cls, location):
if not os.path.exists(os.path.join(location, '.gitmodules')):
return
cls.run_command(
['submodule', 'update', '--init', '--recursive', '-q'],
cwd=location,
) | pantsbuild/pex | [
2269,
235,
2269,
149,
1405962372
] |
def get_repository_root(cls, location):
loc = super(Git, cls).get_repository_root(location)
if loc:
return loc
try:
r = cls.run_command(
['rev-parse', '--show-toplevel'],
cwd=location,
show_stdout=False,
stdo... | pantsbuild/pex | [
2269,
235,
2269,
149,
1405962372
] |
def test_convert_yaml_to_json_string_returns_valid_json_string(self):
data = textwrap.dedent("""
foo:
foo: baa
""")
self.assertEqual('{\n "foo": {\n "foo": "baa"\n }\n}', util.convert_yaml_to_json_string(data)) | marco-hoyer/cfn-sphere | [
82,
26,
82,
4,
1438784024
] |
def test_convert_json_to_yaml_string_returns_valid_yaml_string(self):
data = textwrap.dedent("""
{
"foo": {
"foo": "baa"
}
}
""")
self.assertEqual('foo:\n foo: baa\n', util.convert_json_to_yaml_string(data)) | marco-hoyer/cfn-sphere | [
82,
26,
82,
4,
1438784024
] |
def test_get_cfn_api_server_time_returns_gmt_datetime(self, urlopen_mock):
urlopen_mock.return_value.info.return_value.get.return_value = "Mon, 21 Sep 2015 17:17:26 GMT"
expected_timestamp = datetime(year=2015, month=9, day=21, hour=17, minute=17, second=26, tzinfo=tzutc())
self.assertEqual(expe... | marco-hoyer/cfn-sphere | [
82,
26,
82,
4,
1438784024
] |
def test_get_cfn_api_server_time_raises_exception_on_empty_date_header(self, urlopen_mock):
urlopen_mock.return_value.info.return_value.get.return_value = ""
with self.assertRaises(CfnSphereException):
util.get_cfn_api_server_time() | marco-hoyer/cfn-sphere | [
82,
26,
82,
4,
1438784024
] |
def my_retried_method(count_func):
count_func()
exception = CfnSphereBotoError(
ClientError(error_response={"Error": {"Code": "Throttling", "Message": "Rate exceeded"}},
operation_name="DescribeStacks"))
raise exception | marco-hoyer/cfn-sphere | [
82,
26,
82,
4,
1438784024
] |
def test_with_boto_retry_does_not_retry_for_simple_exception(self):
count_func = Mock()
@util.with_boto_retry(max_retries=1, pause_time_multiplier=1)
def my_retried_method(count_func):
count_func()
raise Exception
with self.assertRaises(Exception):
m... | marco-hoyer/cfn-sphere | [
82,
26,
82,
4,
1438784024
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.