id
int64 0
843k
| repository_name
stringlengths 7
55
| file_path
stringlengths 9
332
| class_name
stringlengths 3
290
| human_written_code
stringlengths 12
4.36M
| class_skeleton
stringlengths 19
2.2M
| total_program_units
int64 1
9.57k
| total_doc_str
int64 0
4.2k
| AvgCountLine
float64 0
7.89k
| AvgCountLineBlank
float64 0
300
| AvgCountLineCode
float64 0
7.89k
| AvgCountLineComment
float64 0
7.89k
| AvgCyclomatic
float64 0
130
| CommentToCodeRatio
float64 0
176
| CountClassBase
float64 0
48
| CountClassCoupled
float64 0
589
| CountClassCoupledModified
float64 0
581
| CountClassDerived
float64 0
5.37k
| CountDeclInstanceMethod
float64 0
4.2k
| CountDeclInstanceVariable
float64 0
299
| CountDeclMethod
float64 0
4.2k
| CountDeclMethodAll
float64 0
4.2k
| CountLine
float64 1
115k
| CountLineBlank
float64 0
9.01k
| CountLineCode
float64 0
94.4k
| CountLineCodeDecl
float64 0
46.1k
| CountLineCodeExe
float64 0
91.3k
| CountLineComment
float64 0
27k
| CountStmt
float64 1
93.2k
| CountStmtDecl
float64 0
46.1k
| CountStmtExe
float64 0
90.2k
| MaxCyclomatic
float64 0
759
| MaxInheritanceTree
float64 0
16
| MaxNesting
float64 0
34
| SumCyclomatic
float64 0
6k
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
4,600 |
Anaconda-Platform/anaconda-client
|
Anaconda-Platform_anaconda-client/tests/utils/notebook/test_downloader.py
|
tests.utils.notebook.test_downloader.DownloaderTestCase
|
class DownloaderTestCase(unittest.TestCase):
def test_ensure_location(self):
aserver_api = mock.MagicMock()
aserver_api.package = mock.MagicMock(return_value=files)
downloader = Downloader(aserver_api, 'username', 'notebook')
self.assertEqual(downloader.list_files()[0]['version'], '2')
self.assertEqual(downloader.list_files()[1]['version'], '2')
def test_can_download(self):
package_1 = {'basename': 'notebook.ipynb'}
package_2 = {'basename': 'NOEXIST'}
downloader = Downloader('binstar', 'username', 'notebook')
downloader.output = data_dir('')
self.assertTrue(not downloader.can_download(package_1))
self.assertTrue(downloader.can_download(package_1, True))
self.assertTrue(downloader.can_download(package_2))
def test_list_old_files(self):
old_files = {'files': [{
'basename': 'old-notebook',
'version': '1.0.0',
'upload_time': '2015-04-02 22:32:31.253000+00:00'
}]}
aserver_api = mock.MagicMock()
aserver_api.package = mock.MagicMock(return_value=old_files)
downloader = Downloader(aserver_api, 'username', 'notebook')
self.assertEqual(downloader.list_files()[0]['version'], '1.0.0')
|
class DownloaderTestCase(unittest.TestCase):
def test_ensure_location(self):
pass
def test_can_download(self):
pass
def test_list_old_files(self):
pass
| 4 | 0 | 9 | 1 | 8 | 0 | 1 | 0 | 1 | 2 | 1 | 0 | 3 | 0 | 3 | 75 | 29 | 4 | 25 | 12 | 21 | 0 | 21 | 12 | 17 | 1 | 2 | 0 | 3 |
4,601 |
Anaconda-Platform/anaconda-client
|
Anaconda-Platform_anaconda-client/tests/utils/notebook/test_inflectors.py
|
tests.utils.notebook.test_inflectors.InflectorsTestCase
|
class InflectorsTestCase(unittest.TestCase):
def test_one_directory(self):
self.assertEqual(inflection.parameterize('Donald E. Knuth'), 'donald-e-knuth')
|
class InflectorsTestCase(unittest.TestCase):
def test_one_directory(self):
pass
| 2 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 73 | 3 | 0 | 3 | 2 | 1 | 0 | 3 | 2 | 1 | 1 | 2 | 0 | 1 |
4,602 |
Anaconda-Platform/anaconda-client
|
Anaconda-Platform_anaconda-client/tests/utils/notebook/test_uploader.py
|
tests.utils.notebook.test_uploader.UploaderTestCase
|
class UploaderTestCase(unittest.TestCase):
def test_release(self):
aserver_api = mock.MagicMock()
aserver_api.release.return_value = 'release'
uploader = Uploader(aserver_api, 'notebook')
self.assertEqual(uploader.release, 'release')
def test_release_not_exist(self):
aserver_api = mock.MagicMock()
aserver_api.release.side_effect = errors.NotFound([])
aserver_api.add_release.return_value = 'release'
uploader = Uploader(aserver_api, 'project')
self.assertEqual(uploader.release, 'release')
def test_package(self):
aserver_api = mock.MagicMock()
aserver_api.package.side_effect = errors.NotFound([])
aserver_api.add_package.return_value = 'package'
uploader = Uploader(aserver_api, 'project')
self.assertEqual(uploader.package, 'package')
def test_version(self):
aserver_api = mock.MagicMock
uploader = Uploader(aserver_api, 'project', version='version')
self.assertEqual(uploader.version, 'version')
uploader = Uploader(aserver_api, 'project')
self.assertIsInstance(uploader.version, str)
def test_package_name(self):
aserver_api = mock.MagicMock()
uploader = Uploader(aserver_api, '~/notebooks/my notebook.ipynb')
self.assertEqual(uploader.project, 'my-notebook')
|
class UploaderTestCase(unittest.TestCase):
def test_release(self):
pass
def test_release_not_exist(self):
pass
def test_package(self):
pass
def test_version(self):
pass
def test_package_name(self):
pass
| 6 | 0 | 6 | 0 | 5 | 0 | 1 | 0 | 1 | 4 | 2 | 0 | 5 | 0 | 5 | 77 | 33 | 5 | 28 | 16 | 22 | 0 | 28 | 16 | 22 | 1 | 2 | 0 | 5 |
4,603 |
Anaconda-Platform/anaconda-client
|
Anaconda-Platform_anaconda-client/tests/utils/test_detect.py
|
tests.utils.test_detect.IsProjectTestCase
|
class IsProjectTestCase(unittest.TestCase):
def test_python_file(self):
is_project(example_path('bokeh-apps/timeout.py'))
def test_dir_project(self):
is_project(example_path('bokeh-apps/weather'))
|
class IsProjectTestCase(unittest.TestCase):
def test_python_file(self):
pass
def test_dir_project(self):
pass
| 3 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 2 | 0 | 2 | 74 | 6 | 1 | 5 | 3 | 2 | 0 | 5 | 3 | 2 | 1 | 2 | 0 | 2 |
4,604 |
Anaconda-Platform/anaconda-client
|
Anaconda-Platform_anaconda-client/tests/urlmock.py
|
tests.urlmock.Registry
|
class Registry:
def __init__(self):
self._map = []
def __enter__(self):
self.real_send = requests.Session.send # pylint: disable=attribute-defined-outside-init
requests.Session.send = self.mock_send
return self
def __exit__(self, *exec_info):
requests.Session.send = self.real_send
@staticmethod
def filter_request(rule, prepared_request):
if rule.url and rule.url != prepared_request.url:
return False
if rule.path and rule.path != prepared_request.path_url:
return False
if rule.method and rule.method != prepared_request.method:
return False
return True
def find_rule(self, prepared_request):
return next((stored_rule for stored_rule in self._map[::-1]
if self.filter_request(stored_rule, prepared_request)), None)
def mock_send(self, prepared_request, *args, **kwargs): # pylint: disable=unused-argument
rule = self.find_rule(prepared_request)
if rule is None:
raise Exception( # pylint: disable=broad-exception-raised
'No matching rule found for url [%s] %s' % (prepared_request.method, prepared_request.url),
)
if rule.expected_headers:
for header, value in rule.expected_headers.items():
if header not in prepared_request.headers:
raise Exception( # pylint: disable=broad-exception-raised
'{}: header {} expected in {}'.format(prepared_request.url, header, prepared_request.headers),
)
if prepared_request.headers[header] != value:
raise Exception( # pylint: disable=broad-exception-raised
'{}: header {} has unexpected value {} was expecting {}'.format(
prepared_request.url, header, prepared_request.headers[header], value,
),
)
content = rule.content
if isinstance(content, dict):
content = json.dumps(content)
if isinstance(content, str):
content = content.encode()
res = requests.models.Response()
res.status_code = rule.status
res._content_consumed = True # pylint: disable=protected-access
res._content = content # pylint: disable=protected-access
res.encoding = 'utf-8'
res.request = prepared_request
res.headers.update(rule.headers or {})
rule.res.append((res, prepared_request))
if rule.side_effect:
rule.side_effect()
return res
def register(self, url=None, path=None, method='GET', status=200, content=b'',
side_effect=None, headers=None, expected_headers=None):
res = Responses()
self._map.append(Rule(url, path, method, status, content, side_effect, res, headers, expected_headers))
return res
def unregister(self, res):
for item in list(self._map):
if res == item.res:
self._map.remove(item)
return
def assertAllCalled(self):
for item in self._map:
res = item.res
res.assertCalled('[%s] %s%s' % (item.method or 'any', item.url or 'http://<any>', item.path))
|
class Registry:
def __init__(self):
pass
def __enter__(self):
pass
def __exit__(self, *exec_info):
pass
@staticmethod
def filter_request(rule, prepared_request):
pass
def find_rule(self, prepared_request):
pass
def mock_send(self, prepared_request, *args, **kwargs):
pass
def register(self, url=None, path=None, method='GET', status=200, content=b'',
side_effect=None, headers=None, expected_headers=None):
pass
def unregister(self, res):
pass
def assertAllCalled(self):
pass
| 11 | 0 | 9 | 1 | 7 | 1 | 3 | 0.1 | 0 | 6 | 1 | 0 | 8 | 2 | 9 | 9 | 89 | 20 | 69 | 22 | 57 | 7 | 58 | 20 | 48 | 9 | 0 | 3 | 23 |
4,605 |
Anaconda-Platform/anaconda-client
|
Anaconda-Platform_anaconda-client/tests/test_whoami.py
|
tests.test_whoami.Test
|
class Test(CLITestCase):
"""Tests for whoami command."""
@urlpatch
def test_whoami_anon(self, urls):
user = urls.register(method='GET', path='/user', status=401)
main(['--show-traceback', 'whoami'])
self.assertIn('Anonymous User', self.stream.getvalue())
user.assertCalled()
@urlpatch
def test_whoami(self, urls):
content = json.dumps({'login': 'eggs', 'created_at': '1/2/2000'})
user = urls.register(method='GET', path='/user', content=content)
main(['--show-traceback', 'whoami'])
self.assertIn('eggs', self.stream.getvalue())
user.assertCalled()
@urlpatch
def test_netrc_ignored(self, urls):
# Disable token authentication
self.load_token.return_value = None
os.environ.pop('BINSTAR_API_TOKEN', None)
os.environ.pop('ANACONDA_API_TOKEN', None)
# requests.get_netrc_auth uses expanduser to find the netrc file, point to our test file
expanduser = unittest.mock.Mock(return_value=data_dir('netrc'))
with unittest.mock.patch('os.path.expanduser', expanduser):
auth = requests.utils.get_netrc_auth('http://localhost', raise_errors=True)
self.assertEqual(auth, ('anonymous', 'pass'))
user = urls.register(path='/user', status=401)
main(['--show-traceback', 'whoami'])
# Not called because token is missing.
user.assertNotCalled()
self.assertIsNone(user.req)
|
class Test(CLITestCase):
'''Tests for whoami command.'''
@urlpatch
def test_whoami_anon(self, urls):
pass
@urlpatch
def test_whoami_anon(self, urls):
pass
@urlpatch
def test_netrc_ignored(self, urls):
pass
| 7 | 1 | 11 | 2 | 8 | 1 | 1 | 0.15 | 1 | 1 | 0 | 0 | 3 | 0 | 3 | 77 | 41 | 10 | 27 | 13 | 20 | 4 | 24 | 10 | 20 | 1 | 3 | 1 | 3 |
4,606 |
Anaconda-Platform/anaconda-client
|
Anaconda-Platform_anaconda-client/tests/test_update.py
|
tests.test_update.TestUpdate
|
class TestUpdate(CLITestCase):
"""Tests for metadata update commands."""
@urlpatch
def test_update_package_from_json(self, urls):
urls.register(method='HEAD', path='/', status=200)
update = urls.register(method='PATCH', path='/package/owner/package_name', content=json_test_data, status=200)
main(['update', 'owner/package_name', data_dir('metadata.json')])
urls.assertAllCalled()
req = json.loads(update.req.body)
self.assertEqual(req, json_test_data)
@urlpatch
def test_update_package_from_file(self, urls):
urls.register(method='HEAD', path='/', status=200)
update = urls.register(method='PATCH', path='/package/owner/package_name',
content=package_test_data, status=200)
main(['update', 'owner/package_name', data_dir('test_package34-0.3.1.tar.gz')])
urls.assertAllCalled()
req = json.loads(update.req.body)
self.assertEqual(req, package_test_data)
@urlpatch
def test_update_release_from_json(self, urls):
urls.register(method='HEAD', path='/', status=200)
update = urls.register(method='PATCH', path='/release/owner/package_name/1.0.0',
content=json_test_data, status=200)
main(['update', 'owner/package_name/1.0.0', data_dir('metadata.json'), '--release'])
urls.assertAllCalled()
req = json.loads(update.req.body)
self.assertEqual(req, json_test_data)
@urlpatch
def test_update_release_from_file(self, urls):
urls.register(method='HEAD', path='/', status=200)
update = urls.register(method='PATCH', path='/release/owner/package_name/1.0.0',
content=release_test_data, status=200)
main(['update', 'owner/package_name/1.0.0', data_dir('test_package34-0.3.1.tar.gz'), '--release'])
urls.assertAllCalled()
req = json.loads(update.req.body)
self.assertEqual(req, release_test_data)
@urlpatch
def test_update_local_file_not_found(self, urls):
urls.register(method='HEAD', path='/', status=200)
urls.register(method='PATCH', path='/package/owner/package_name', content=package_test_data, status=404)
with self.assertRaises(SystemExit):
main(['update', 'owner/package_name', data_dir('not_existing.tar.gz')])
@urlpatch
def test_update_package_not_found(self, urls):
urls.register(method='HEAD', path='/', status=200)
urls.register(method='PATCH', path='/package/owner/package_name', content=package_test_data, status=404)
with self.assertRaises(errors.NotFound):
main(['update', 'owner/package_name', data_dir('test_package34-0.3.1.tar.gz')])
@urlpatch
def test_update_release_missing_version(self, urls):
urls.register(method='HEAD', path='/', status=200)
urls.register(method='PATCH', path='/release/owner/package_name/1.0.0', content=package_test_data, status=200)
with self.assertRaises(errors.UserError):
main(['update', 'owner/package_name', data_dir('test_package34-0.3.1.tar.gz'), '--release'])
@urlpatch
def test_update_release_not_found(self, urls):
urls.register(method='HEAD', path='/', status=200)
urls.register(method='PATCH', path='/release/owner/package_name/1.0.0', content=package_test_data, status=404)
with self.assertRaises(errors.NotFound):
main(['update', 'owner/package_name/1.0.0', data_dir('test_package34-0.3.1.tar.gz'), '--release'])
|
class TestUpdate(CLITestCase):
'''Tests for metadata update commands.'''
@urlpatch
def test_update_package_from_json(self, urls):
pass
@urlpatch
def test_update_package_from_file(self, urls):
pass
@urlpatch
def test_update_release_from_json(self, urls):
pass
@urlpatch
def test_update_release_from_file(self, urls):
pass
@urlpatch
def test_update_local_file_not_found(self, urls):
pass
@urlpatch
def test_update_package_not_found(self, urls):
pass
@urlpatch
def test_update_release_missing_version(self, urls):
pass
@urlpatch
def test_update_release_not_found(self, urls):
pass
| 17 | 1 | 7 | 1 | 6 | 0 | 1 | 0.02 | 1 | 3 | 2 | 0 | 8 | 0 | 8 | 82 | 76 | 15 | 60 | 25 | 43 | 1 | 49 | 17 | 40 | 1 | 3 | 1 | 8 |
4,607 |
Anaconda-Platform/anaconda-client
|
Anaconda-Platform_anaconda-client/tests/test_subdir.py
|
tests.test_subdir.TestGetSubdir
|
class TestGetSubdir(unittest.TestCase):
def test_noarch(self):
index = {'subdir': 'noarch'}
self.assertEqual(get_subdir(index), 'noarch')
index = {'arch': None}
self.assertEqual(get_subdir(index), 'noarch')
index = {}
self.assertEqual(get_subdir(index), 'noarch')
index = {'arch': 'x86_64', 'platform': None, 'subdir': 'noarch'}
self.assertEqual(get_subdir(index), 'noarch')
def test_linux64(self):
index = {'arch': 'x86_64', 'platform': 'linux'}
self.assertEqual(get_subdir(index), 'linux-64')
def test_osx32(self):
index = {'arch': 'x86', 'platform': 'osx'}
self.assertEqual(get_subdir(index), 'osx-32')
def test_ppc64(self):
index = {'arch': 'ppc64le', 'platform': 'linux'}
self.assertEqual(get_subdir(index), 'linux-ppc64le')
index = {'subdir': 'linux-ppc64le'}
self.assertEqual(get_subdir(index), 'linux-ppc64le')
|
class TestGetSubdir(unittest.TestCase):
def test_noarch(self):
pass
def test_linux64(self):
pass
def test_osx32(self):
pass
def test_ppc64(self):
pass
| 5 | 0 | 6 | 1 | 5 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 4 | 0 | 4 | 76 | 29 | 8 | 21 | 9 | 16 | 0 | 21 | 9 | 16 | 1 | 2 | 0 | 4 |
4,608 |
Anaconda-Platform/anaconda-client
|
Anaconda-Platform_anaconda-client/tests/test_requests_ext.py
|
tests.test_requests_ext.TestMultiPart
|
class TestMultiPart(unittest.TestCase):
def test_unicode_read(self):
body = io.BytesIO('Unicode™'.encode('utf-8'))
multipart = requests_ext.MultiPartIO([body])
self.assertEqual('Unicode™'.encode('utf-8'), multipart.read())
|
class TestMultiPart(unittest.TestCase):
def test_unicode_read(self):
pass
| 2 | 0 | 4 | 0 | 4 | 0 | 1 | 0 | 1 | 1 | 1 | 0 | 1 | 0 | 1 | 73 | 5 | 0 | 5 | 4 | 3 | 0 | 5 | 4 | 3 | 1 | 2 | 0 | 1 |
4,609 |
Anaconda-Platform/anaconda-client
|
Anaconda-Platform_anaconda-client/tests/test_register.py
|
tests.test_register.Test
|
class Test(CLITestCase):
"""Tests for package registration commands."""
@urlpatch
def test_register_public(self, registry):
r1 = registry.register(method='GET', path='/user', content='{"login": "eggs"}')
r2 = registry.register(method='GET', path='/package/eggs/foo', status=404)
r3 = registry.register(method='POST', path='/package/eggs/foo', status=200, content='{"login": "eggs"}')
main(['--show-traceback', 'register', data_dir('foo-0.1-0.tar.bz2')])
r1.assertCalled()
r2.assertCalled()
r3.assertCalled()
data = json.loads(r3.req.body)
self.assertTrue(data['public'])
@urlpatch
def test_register_private(self, registry): # pylint: disable=missing-function-docstring
r1 = registry.register(method='GET', path='/user', content='{"login": "eggs"}')
r2 = registry.register(method='GET', path='/package/eggs/foo', status=404)
r3 = registry.register(method='POST', path='/package/eggs/foo', status=200, content='{"login": "eggs"}')
main(['--show-traceback', 'register', '--private', data_dir('foo-0.1-0.tar.bz2')])
r1.assertCalled()
r2.assertCalled()
r3.assertCalled()
data = json.loads(r3.req.body)
self.assertFalse(data['public'])
|
class Test(CLITestCase):
'''Tests for package registration commands.'''
@urlpatch
def test_register_public(self, registry):
pass
@urlpatch
def test_register_private(self, registry):
pass
| 5 | 1 | 13 | 3 | 10 | 1 | 1 | 0.09 | 1 | 0 | 0 | 0 | 2 | 0 | 2 | 76 | 32 | 8 | 23 | 13 | 18 | 2 | 21 | 11 | 18 | 1 | 3 | 0 | 2 |
4,610 |
Anaconda-Platform/anaconda-client
|
Anaconda-Platform_anaconda-client/tests/test_packages.py
|
tests.test_packages.Test
|
class Test(unittest.TestCase):
@urlpatch
def test_packages_array_param(self, urls):
api = Binstar()
urls.register(method='GET', path='/packages/u1?package_type=conda&package_type=pypi', content='[]')
api.user_packages('u1', package_type=['conda', 'pypi'])
urls.assertAllCalled()
@urlpatch
def test_packages_parameters(self, urls):
api = Binstar()
urls.register(method='GET', path='/packages/u1?platform=osx-64&package_type=conda&type=app', content='[]')
api.user_packages('u1', platform='osx-64', type_='app', package_type='conda')
urls.assertAllCalled()
@urlpatch
def test_packages_empty(self, urls):
api = Binstar()
urls.register(method='GET', path='/packages/u1', content='[]')
packages = api.user_packages('u1')
self.assertEqual(packages, [])
urls.assertAllCalled()
|
class Test(unittest.TestCase):
@urlpatch
def test_packages_array_param(self, urls):
pass
@urlpatch
def test_packages_parameters(self, urls):
pass
@urlpatch
def test_packages_empty(self, urls):
pass
| 7 | 0 | 7 | 2 | 5 | 0 | 1 | 0 | 1 | 1 | 1 | 0 | 3 | 0 | 3 | 75 | 28 | 8 | 20 | 11 | 13 | 0 | 17 | 8 | 13 | 1 | 2 | 0 | 3 |
4,611 |
Anaconda-Platform/anaconda-client
|
Anaconda-Platform_anaconda-client/tests/test_license.py
|
tests.test_license.Test
|
class Test(unittest.TestCase):
@urlpatch
def test_licenses_array_param(self, urls):
api = Binstar()
urls.register(method='GET', path='/license', content='[]')
api.user_licenses()
urls.assertAllCalled()
|
class Test(unittest.TestCase):
@urlpatch
def test_licenses_array_param(self, urls):
pass
| 3 | 0 | 5 | 0 | 5 | 0 | 1 | 0 | 1 | 1 | 1 | 0 | 1 | 0 | 1 | 73 | 7 | 0 | 7 | 4 | 4 | 0 | 6 | 3 | 4 | 1 | 2 | 0 | 1 |
4,612 |
AndresMWeber/Nomenclate
|
tests/test_tokens.py
|
tests.test_tokens.TestTokenAttrSet
|
class TestTokenAttrSet(TestTokenAttrBase):
def test_set_invalid(self):
with self.assertRaises(exceptions.ValidationError):
tokens.TokenAttr().label = [1]
with self.assertRaises(exceptions.ValidationError):
tokens.TokenAttr().label = {1: 1}
|
class TestTokenAttrSet(TestTokenAttrBase):
def test_set_invalid(self):
pass
| 2 | 0 | 5 | 0 | 5 | 0 | 1 | 0 | 1 | 2 | 2 | 0 | 1 | 0 | 1 | 78 | 6 | 0 | 6 | 2 | 4 | 0 | 6 | 2 | 4 | 1 | 4 | 1 | 1 |
4,613 |
AndresMWeber/Nomenclate
|
tests/test_tokens.py
|
tests.test_tokens.TestTokenEq
|
class TestTokenEq(TestTokenAttrBase):
def test_equal(self):
self.assertTrue(tokens.TokenAttr('name', 'Bob') == tokens.TokenAttr('name', 'Bob'))
def test_not_equal_label(self):
self.assertFalse(tokens.TokenAttr('name', 'Bob') == tokens.TokenAttr('name', 'Fob'))
def test_not_equal_token(self):
self.assertFalse(tokens.TokenAttr('name', 'Bob') == tokens.TokenAttr('fame', 'Bob'))
def test_non_token(self):
self.assertFalse(tokens.TokenAttr('name', 'Bob') == '<TokenAttr name(name):\'Bob\'>')
|
class TestTokenEq(TestTokenAttrBase):
def test_equal(self):
pass
def test_not_equal_label(self):
pass
def test_not_equal_token(self):
pass
def test_non_token(self):
pass
| 5 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 1 | 1 | 0 | 4 | 0 | 4 | 81 | 12 | 3 | 9 | 5 | 4 | 0 | 9 | 5 | 4 | 1 | 4 | 0 | 4 |
4,614 |
AndresMWeber/Nomenclate
|
tests/test_tokens.py
|
tests.test_tokens.TestTokenGe
|
class TestTokenGe(TestTokenAttrBase):
def test_equal(self):
self.assertTrue(tokens.TokenAttr('name', 'Bob') >= tokens.TokenAttr('name', 'Bob'))
def test_not_equal_label(self):
self.assertFalse(tokens.TokenAttr('name', 'Bob') >= tokens.TokenAttr('name', 'Fob'))
def test_not_equal_token(self):
self.assertTrue(tokens.TokenAttr('name', 'Bob') >= tokens.TokenAttr('fame', 'Bob'))
def test_non_token(self):
self.assertRaises(AttributeError, tokens.TokenAttr('name', 'Bob').__ge__, '<TokenAttr name(name):\'Bob\'>')
|
class TestTokenGe(TestTokenAttrBase):
def test_equal(self):
pass
def test_not_equal_label(self):
pass
def test_not_equal_token(self):
pass
def test_non_token(self):
pass
| 5 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 2 | 1 | 0 | 4 | 0 | 4 | 81 | 12 | 3 | 9 | 5 | 4 | 0 | 9 | 5 | 4 | 1 | 4 | 0 | 4 |
4,615 |
AndresMWeber/Nomenclate
|
tests/test_tokens.py
|
tests.test_tokens.TestTokenGt
|
class TestTokenGt(TestTokenAttrBase):
def test_equal(self):
self.assertFalse(tokens.TokenAttr('name', 'Bob') > tokens.TokenAttr('name', 'Bob'))
def test_not_equal_label(self):
self.assertFalse(tokens.TokenAttr('name', 'Bob') > tokens.TokenAttr('name', 'Fob'))
def test_not_equal_token(self):
self.assertTrue(tokens.TokenAttr('name', 'Bob') > tokens.TokenAttr('fame', 'Bob'))
def test_non_token(self):
self.assertRaises(AttributeError, tokens.TokenAttr('name', 'Bob').__gt__, '<TokenAttr name(name):\'Bob\'>')
|
class TestTokenGt(TestTokenAttrBase):
def test_equal(self):
pass
def test_not_equal_label(self):
pass
def test_not_equal_token(self):
pass
def test_non_token(self):
pass
| 5 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 2 | 1 | 0 | 4 | 0 | 4 | 81 | 12 | 3 | 9 | 5 | 4 | 0 | 9 | 5 | 4 | 1 | 4 | 0 | 4 |
4,616 |
AndresMWeber/Nomenclate
|
tests/test_tokens.py
|
tests.test_tokens.TestTokenStr
|
class TestTokenStr(TestTokenAttrBase):
def test_label_valid(self):
token_attr = tokens.TokenAttr('name', 'bob')
self.assertEquals(str(token_attr), repr(token_attr))
def test_label_empty(self):
token_attr = tokens.TokenAttr('name', '')
self.assertEquals(str(token_attr), repr(token_attr))
|
class TestTokenStr(TestTokenAttrBase):
def test_label_valid(self):
pass
def test_label_empty(self):
pass
| 3 | 0 | 3 | 0 | 3 | 0 | 1 | 0 | 1 | 2 | 1 | 0 | 2 | 0 | 2 | 79 | 8 | 1 | 7 | 5 | 4 | 0 | 7 | 5 | 4 | 1 | 4 | 0 | 2 |
4,617 |
AndresMWeber/Nomenclate
|
tests/test_tokens.py
|
tests.test_tokens.TestTokenNe
|
class TestTokenNe(TestTokenAttrBase):
def test_equal(self):
self.assertFalse(tokens.TokenAttr('name', 'Bob') != tokens.TokenAttr('name', 'Bob'))
def test_not_equal_label(self):
self.assertTrue(tokens.TokenAttr('name', 'Bob') != tokens.TokenAttr('name', 'Fob'))
def test_not_equal_token(self):
self.assertTrue(tokens.TokenAttr('name', 'Bob') != tokens.TokenAttr('fame', 'Bob'))
def test_non_token(self):
self.assertRaises(AttributeError, tokens.TokenAttr('name', 'Bob').__ne__, '<TokenAttr name(name):\'Bob\'>')
|
class TestTokenNe(TestTokenAttrBase):
def test_equal(self):
pass
def test_not_equal_label(self):
pass
def test_not_equal_token(self):
pass
def test_non_token(self):
pass
| 5 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 2 | 1 | 0 | 4 | 0 | 4 | 81 | 12 | 3 | 9 | 5 | 4 | 0 | 9 | 5 | 4 | 1 | 4 | 0 | 4 |
4,618 |
AndresMWeber/Nomenclate
|
tests/test_tokens.py
|
tests.test_tokens.TestTokenRepr
|
class TestTokenRepr(TestTokenAttrBase):
@staticmethod
def build_repr(token_attr):
return '<%s (%s): %r>' % (token_attr.__class__.__name__,
token_attr.token,
token_attr.to_json())
def test_label_valid(self):
token_attr = tokens.TokenAttr('name', 'bob')
self.assertEquals(repr(token_attr), self.build_repr(token_attr))
def test_label_empty(self):
token_attr = tokens.TokenAttr('name', '')
self.assertEquals(repr(token_attr), self.build_repr(token_attr))
|
class TestTokenRepr(TestTokenAttrBase):
@staticmethod
def build_repr(token_attr):
pass
def test_label_valid(self):
pass
def test_label_empty(self):
pass
| 5 | 0 | 3 | 0 | 3 | 0 | 1 | 0 | 1 | 1 | 1 | 0 | 2 | 0 | 3 | 80 | 14 | 2 | 12 | 7 | 7 | 0 | 9 | 6 | 5 | 1 | 4 | 0 | 3 |
4,619 |
AndresMWeber/Nomenclate
|
tests/test_tokens.py
|
tests.test_tokens.TestTokenToken
|
class TestTokenToken(TestTokenAttrBase):
def test_token_valid(self):
token_attr = tokens.TokenAttr('name', 'bob')
self.assertEquals(token_attr.token, 'name')
def test_token_empty(self):
token_attr = tokens.TokenAttr('', 'bob')
self.assertEquals(token_attr.token, '')
def test_token_set(self):
token_attr = tokens.TokenAttr('', 'bob')
self.assertEquals(token_attr.token, '')
token_attr.token = 'name'
self.assertEquals(token_attr.token, 'name')
|
class TestTokenToken(TestTokenAttrBase):
def test_token_valid(self):
pass
def test_token_empty(self):
pass
def test_token_set(self):
pass
| 4 | 0 | 4 | 0 | 4 | 0 | 1 | 0 | 1 | 1 | 1 | 0 | 3 | 0 | 3 | 80 | 14 | 2 | 12 | 7 | 8 | 0 | 12 | 7 | 8 | 1 | 4 | 0 | 3 |
4,620 |
AndresMWeber/Nomenclate
|
nomenclate/core/errors.py
|
nomenclate.core.errors.FormatError
|
class FormatError(NomenclateException):
"""Format error.
"""
pass
|
class FormatError(NomenclateException):
'''Format error.
'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 10 | 4 | 0 | 2 | 1 | 1 | 2 | 2 | 1 | 1 | 0 | 4 | 0 | 0 |
4,621 |
AndresMWeber/Nomenclate
|
tests/test_tokens.py
|
tests.test_tokens.TestTokenLe
|
class TestTokenLe(TestTokenAttrBase):
def test_equal(self):
self.assertTrue(tokens.TokenAttr('name', 'Bob') >= tokens.TokenAttr('name', 'Bob'))
def test_not_equal_label(self):
self.assertFalse(tokens.TokenAttr('name', 'Bob') >= tokens.TokenAttr('name', 'Fob'))
def test_not_equal_token(self):
self.assertTrue(tokens.TokenAttr('name', 'Bob') >= tokens.TokenAttr('fame', 'Bob'))
def test_non_token(self):
self.assertRaises(AttributeError, tokens.TokenAttr('name', 'Bob').__le__, '<TokenAttr name(name):\'Bob\'>')
|
class TestTokenLe(TestTokenAttrBase):
def test_equal(self):
pass
def test_not_equal_label(self):
pass
def test_not_equal_token(self):
pass
def test_non_token(self):
pass
| 5 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 2 | 1 | 0 | 4 | 0 | 4 | 81 | 12 | 3 | 9 | 5 | 4 | 0 | 9 | 5 | 4 | 1 | 4 | 0 | 4 |
4,622 |
AndresMWeber/Nomenclate
|
nomenclate/core/errors.py
|
nomenclate.core.errors.BalanceError
|
class BalanceError(ValidationError):
"""IO error.
"""
pass
|
class BalanceError(ValidationError):
'''IO error.
'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 10 | 4 | 0 | 2 | 1 | 1 | 2 | 2 | 1 | 1 | 0 | 5 | 0 | 0 |
4,623 |
AndresMWeber/Nomenclate
|
nomenclate/core/configurator.py
|
nomenclate.core.configurator.ConfigEntryFormatter
|
class ConfigEntryFormatter(object):
def format_query_result(self, query_result, query_path, return_type=list, preceding_depth=None):
""" Formats the query result based on the return type requested.
:param query_result: (dict or str or list), yaml query result
:param query_path: (str, list(str)), representing query path
:param return_type: type, return type of object user desires
:param preceding_depth: int, the depth to which we want to encapsulate back up config tree
-1 : defaults to entire tree
:return: (dict, OrderedDict, str, list), specified return type
"""
if type(query_result) != return_type:
converted_result = self.format_with_handler(query_result, return_type)
else:
converted_result = query_result
converted_result = self.add_preceding_dict(converted_result, query_path, preceding_depth)
return converted_result
def format_with_handler(self, query_result, return_type):
""" Uses the callable handler to format the query result to the desired return type
:param query_result: the result value of our query
:param return_type: desired return type
:return: type, the query value as the return type requested
"""
handler = self.get_handler(type(query_result), return_type)
return handler.format_result(query_result)
@staticmethod
def get_handler(query_result_type, return_type):
""" Find the appropriate return type handler to convert the query result to the desired return type
:param query_result_type: type, desired return type
:param return_type: type, actual return type
:return: callable, function that will handle the conversion
"""
try:
return FormatterRegistry.get_by_take_and_return_type(query_result_type, return_type)
except (IndexError, AttributeError, KeyError):
raise IndexError(
"Could not find function in conversion list for input type %s and return type %s"
% (query_result_type, return_type)
)
@staticmethod
def add_preceding_dict(config_entry, query_path, preceding_depth):
""" Adds the preceeding config keys to the config_entry to simulate the original full path to the config entry
:param config_entry: object, the entry that was requested and returned from the config
:param query_path: (str, list(str)), the original path to the config_entry
:param preceding_depth: int, the depth to which we are recreating the preceding config keys
:return: dict, simulated config to n * preceding_depth
"""
if preceding_depth is None:
return config_entry
preceding_dict = {query_path[-1]: config_entry}
path_length_minus_query_pos = len(query_path) - 1
preceding_depth = (
path_length_minus_query_pos - preceding_depth if preceding_depth != -1 else 0
)
for index in reversed(range(preceding_depth, path_length_minus_query_pos)):
preceding_dict = {query_path[index]: preceding_dict}
return preceding_dict
|
class ConfigEntryFormatter(object):
def format_query_result(self, query_result, query_path, return_type=list, preceding_depth=None):
''' Formats the query result based on the return type requested.
:param query_result: (dict or str or list), yaml query result
:param query_path: (str, list(str)), representing query path
:param return_type: type, return type of object user desires
:param preceding_depth: int, the depth to which we want to encapsulate back up config tree
-1 : defaults to entire tree
:return: (dict, OrderedDict, str, list), specified return type
'''
pass
def format_with_handler(self, query_result, return_type):
''' Uses the callable handler to format the query result to the desired return type
:param query_result: the result value of our query
:param return_type: desired return type
:return: type, the query value as the return type requested
'''
pass
@staticmethod
def get_handler(query_result_type, return_type):
''' Find the appropriate return type handler to convert the query result to the desired return type
:param query_result_type: type, desired return type
:param return_type: type, actual return type
:return: callable, function that will handle the conversion
'''
pass
@staticmethod
def add_preceding_dict(config_entry, query_path, preceding_depth):
''' Adds the preceeding config keys to the config_entry to simulate the original full path to the config entry
:param config_entry: object, the entry that was requested and returned from the config
:param query_path: (str, list(str)), the original path to the config_entry
:param preceding_depth: int, the depth to which we are recreating the preceding config keys
:return: dict, simulated config to n * preceding_depth
'''
pass
| 7 | 4 | 15 | 2 | 7 | 6 | 2 | 0.75 | 1 | 8 | 1 | 0 | 2 | 0 | 4 | 4 | 67 | 11 | 32 | 12 | 25 | 24 | 24 | 10 | 19 | 4 | 1 | 1 | 9 |
4,624 |
AndresMWeber/Nomenclate
|
nomenclate/core/configurator.py
|
nomenclate.core.configurator.OrderedDictToList
|
class OrderedDictToList(BaseFormatter):
converts = {"accepted_input_type": OrderedDict, "accepted_return_type": list}
@staticmethod
def format_result(input):
"""From: http://stackoverflow.com/questions/13062300/convert-a-dict-to-sorted-dict-in-python
"""
return list(input)
|
class OrderedDictToList(BaseFormatter):
@staticmethod
def format_result(input):
'''From: http://stackoverflow.com/questions/13062300/convert-a-dict-to-sorted-dict-in-python
'''
pass
| 3 | 1 | 4 | 0 | 2 | 2 | 1 | 0.4 | 1 | 1 | 0 | 0 | 0 | 0 | 1 | 17 | 8 | 1 | 5 | 4 | 2 | 2 | 4 | 3 | 2 | 1 | 4 | 0 | 1 |
4,625 |
AndresMWeber/Nomenclate
|
nomenclate/core/configurator.py
|
nomenclate.core.configurator.NoneToDict
|
class NoneToDict(BaseFormatter):
converts = {"accepted_input_type": type(None), "accepted_return_type": dict}
@staticmethod
def format_result(input):
"""From: http://stackoverflow.com/questions/13062300/convert-a-dict-to-sorted-dict-in-python
"""
return {}
|
class NoneToDict(BaseFormatter):
@staticmethod
def format_result(input):
'''From: http://stackoverflow.com/questions/13062300/convert-a-dict-to-sorted-dict-in-python
'''
pass
| 3 | 1 | 4 | 0 | 2 | 2 | 1 | 0.4 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 17 | 8 | 1 | 5 | 4 | 2 | 2 | 4 | 3 | 2 | 1 | 4 | 0 | 1 |
4,626 |
AndresMWeber/Nomenclate
|
nomenclate/core/configurator.py
|
nomenclate.core.configurator.ListToString
|
class ListToString(BaseFormatter):
converts = {"accepted_input_type": list, "accepted_return_type": str}
@staticmethod
def format_result(input):
return " ".join(input)
|
class ListToString(BaseFormatter):
@staticmethod
def format_result(input):
pass
| 3 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 17 | 6 | 1 | 5 | 4 | 2 | 0 | 4 | 3 | 2 | 1 | 4 | 0 | 1 |
4,627 |
AndresMWeber/Nomenclate
|
nomenclate/core/configurator.py
|
nomenclate.core.configurator.IntToList
|
class IntToList(BaseFormatter):
converts = {"accepted_input_type": int, "accepted_return_type": list}
@staticmethod
def format_result(input):
return [input]
|
class IntToList(BaseFormatter):
@staticmethod
def format_result(input):
pass
| 3 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 17 | 6 | 1 | 5 | 4 | 2 | 0 | 4 | 3 | 2 | 1 | 4 | 0 | 1 |
4,628 |
AndresMWeber/Nomenclate
|
nomenclate/core/configurator.py
|
nomenclate.core.configurator.FormatterRegistry
|
class FormatterRegistry(type):
""" Factory class responsible for registering all input type to type conversions.
E.G. - String -> List, Dict -> String etc.
"""
CONVERSION_TABLE = {}
def __new__(mcs, name, bases, dct):
cls = type.__new__(mcs, name, bases, dct)
extensions = dct.get("converts")
accepted_input_type = extensions.get("accepted_input_type", None)
accepted_return_type = extensions.get("accepted_return_type", None)
if accepted_input_type and accepted_return_type:
take_exists = mcs.CONVERSION_TABLE.get(accepted_input_type)
if not take_exists:
mcs.CONVERSION_TABLE[accepted_input_type] = {}
mcs.CONVERSION_TABLE[accepted_input_type][accepted_return_type] = cls
return cls
@classmethod
def get_by_take_and_return_type(mcs, input_type, return_type):
return mcs.CONVERSION_TABLE[input_type][return_type]
|
class FormatterRegistry(type):
''' Factory class responsible for registering all input type to type conversions.
E.G. - String -> List, Dict -> String etc.
'''
def __new__(mcs, name, bases, dct):
pass
@classmethod
def get_by_take_and_return_type(mcs, input_type, return_type):
pass
| 4 | 1 | 9 | 2 | 7 | 0 | 2 | 0.19 | 1 | 0 | 0 | 1 | 1 | 0 | 2 | 15 | 26 | 7 | 16 | 10 | 12 | 3 | 15 | 9 | 12 | 3 | 2 | 2 | 4 |
4,629 |
AndresMWeber/Nomenclate
|
nomenclate/core/configurator.py
|
nomenclate.core.configurator.DictToString
|
class DictToString(BaseFormatter):
converts = {"accepted_input_type": dict, "accepted_return_type": str}
@staticmethod
def format_result(input):
return " ".join(list(input))
|
class DictToString(BaseFormatter):
@staticmethod
def format_result(input):
pass
| 3 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 1 | 17 | 6 | 1 | 5 | 4 | 2 | 0 | 4 | 3 | 2 | 1 | 4 | 0 | 1 |
4,630 |
AndresMWeber/Nomenclate
|
nomenclate/core/configurator.py
|
nomenclate.core.configurator.DictToOrderedDict
|
class DictToOrderedDict(BaseFormatter):
converts = {"accepted_input_type": dict, "accepted_return_type": OrderedDict}
@staticmethod
def format_result(input):
"""From: http://stackoverflow.com/questions/13062300/convert-a-dict-to-sorted-dict-in-python
"""
items = list(input.items())
return OrderedDict(sorted(items, key=lambda x: x[0]))
|
class DictToOrderedDict(BaseFormatter):
@staticmethod
def format_result(input):
'''From: http://stackoverflow.com/questions/13062300/convert-a-dict-to-sorted-dict-in-python
'''
pass
| 3 | 1 | 5 | 0 | 3 | 2 | 1 | 0.33 | 1 | 2 | 0 | 0 | 0 | 0 | 1 | 17 | 9 | 1 | 6 | 5 | 3 | 2 | 5 | 4 | 3 | 1 | 4 | 0 | 1 |
4,631 |
AndresMWeber/Nomenclate
|
nomenclate/core/configurator.py
|
nomenclate.core.configurator.DictToList
|
class DictToList(BaseFormatter):
converts = {"accepted_input_type": dict, "accepted_return_type": list}
@staticmethod
def format_result(input):
""" Always sorted for order
"""
keys = list(input)
keys.sort()
return keys
|
class DictToList(BaseFormatter):
@staticmethod
def format_result(input):
''' Always sorted for order
'''
pass
| 3 | 1 | 6 | 0 | 4 | 2 | 1 | 0.29 | 1 | 1 | 0 | 0 | 0 | 0 | 1 | 17 | 10 | 1 | 7 | 5 | 4 | 2 | 6 | 4 | 4 | 1 | 4 | 0 | 1 |
4,632 |
AndresMWeber/Nomenclate
|
nomenclate/core/configurator.py
|
nomenclate.core.configurator.ConfigParse
|
class ConfigParse(object):
""" Responsible for finding + loading the configuration file contents then transmuting any config queries.
It can also be simply set from a dictionary.
"""
config_entry_handler = ConfigEntryFormatter()
def __init__(self, data: dict = None, config_filename: str = None):
"""
:param config_filepath: str, the path to a user specified config, or the nomenclate default
"""
self.config = None
self.config_filepath = None
if data:
self.set_from_dict(data)
if config_filename:
self.set_from_file(config_filename)
if not self.config:
self.create_user_config()
self.function_type_lookup = {
str: self._get_path_entry_from_string,
list: self._get_path_entry_from_list,
}
def create_user_config(self):
file_path = copy_file_to_home_dir(TEMPLATE_YML_CONFIG_FILE_PATH, DEFAULT_YML_CONFIG_FILE)
self.set_from_file(file_path)
def set_from_dict(self, data: dict):
""" Set the config from a dictionary to allow for non-config file based real time modifications to the config.
:param data: dict, the input data that will override the current config settings.
"""
self.config = OrderedDict(sorted(data, key=lambda x: x[0], reverse=True))
@classmethod
def validate_config_file(cls, config_filename: str):
return search_relative_cwd_user_dirs_for_file(config_filename, validator=validate_yaml_file)
def set_from_file(self, config_filename):
""" Loads from file and caches all data from the config file in the form of an OrderedDict to self.data
:param config_filepath: str, the full filepath to the config file
:return: bool, success status
"""
self.config_filepath = self.validate_config_file(config_filename)
config_data = None
with open(self.config_filepath, "r") as f:
config_data = yaml.safe_load(f)
try:
items = config_data.items()
except AttributeError:
items = list(config_data)
finally:
self.set_from_dict(items)
def get(self, query_path=None, return_type=list, preceding_depth: int = None):
""" Traverses the list of query paths to find the data requested
:param query_path: (list(str), str), list of query path branches or query string
Default behavior: returns list(str) of possible config headers
:param return_type: (list, str, dict, OrderedDict), desired return type for the data
:param preceding_depth: int, returns a dictionary containing the data that traces back up the path for x depth
-1: for the full traversal back up the path
None: is default for no traversal
:return: (list, str, dict, OrderedDict), the type specified from return_type
:raises: exceptions.ResourceNotFoundError: if the query path is invalid
"""
if query_path is None:
return self._default_config(return_type)
try:
config_entry = self.function_type_lookup.get(type(query_path), str)(query_path)
query_result = self.config_entry_handler.format_query_result(
config_entry, query_path, return_type=return_type, preceding_depth=preceding_depth
)
return query_result
except IndexError:
return return_type()
def _get_path_entry_from_string(self, query_string, first_found=True, full_path=False):
""" Parses a string to form a list of strings that represents a possible config entry header
:param query_string: str, query string we are looking for
:param first_found: bool, return first found entry or entire list
:param full_path: bool, whether to return each entry with their corresponding config entry path
:return: (Generator((list, str, dict, OrderedDict)), config entries that match the query string
:raises: exceptions.ResourceNotFoundError
"""
iter_matches = gen_dict_key_matches(query_string, self.config, full_path=full_path)
try:
return next(iter_matches) if first_found else iter_matches
except (StopIteration, TypeError):
raise ResourceNotFoundError(f"{query_string} not found in the config: {self.config}")
def _get_path_entry_from_list(self, query_path):
""" Returns the config entry at query path
:param query_path: list(str), config header path to follow for entry
:return: (list, str, dict, OrderedDict), config entry requested
:raises: exceptions.ResourceNotFoundError
"""
cur_data = self.config
try:
for child in query_path:
cur_data = cur_data[child]
return cur_data
except (AttributeError, KeyError):
raise ResourceNotFoundError("{query_path} not found in in the config.")
def _default_config(self, return_type):
""" Generates a default instance of whatever the type requested was (in case of miss)
:param return_type: type, type of object requested
:return: object, instance of return_type
"""
if return_type == list:
return [k for k in self.config]
return return_type()
|
class ConfigParse(object):
''' Responsible for finding + loading the configuration file contents then transmuting any config queries.
It can also be simply set from a dictionary.
'''
def __init__(self, data: dict = None, config_filename: str = None):
'''
:param config_filepath: str, the path to a user specified config, or the nomenclate default
'''
pass
def create_user_config(self):
pass
def set_from_dict(self, data: dict):
''' Set the config from a dictionary to allow for non-config file based real time modifications to the config.
:param data: dict, the input data that will override the current config settings.
'''
pass
@classmethod
def validate_config_file(cls, config_filename: str):
pass
def set_from_file(self, config_filename):
''' Loads from file and caches all data from the config file in the form of an OrderedDict to self.data
:param config_filepath: str, the full filepath to the config file
:return: bool, success status
'''
pass
def get(self, query_path=None, return_type=list, preceding_depth: int = None):
''' Traverses the list of query paths to find the data requested
:param query_path: (list(str), str), list of query path branches or query string
Default behavior: returns list(str) of possible config headers
:param return_type: (list, str, dict, OrderedDict), desired return type for the data
:param preceding_depth: int, returns a dictionary containing the data that traces back up the path for x depth
-1: for the full traversal back up the path
None: is default for no traversal
:return: (list, str, dict, OrderedDict), the type specified from return_type
:raises: exceptions.ResourceNotFoundError: if the query path is invalid
'''
pass
def _get_path_entry_from_string(self, query_string, first_found=True, full_path=False):
''' Parses a string to form a list of strings that represents a possible config entry header
:param query_string: str, query string we are looking for
:param first_found: bool, return first found entry or entire list
:param full_path: bool, whether to return each entry with their corresponding config entry path
:return: (Generator((list, str, dict, OrderedDict)), config entries that match the query string
:raises: exceptions.ResourceNotFoundError
'''
pass
def _get_path_entry_from_list(self, query_path):
''' Returns the config entry at query path
:param query_path: list(str), config header path to follow for entry
:return: (list, str, dict, OrderedDict), config entry requested
:raises: exceptions.ResourceNotFoundError
'''
pass
def _default_config(self, return_type):
''' Generates a default instance of whatever the type requested was (in case of miss)
:param return_type: type, type of object requested
:return: object, instance of return_type
'''
pass
| 11 | 8 | 12 | 1 | 7 | 4 | 2 | 0.62 | 1 | 12 | 1 | 0 | 8 | 3 | 9 | 9 | 124 | 22 | 63 | 24 | 52 | 39 | 56 | 22 | 46 | 4 | 1 | 2 | 20 |
4,633 |
AndresMWeber/Nomenclate
|
tests/test_tokens.py
|
tests.test_tokens.TestTokenAttrInstantiate
|
class TestTokenAttrInstantiate(TestTokenAttrBase):
def test_empty_instantiate(self):
self.assertEquals(tokens.TokenAttr().label, '')
def test_valid_instantiate(self):
self.fixtures.append(tokens.TokenAttr('test', 'test'))
def test_invalid_instantiate_token_list(self):
self.assertRaises(exceptions.ValidationError, tokens.TokenAttr, [], 'test')
def test_invalid_instantiate_token_dict(self):
self.assertRaises(exceptions.ValidationError, tokens.TokenAttr, {}, 'test')
def test_valid_instantiate_token(self):
self.assertEquals(tokens.TokenAttr('test', {}).label, "")
def test_state(self):
self.assertEquals(self.token_attr.label, 'test_label')
self.assertEquals(self.token_attr.token, 'test_token')
|
class TestTokenAttrInstantiate(TestTokenAttrBase):
def test_empty_instantiate(self):
pass
def test_valid_instantiate(self):
pass
def test_invalid_instantiate_token_list(self):
pass
def test_invalid_instantiate_token_dict(self):
pass
def test_valid_instantiate_token(self):
pass
def test_state(self):
pass
| 7 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 2 | 2 | 0 | 6 | 0 | 6 | 83 | 19 | 5 | 14 | 7 | 7 | 0 | 14 | 7 | 7 | 1 | 4 | 0 | 6 |
4,634 |
AndresMWeber/Nomenclate
|
nomenclate/core/configurator.py
|
nomenclate.core.configurator.StringToList
|
class StringToList(BaseFormatter):
converts = {"accepted_input_type": str, "accepted_return_type": list}
@staticmethod
def format_result(input):
return input.split()
|
class StringToList(BaseFormatter):
@staticmethod
def format_result(input):
pass
| 3 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 17 | 6 | 1 | 5 | 4 | 2 | 0 | 4 | 3 | 2 | 1 | 4 | 0 | 1 |
4,635 |
AndresMWeber/Nomenclate
|
tests/test_tokens.py
|
tests.test_tokens.TestTokenLabel
|
class TestTokenLabel(TestTokenAttrBase):
def test_normal_get(self):
token_attr = tokens.TokenAttr('name', 'Bob')
self.assertEquals(token_attr.label, 'Bob')
|
class TestTokenLabel(TestTokenAttrBase):
def test_normal_get(self):
pass
| 2 | 0 | 3 | 0 | 3 | 0 | 1 | 0 | 1 | 1 | 1 | 0 | 1 | 0 | 1 | 78 | 4 | 0 | 4 | 3 | 2 | 0 | 4 | 3 | 2 | 1 | 4 | 0 | 1 |
4,636 |
AndresMWeber/Nomenclate
|
tests/test_renderers.py
|
tests.test_renderers.TestRenderersBase
|
class TestRenderersBase(TestBase):
def setUp(self):
super(TestRenderersBase, self).setUp()
self.nomenclative_valid = processing.Nomenclative('side_location_nameDecoratorVar_childtype_purpose_type')
self.nomenclative_valid_short = processing.Nomenclative('side_name_type')
self.nomenclative_invalid = processing.Nomenclative('test_labelside')
self.token_test_dict = {'side': 'left',
'location': 'rear',
'name': 'test',
'decorator': '',
'var': 0,
'childtype': 'joints',
'purpose': 'offset',
'type': 'group'}
self.fixtures.append([self.nomenclative_valid,
self.nomenclative_valid_short,
self.nomenclative_invalid,
self.token_test_dict])
|
class TestRenderersBase(TestBase):
def setUp(self):
pass
| 2 | 0 | 19 | 2 | 17 | 0 | 1 | 0 | 1 | 2 | 1 | 1 | 1 | 4 | 1 | 77 | 20 | 2 | 18 | 6 | 16 | 0 | 8 | 6 | 6 | 1 | 3 | 0 | 1 |
4,637 |
AndresMWeber/Nomenclate
|
tests/test_tokens.py
|
tests.test_tokens.TestTokenAttrBase
|
class TestTokenAttrBase(TestBase):
def setUp(self):
super(TestTokenAttrBase, self).setUp()
self.token_attr = tokens.TokenAttr('test_token', 'test_label')
self.fixtures.append(self.token_attr)
|
class TestTokenAttrBase(TestBase):
def setUp(self):
pass
| 2 | 0 | 4 | 0 | 4 | 0 | 1 | 0 | 1 | 2 | 1 | 12 | 1 | 1 | 1 | 77 | 5 | 0 | 5 | 3 | 3 | 0 | 5 | 3 | 3 | 1 | 3 | 0 | 1 |
4,638 |
AndresMWeber/Nomenclate
|
tests/test_formatter.py
|
tests.test_formatter.TestFormatStringValidateFormatString
|
class TestFormatStringValidateFormatString(TestFormatStringBase):
def test_get__validate_format_string_valid(self):
self.fs.get_valid_format_order('side_mide')
def test_get__validate_format_string__is_format_invalid(self):
self.assertRaises(exceptions.FormatError, self.fs.get_valid_format_order, 'notside;blah')
|
class TestFormatStringValidateFormatString(TestFormatStringBase):
def test_get__validate_format_string_valid(self):
pass
def test_get__validate_format_string__is_format_invalid(self):
pass
| 3 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 1 | 1 | 0 | 2 | 0 | 2 | 79 | 6 | 1 | 5 | 3 | 2 | 0 | 5 | 3 | 2 | 1 | 4 | 0 | 2 |
4,639 |
AndresMWeber/Nomenclate
|
tests/test_nameparser.py
|
tests.test_nameparser.TestNameparser
|
class TestNameparser(TestBase):
def setUp(self):
super(TestNameparser, self).setUp()
self.fixture = np.NameParser()
self.test_filenames = ['VGS15_sh004_lgt_v002.ma',
'vhcl_chevyTraverse_2018_interior_rig_v06_jf.ma',
'nurs_enchant_lilies_hi_cn_flowers_receptacle_a_1002_tg',
'HKY_010_lighting_v007.hip',
'Will_102_060',
'cdf0090_lighting_PROPS_FG_RIM_beauty_v011.1062.exr',
'I_HKY_150_L1_v1_graded.1001.jpeg',
'us.gcr.io_valued-geode-142207%2Fappengine_default.tar',
'12-09-16_theStuff_photo_post1s_b02.psd']
def tearDown(self):
super(TestNameparser, self).tearDown()
del self.fixture
def test_parse_options(self):
self.assertEquals(self.fixture.parse_name(self.test_filenames[0])['basename']['match'], 'VGS15_sh_lgt')
self.assertEquals(self.fixture.parse_name(self.test_filenames[1])['basename']['match'], 'vhcl_chevyTraverse')
self.assertEquals(self.fixture.parse_name(self.test_filenames[2])['basename']['match'],
'nurs_enchant_lilies_hi')
self.assertEquals(self.fixture.parse_name(self.test_filenames[2])['side']['match'], 'cn')
self.assertEquals(self.fixture.parse_name(self.test_filenames[3])['basename']['match'], 'HKY')
self.assertEquals(self.fixture.parse_name(self.test_filenames[4])['basename']['match'], 'Will')
self.assertEquals(self.fixture.parse_name(self.test_filenames[5])['basename']['match'],
'cdf_lighting_PROPS_FG_RIM_beauty')
self.assertEquals(self.fixture.parse_name(self.test_filenames[6])['basename']['match'], 'I_HKY')
self.assertEquals(self.fixture.parse_name(self.test_filenames[7])['basename']['match'], 'us')
self.assertEquals(self.fixture.parse_name(self.test_filenames[8])['basename']['match'],
'theStuff_photo_post1s_b')
self.assertEquals(self.fixture.parse_name(self.test_filenames[8])['version']['version'], 2)
self.assertEquals(self.fixture.parse_name(self.test_filenames[8])['date']['match'], '12-09-16')
def test_short_options(self):
self.assertEqual(self.fixture.get_short('robotsLight8|robotLight2|robotLight2Shape'), 'robotLight2Shape')
self.assertEqual(self.fixture.get_short('robotLight2Shape'), 'robotLight2Shape')
self.assertEqual(self.fixture.get_short('robotsLight8|robotLight2|l_arm_up_LOC'), 'l_arm_up_LOC')
def test_discipline_options_invalid(self):
tests = ['gus_clothing_v10_aw.ZPR',
'Total_Protonic_reversal_v001_(Shane).exr',
'jacket_NORM.1004.tif',
'jacket_substance_EXPORT.abc',
'27_12_2015',
'clothing_compiled_maya_v01_aw.mb',
'QS_296.ZPR',
'r_foreLeg.obj',
'samsung_galaxy_s6_rough.stl',
'mansur_gavriel_purse_back.stl',
'LSC_sh01_v8_Nesquick_SFX_MS_WIP_v3_032415-540p_Quicktime.mov',
'IMG_20160509_140103743.jpg',
'hippydrome_2014.fbx', 'AM152_FBX.part03.rar',
'envelope_RB_v003_weights_groundhog.ma',
'envelope_weights_02_unsmoothedJoints.json',
'moleV01.001.jpg',
'robots8|robot2|robott2Shape']
for test in tests:
self.assertIsNone(self.fixture.get_discipline(test))
def test_discipline_options_valid(self):
tests = [('char_luchadorA-model1_qt1.mov', 'model'),
('kayJewelersPenguin_5402411_build_penguin_rigPuppet_penguin_v2.ma', 'rig'),
('rig_makeGentooPenguin.mel', 'rig'),
('Nesquik_Light_Sign_Anim_Test-1080p_HD_Quicktime.mov', 'Anim'),
('12302016_004_Nesquik_Light_Sign_Anim_Test.mov', 'Anim'),
('nesquikQuicky_5402876_build_char_quicky_model_quicky_lodA_v10.ma', 'model'),
('icons_MDL_v006_aw.ma', 'MDL')]
for test, val in tests:
self.assertEquals(self.fixture.get_discipline(test)['match'], val)
def test_get_side_options(self):
# Testing for isolated by underscores
self._side_runner(['%s_arm_up_LOC',
'prefix_%s_part_dir_type',
'prefix_part_up_%s'])
def test_get_side_camel(self):
self._side_runner(['prefix_part%s_dir_type',
'prefix_%sPart_dir_type'])
def test_get_side_no_side_present(self):
self.assertEquals(self.fixture.get_side('blah_is_no_type_of_side_LOC'),
None)
def test_side_edge_cases(self):
tests = [('r_foreLeg.obj', ['right', (0, 2), 'r']),
('jacket_substance_EXPORT.abc', None)]
for test_string, test_value in tests:
result = self.fixture.get_side(test_string)
if result:
result = [result[val] for val in ['side', 'position_full', 'match']]
self.assertEquals(result, test_value)
def _side_runner(self, test_options):
for side in ['left', 'right']:
permutations = []
for abbr in np.NameParser._get_abbreviations(side, 3):
permutations = itertools.chain(permutations,
np.NameParser._get_casing_permutations(abbr))
for permutation in permutations:
for test_option in test_options:
# Removing unlikely permutations like LeF: they could be mistaken for camel casing on other words
if self.fixture.is_valid_camel(permutation):
side_results = self.fixture.get_side(test_option % permutation)
if side_results:
side_results = [side_results[val] for val in ['side', 'position_full', 'match']]
test_index = test_option.find('%s') - 1
if permutation[0].islower() and test_option[test_index].isalpha() and test_index != -1:
self.assertIsNone(side_results)
else:
for element in [side, permutation]:
self.assertIn(element, side_results)
def test_get_date_specific(self):
self.assertEquals(self.fixture.get_date('12-09-16_theStuff_photo_post1s_b02.psd')['match'], '12-09-16')
def test_get_date_options(self):
test_formats = ['%Y-%m-%d_%H-%M-%S',
'%Y-%m-%d-%H-%M-%S',
'%Y-%m-%d--%H-%M-%S',
'%Y-%m-%d%H-%M-%S',
'%Y-%m-%d',
'%m_%d_%Y',
'%m_%d_%y',
'%m%d%y',
'%m%d%Y',
'%y_%m_%dT%H_%M_%S',
'%Y%m%d',
'%Y%m%d-%H%M%S',
'%Y%m%d-%H%M',
'%Y']
input_time = datetime.datetime(2016, 9, 16, 9, 30, 15)
orders = ['hotel_minatorOutpost_{DATE}_1.5.mb',
'hotel_minatorOutpost_1.5.mb_{DATE}',
'{DATE}_hotel_minatorOutpost_1.5.mb',
'{DATE}.hotel_minatorOutpost_1.5.mb',
'hotel_minator{DATE}_tested_LOC',
'hotel_{DATE}minator_tested_LOC',
'hotel_blahbergG{DATE}minator_tested_LOC',
'hippydrome_{DATE}.fbx',
'IMG_{DATE}_140103743.jpg']
for order in orders:
for test_format in test_formats:
result = self.fixture.get_date(order.format(DATE=input_time.strftime(test_format)))
if result:
result = (result['datetime'], result['format'])
self.assertEqual(result,
(datetime.datetime.strptime(input_time.strftime(test_format), test_format),
test_format))
def test_valid_camel(self):
for test in [('aAaa', True), ('Aaaa', False), ('AAAaaaaa', True), ('AAAAaaaAAA', True),
('AaA', True), ('Aa', False), ('AA', False), ('aa', False), ('camel', False),
('camelCase', True), ('CamelCase', True), ('CAMELCASE', False), ('camelcase', False),
('Camelcase', False), ('Case', False), ('camelCamelCase', True)]:
test, val = test
self.assertEquals(self.fixture.is_valid_camel(test), val)
def test_get_casing_permutations(self):
# testing all possible permutations of a simple example
self.assertEquals([i for i in self.fixture._get_casing_permutations('asdf')],
['asdf', 'Asdf', 'aSdf', 'ASdf',
'asDf', 'AsDf', 'aSDf', 'ASDf',
'asdF', 'AsdF', 'aSdF', 'ASdF',
'asDF', 'AsDF', 'aSDF', 'ASDF'])
# making sure it gives same results regardless of casing of original word
self.assertEquals([i for i in self.fixture._get_casing_permutations('AfdS')],
[i for i in self.fixture._get_casing_permutations('Afds')])
# double checking shorter casing permutations...it fucks up on length two currently
self.assertEquals([i for i in self.fixture._get_casing_permutations('lf')],
['lf', 'Lf', 'lF', 'LF'])
def test_get_abbrs_options(self):
self.assertEquals([i for i in self.fixture._get_abbreviations('test', 2)],
['te', 'tes', 'test', 'ts', 'tst', 'tt'])
self.assertEquals([i for i in self.fixture._get_abbreviations('test')],
['te', 'tes', 'test', 'ts', 'tst', 'tt', 't'])
def test_get_base_options(self):
self.assertEquals(self.fixture.get_base('gus_clothing_v10_aw.ZPR')['match'], 'gus_clothing')
self.assertEquals(self.fixture.get_base('jacket_NORM.1004.tif')['match'], 'jacket_NORM')
self.assertEquals(self.fixture.get_base('jacket_substance_EXPORT.abc')['match'], 'jacket_substance_EXPORT')
self.assertEquals(self.fixture.get_base('27_12_2015'), None)
self.assertEquals(self.fixture.get_base('clothing_compiled_maya_v01_aw.mb')['match'], 'clothing_compiled_maya')
self.assertEquals(self.fixture.get_base('QS_296.ZPR')['match'], 'QS')
self.assertEquals(self.fixture.get_base('char_luchadorA-model1_qt1.mov')['match'], 'char_luchadorA-model_qt')
self.assertEquals(
self.fixture.get_base('kayJewelersPenguin_5402411_build_penguin_rigPuppet_penguin_v2.ma')['match'],
'kayJewelersPenguin_5402411_build_penguin_rigPuppet_penguin')
self.assertEquals(self.fixture.get_base('rig_makeGentooPenguin.mel')['match'], 'rig_makeGentooPenguin')
self.assertEquals(self.fixture.get_base('r_foreLeg.obj')['match'], 'foreLeg')
self.assertEquals(self.fixture.get_base('samsung_galaxy_s6_rough.stl')['match'], 'samsung_galaxy_s_rough')
self.assertEquals(self.fixture.get_base('mansur_gavriel_purse_back.stl')['match'], 'mansur_gavriel_purse_back')
self.assertEquals(
self.fixture.get_base('LSC_sh01_v8_Nesquick_SFX_MS_WIP_v3_032415-540p_Quicktime.mov')['match'],
'LSC_sh')
self.assertEquals(self.fixture.get_base('Nesquik_Light_Sign_Anim_Test-1080p_HD_Quicktime.mov')['match'],
'Nesquik_Light_Sign_Anim_Test-1080p_HD_Quicktime')
self.assertEquals(self.fixture.get_base('12302016_004_Nesquik_Light_Sign_Anim_Test.mov')['match'],
'Nesquik_Light_Sign_Anim_Test')
self.assertEquals(
self.fixture.get_base('nesquikQuicky_5402876_build_char_quicky_model_quicky_lodA_v10.ma')['match'],
'nesquikQuicky_5402876_build_char_quicky_model_quicky_lodA')
self.assertEquals(self.fixture.get_base('IMG_20160509_140103743.jpg')['match'], 'IMG')
self.assertEquals(self.fixture.get_base('hippydrome_2014.fbx')['match'], 'hippydrome')
self.assertEquals(self.fixture.get_base('AM152_FBX.part03.rar')['match'], 'AM152_FBX')
self.assertEquals(self.fixture.get_base('envelope_RB_v003_weights_groundhog.ma')['match'], 'envelope_RB')
self.assertEquals(self.fixture.get_base('envelope_weights_02_unsmoothedJoints.json')['match'],
'envelope_weights')
self.assertEquals(self.fixture.get_base('icons_MDL_v006_aw.ma')['match'], 'icons_MDL')
self.assertEquals(self.fixture.get_base('moleV01.001.jpg')['match'], 'mole')
def test_get_version_options(self):
tests = [('gus_clothing_v10_aw.ZPR', (10, 'v10')),
('jacket_NORM.1004.tif', (1004, '1004')),
('jacket_substance_EXPORT.abc', None),
('27_12_2015', None),
('clothing_compiled_maya_v01_aw.mb', (1, 'v01')),
('QS_296.ZPR', (296, '296')),
('char_luchadorA-model1_qt1.mov', (1.1, '1')),
('kayJewelersPenguin_5402411_build_penguin_rigPuppet_penguin_v2.ma', (2, 'v2')),
('rig_makeGentooPenguin.mel', None),
('r_foreLeg.obj', None),
('samsung_galaxy_s6_rough.stl', (6, '6')),
('mansur_gavriel_purse_back.stl', None),
('LSC_sh01_v8_Nesquick_SFX_MS\-_WIP_v3_032415-540p_Quicktime.mov', ('1.8.3', '01')),
('Ne1004squik_Light_Sign_Anim_Test-1080p_HD_Quicktime.mov', None),
('12301121_004_Nesquik_Light_Sign_Anim_Test.mov', (4, '004')),
('nesquikQuicky_5402876_build_char_quicky_model_quicky_lodA_v10.ma', (10, 'v10')),
('IMG_20160509_140103743.jpg', None),
('hippydrome_2014.fbx', None),
('AM152_FBX.part03.rar', (3, '03')),
('envelope_RB_v003_weights_groundhog.ma', (3, 'v003')),
('envelope_weights_02_unsmoothedJoints.json', (2, '02')),
('icons_MDL_v0006_aw.ma', (6, 'v0006')),
('moleV01.001.jpg', (1.1, 'V01')),
('VGS15_sh004_lgt_v002', (4.2, '004'))]
for test, value in tests:
test_result = self.fixture.get_version(test)
if test_result is not None:
version = test_result.get('version', None) or test_result.get('compound_version')
match = test_result.get('match', None)
try:
match = test_result.get('compound_matches')[0].get('match')
except (IndexError, TypeError):
pass
self.assertEquals((version, match), value)
else:
self.assertEquals(test_result, value)
def test_get_udim_options(self):
tests = [('gus_clothing_v10_aw.ZPR', None),
('jacket_NORM.1004.tif', 1004),
('jacket_NORM1004.tif', 1004),
('jacket_NORM1004poop.tif', None), # Deemed a shitty case, not handling it.
('jacket_substance_EXPORT.abc', None),
('27_12_2015', None),
('QS_296.ZPR', None),
('Nesquik_Light_Sign_Anim_Test-1080p_HD_Quicktime.mov', None),
('IMG_20160509_140103743.jpg', None)]
for test_string, test_value in tests:
result = self.fixture.get_udim(test_string)
if result:
result = result['match_int']
self.assertEquals(result, test_value)
|
class TestNameparser(TestBase):
def setUp(self):
pass
def tearDown(self):
pass
def test_parse_options(self):
pass
def test_short_options(self):
pass
def test_discipline_options_invalid(self):
pass
def test_discipline_options_valid(self):
pass
def test_get_side_options(self):
pass
def test_get_side_camel(self):
pass
def test_get_side_no_side_present(self):
pass
def test_side_edge_cases(self):
pass
def _side_runner(self, test_options):
pass
def test_get_date_specific(self):
pass
def test_get_date_options(self):
pass
def test_valid_camel(self):
pass
def test_get_casing_permutations(self):
pass
def test_get_abbrs_options(self):
pass
def test_get_base_options(self):
pass
def test_get_version_options(self):
pass
def test_get_udim_options(self):
pass
| 20 | 0 | 13 | 0 | 13 | 0 | 2 | 0.02 | 1 | 6 | 1 | 0 | 19 | 2 | 19 | 95 | 272 | 23 | 244 | 53 | 224 | 6 | 129 | 53 | 109 | 9 | 3 | 6 | 40 |
4,640 |
AndresMWeber/Nomenclate
|
tests/test_nomenclature.py
|
tests.test_nomenclature.TestNomenclateBase
|
class TestNomenclateBase(TestBase):
def setUp(self):
super(TestNomenclateBase, self).setUp()
self.cfg = config.ConfigParse()
self.test_format = "side_location_nameDecoratorVar_childtype_purpose_type"
self.test_format_b = "location_nameDecoratorVar_childtype_purpose_type_side"
self.nom = nm.Nom()
# Inject our fake config
self.nom.CFG = self.cfg
self.nom.side.set("left")
self.nom.name.set("testObject")
self.nom.type.set("locator")
self.nom.var.set(0)
self.nom.var.case = "upper"
self.fixtures = [self.cfg, self.nom, self.test_format_b, self.test_format]
@property
def fill_vars(self):
return {
"childtype": "token",
"purpose": "filler",
"side": "left",
"var": 0,
"location": "top",
"type": "locator",
"name": "testObject",
"decorator": "joint",
}
@property
def empty_vars(self):
return {
"var": "",
"type": "",
"name": "",
"location": "",
"decorator": "",
"side": "",
"purpose": "",
"childtype": "",
}
@property
def partial_vars(self):
return {"side": "left", "var": 0, "type": "locator", "name": "testObject"}
@property
def missing_partials(self):
return {"location": "", "decorator": "", "purpose": "", "childtype": ""}
|
class TestNomenclateBase(TestBase):
def setUp(self):
pass
@property
def fill_vars(self):
pass
@property
def empty_vars(self):
pass
@property
def partial_vars(self):
pass
@property
def missing_partials(self):
pass
| 10 | 0 | 8 | 0 | 8 | 0 | 1 | 0.02 | 1 | 2 | 1 | 14 | 5 | 5 | 5 | 81 | 51 | 6 | 44 | 15 | 34 | 1 | 22 | 11 | 16 | 1 | 3 | 0 | 5 |
4,641 |
AndresMWeber/Nomenclate
|
tests/test_nomenclature.py
|
tests.test_nomenclature.TestNomenclateDir
|
class TestNomenclateDir(TestNomenclateBase):
def test_default(self):
nom = nm.Nom()
for item in nom.tokens:
self.assertIn(item.token, dir(nom))
def test_merge_dict(self):
nom = nm.Nom()
random = {"weird": "nope", "not_here": "haha", "foo": "bar"}
nom.merge_dict(random)
for item in list(random):
self.assertIn(item, dir(nom))
def test_swap_format(self):
nom = nm.Nom()
nom.format = ["naming_formats", "riggers", "raffaele_fragapane"]
for item in nom.tokens:
self.assertIn(item.token, dir(nom))
|
class TestNomenclateDir(TestNomenclateBase):
def test_default(self):
pass
def test_merge_dict(self):
pass
def test_swap_format(self):
pass
| 4 | 0 | 5 | 0 | 5 | 0 | 2 | 0 | 1 | 1 | 0 | 0 | 3 | 0 | 3 | 84 | 18 | 2 | 16 | 11 | 12 | 0 | 16 | 11 | 12 | 2 | 4 | 1 | 6 |
4,642 |
AndresMWeber/Nomenclate
|
tests/test_nomenclature.py
|
tests.test_nomenclature.TestNomenclateEq
|
class TestNomenclateEq(TestNomenclateBase):
def test_equal(self):
other = nm.Nom(self.nom)
self.assertTrue(other == self.nom)
def test_inequal_one_diff(self):
other = nm.Nom(self.nom.state)
other.name = "ronald"
self.assertFalse(other == self.nom)
def test_inequal_multi_diff(self):
other = nm.Nom(self.nom.state)
other.name = "ronald"
other.var = "C"
other.type = "joint"
self.assertFalse(other == self.nom)
|
class TestNomenclateEq(TestNomenclateBase):
def test_equal(self):
pass
def test_inequal_one_diff(self):
pass
def test_inequal_multi_diff(self):
pass
| 4 | 0 | 4 | 0 | 4 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 3 | 0 | 3 | 84 | 16 | 2 | 14 | 7 | 10 | 0 | 14 | 7 | 10 | 1 | 4 | 0 | 3 |
4,643 |
AndresMWeber/Nomenclate
|
tests/test_nomenclature.py
|
tests.test_nomenclature.TestNomenclateGet
|
class TestNomenclateGet(TestNomenclateBase):
def test_get(self):
self.assertEquals(self.nom.get(), "l_testObjectA_LOC")
def test_get_after_change(self):
previous_state = self.nom.state
self.nom.location.set("rear")
self.assertEquals(self.nom.get(), "l_rr_testObjectA_LOC")
self.nom.state = previous_state
|
class TestNomenclateGet(TestNomenclateBase):
def test_get(self):
pass
def test_get_after_change(self):
pass
| 3 | 0 | 4 | 0 | 4 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 2 | 0 | 2 | 83 | 9 | 1 | 8 | 4 | 5 | 0 | 8 | 4 | 5 | 1 | 4 | 0 | 2 |
4,644 |
AndresMWeber/Nomenclate
|
tests/test_nomenclature.py
|
tests.test_nomenclature.TestNomenclateGetFormatOrderFromFormatString
|
class TestNomenclateGetFormatOrderFromFormatString(TestNomenclateBase):
def test_get_format_order(self):
self.assertEquals(
self.nom.format_string_object.parse_format_order(self.test_format),
["side", "location", "name", "Decorator", "Var", "childtype", "purpose", "type"],
)
|
class TestNomenclateGetFormatOrderFromFormatString(TestNomenclateBase):
def test_get_format_order(self):
pass
| 2 | 0 | 5 | 0 | 5 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 82 | 6 | 0 | 6 | 2 | 4 | 0 | 3 | 2 | 1 | 1 | 4 | 0 | 1 |
4,645 |
AndresMWeber/Nomenclate
|
tests/test_nomenclature.py
|
tests.test_nomenclature.TestNomenclateInitializeConfigSettings
|
class TestNomenclateInitializeConfigSettings(TestNomenclateBase):
pass
|
class TestNomenclateInitializeConfigSettings(TestNomenclateBase):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 81 | 2 | 0 | 2 | 1 | 1 | 0 | 2 | 1 | 1 | 0 | 4 | 0 | 0 |
4,646 |
AndresMWeber/Nomenclate
|
tests/test_nomenclature.py
|
tests.test_nomenclature.TestNomenclateInitializeFormatOptions
|
class TestNomenclateInitializeFormatOptions(TestNomenclateBase):
def test_switch_naming_format_from_str(self):
self.nom.initialize_format_options(self.test_format_b)
self.assertTrue(
self.checkEqual(
self.nom.format_order,
["side", "location", "name", "Decorator", "Var", "childtype", "purpose", "type"],
)
)
self.nom.initialize_format_options(self.test_format)
self.assertTrue(
self.checkEqual(
self.nom.format_order,
["side", "location", "name", "Decorator", "Var", "childtype", "purpose", "type"],
)
)
def test_switch_multiple_naming_formats_from_config(self):
self.nom.initialize_format_options(["naming_formats", "riggers", "lee_wolland"])
self.assertTrue(
self.checkEqual(
self.nom.format_order, ["type", "childtype", "space", "purpose", "name", "side"]
)
)
self.nom.initialize_format_options(["naming_formats", "riggers", "raffaele_fragapane"])
self.assertTrue(
self.checkEqual(self.nom.format_order, ["name", "height", "Side", "Depth", "purpose"])
)
self.nom.initialize_format_options(self.test_format)
|
class TestNomenclateInitializeFormatOptions(TestNomenclateBase):
def test_switch_naming_format_from_str(self):
pass
def test_switch_multiple_naming_formats_from_config(self):
pass
| 3 | 0 | 15 | 2 | 14 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 2 | 0 | 2 | 83 | 32 | 4 | 28 | 3 | 25 | 0 | 12 | 3 | 9 | 1 | 4 | 0 | 2 |
4,647 |
AndresMWeber/Nomenclate
|
tests/test_nomenclature.py
|
tests.test_nomenclature.TestNomenclateInitializeOptions
|
class TestNomenclateInitializeOptions(TestNomenclateBase):
def test_options_stored(self):
nm.Nom.CONFIG_OPTIONS = None
nm.Nom.initialize_options()
self.assertIsNotNone(nm.Nom.CONFIG_OPTIONS)
|
class TestNomenclateInitializeOptions(TestNomenclateBase):
def test_options_stored(self):
pass
| 2 | 0 | 4 | 0 | 4 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 82 | 5 | 0 | 5 | 2 | 3 | 0 | 5 | 2 | 3 | 1 | 4 | 0 | 1 |
4,648 |
AndresMWeber/Nomenclate
|
tests/test_nomenclature.py
|
tests.test_nomenclature.TestNomenclateMergeDict
|
class TestNomenclateMergeDict(TestNomenclateBase):
def test_partial_merge(self):
nom = nm.Nom()
nom.merge_dict(self.partial_vars)
_ = {}
_.update(self.partial_vars)
_.update(self.missing_partials)
self.assertDictEqual(
{token: token_attr_dict["label"] for token, token_attr_dict in nom.state.items()}, _
)
def test_not_Found_in_format_merge(self):
nom = nm.Nom()
random = {"weird": "nope", "not_here": "haha", "foo": "bar"}
nom.merge_dict(random)
random.update(self.empty_vars)
self.assertDictEqual(nom.state, random)
|
class TestNomenclateMergeDict(TestNomenclateBase):
def test_partial_merge(self):
pass
def test_not_Found_in_format_merge(self):
pass
| 3 | 0 | 8 | 0 | 8 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 2 | 0 | 2 | 83 | 17 | 1 | 16 | 7 | 13 | 0 | 14 | 7 | 11 | 1 | 4 | 0 | 2 |
4,649 |
AndresMWeber/Nomenclate
|
tests/test_nomenclature.py
|
tests.test_nomenclature.TestNomenclateRepr
|
class TestNomenclateRepr(TestNomenclateBase):
def test__str__(self):
self.assertEquals(str(self.nom), "l_testObjectA_LOC")
|
class TestNomenclateRepr(TestNomenclateBase):
def test__str__(self):
pass
| 2 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 1 | 82 | 3 | 0 | 3 | 2 | 1 | 0 | 3 | 2 | 1 | 1 | 4 | 0 | 1 |
4,650 |
AndresMWeber/Nomenclate
|
tests/test_nomenclature.py
|
tests.test_nomenclature.TestNomenclateResetFromConfig
|
class TestNomenclateResetFromConfig(TestNomenclateBase):
def test_refresh(self):
self.assertIsNone(self.nom.reset_from_config())
|
class TestNomenclateResetFromConfig(TestNomenclateBase):
def test_refresh(self):
pass
| 2 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 82 | 3 | 0 | 3 | 2 | 1 | 0 | 3 | 2 | 1 | 1 | 4 | 0 | 1 |
4,651 |
AndresMWeber/Nomenclate
|
tests/test_nomenclature.py
|
tests.test_nomenclature.TestNomenclateState
|
class TestNomenclateState(TestNomenclateBase):
def test_state_clear(self):
previous_state = self.nom.state
self.nom.token_dict.reset()
self.assertEquals(
self.nom.state,
{
"location": "",
"type": "",
"name": "",
"side": "",
"var": "",
"purpose": "",
"decorator": "",
"childtype": "",
},
)
self.nom.state = previous_state
def test_state_valid(self):
self.assertEquals(
{token: token_attr_dict["label"] for token, token_attr_dict in self.nom.state.items()},
{
"childtype": "",
"decorator": "",
"location": "",
"name": "testObject",
"purpose": "",
"side": "left",
"type": "locator",
"var": 0,
},
)
|
class TestNomenclateState(TestNomenclateBase):
def test_state_clear(self):
pass
def test_state_valid(self):
pass
| 3 | 0 | 16 | 0 | 16 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 2 | 0 | 2 | 83 | 33 | 1 | 32 | 4 | 29 | 0 | 8 | 4 | 5 | 1 | 4 | 0 | 2 |
4,652 |
AndresMWeber/Nomenclate
|
tests/test_nomenclature.py
|
tests.test_nomenclature.TestNomenclateSwapFormats
|
class TestNomenclateSwapFormats(TestNomenclateBase):
lee_path = ["naming_formats", "riggers", "lee_wolland"]
raf_path = ["naming_formats", "riggers", "raffaele_fragapane"]
def test_format_switch_same_format(self):
nom = nm.Nom()
nom_b = nm.Nom()
self.assertEquals(nom.tokens, nom_b.tokens)
nom.format = "side_location_nameDecoratorVar_childtype_purpose_type"
self.assertEquals(nom.tokens, nom_b.tokens)
def test_format_switch_same_tokens(self):
nom = nm.Nom()
nom_b = nm.Nom()
self.assertEquals(nom.tokens, nom_b.tokens)
nom.format = "type_purpose_name_childtype_decorator_var_location_side"
self.assertEquals(nom.tokens, nom_b.tokens)
def test_switch_multiple_naming_formats_use_initialize_format_options(self):
self.nom.initialize_format_options(self.lee_path)
self.set_values()
self.assertEquals(self.nom.get(), "LOC_hchy_test_l")
self.nom.initialize_format_options(self.raf_path)
self.set_raf_values()
self.assertEquals(self.nom.get(), "test_TLR_hchy")
self.nom.initialize_format_options(self.test_format)
def test_switch_multiple_naming_formats_set_format(self):
self.nom.format = self.lee_path
self.set_values()
self.assertEquals(self.nom.get(), "LOC_hchy_test_l")
self.nom.format = self.raf_path
self.set_raf_values()
self.assertEquals(self.nom.get(), "test_TLR_hchy")
self.nom.initialize_format_options(self.test_format)
def test_switch_single_format(self):
self.nom.format = self.lee_path
self.set_values()
self.assertEquals(self.nom.get(), "LOC_hchy_test_l")
self.nom.format = self.raf_path
self.set_raf_values()
self.assertEquals(self.nom.get(), "test_TLR_hchy")
def test_switch_single_char_format(self):
self.nom.format = "a"
self.nom.a = "john"
self.assertEquals(self.nom.get(), "john")
def test_switch_double_format(self):
self.nom.format = "af"
self.nom.af = "john"
self.assertEquals(self.nom.get(), "john")
def test_switch_triple_format(self):
self.nom.format = "asd"
self.nom.asd = "john"
self.assertEquals(self.nom.get(), "john")
def test_switch_single_format_nonsense(self):
self.nom.format = "asdf"
self.nom.asdf = "john"
self.assertEquals(self.nom.get(), "john")
def test_switch_single_format_repeat(self):
try:
self.nom.format = "asdf_asdf"
except nm.core.errors.FormatError:
pass
def test_switch_single_format_repeat_different_casing(self):
try:
self.nom.format = "asdf_Asdf"
except nm.core.errors.FormatError:
pass
def set_values(self):
self.nom.name = "test"
self.nom.height = "top"
self.nom.side = "left"
self.nom.depth = "rear"
self.nom.purpose = "hierarchy"
def set_raf_values(self):
self.nom.height = "top"
self.nom.height.case = "upper"
self.nom.depth = "rear"
self.nom.depth.case = "upper"
self.nom.side.case = "upper"
|
class TestNomenclateSwapFormats(TestNomenclateBase):
def test_format_switch_same_format(self):
pass
def test_format_switch_same_tokens(self):
pass
def test_switch_multiple_naming_formats_use_initialize_format_options(self):
pass
def test_switch_multiple_naming_formats_set_format(self):
pass
def test_switch_single_format(self):
pass
def test_switch_single_char_format(self):
pass
def test_switch_double_format(self):
pass
def test_switch_triple_format(self):
pass
def test_switch_single_format_nonsense(self):
pass
def test_switch_single_format_repeat(self):
pass
def test_switch_single_format_repeat_different_casing(self):
pass
def set_values(self):
pass
def set_raf_values(self):
pass
| 14 | 0 | 6 | 0 | 6 | 0 | 1 | 0 | 1 | 1 | 1 | 0 | 13 | 0 | 13 | 94 | 90 | 14 | 76 | 20 | 62 | 0 | 76 | 20 | 62 | 2 | 4 | 1 | 15 |
4,653 |
AndresMWeber/Nomenclate
|
tests/test_nomenclature.py
|
tests.test_nomenclature.TestNomenclateTokens
|
class TestNomenclateTokens(TestNomenclateBase):
def test_non_full(self):
nom = nm.Nom()
self.checkEqual(nom.tokens, list(self.empty_vars))
def test_partial(self):
nom = nm.Nom(self.partial_vars)
self.checkEqual(nom.tokens, list(self.empty_vars))
def test_full(self):
nom = nm.Nom(self.fill_vars)
self.checkEqual(nom.tokens, list(self.empty_vars))
|
class TestNomenclateTokens(TestNomenclateBase):
def test_non_full(self):
pass
def test_partial(self):
pass
def test_full(self):
pass
| 4 | 0 | 3 | 0 | 3 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 3 | 0 | 3 | 84 | 12 | 2 | 10 | 7 | 6 | 0 | 10 | 7 | 6 | 1 | 4 | 0 | 3 |
4,654 |
AndresMWeber/Nomenclate
|
tests/test_nomenclature.py
|
tests.test_nomenclature.TestNomenclateUnset
|
class TestNomenclateUnset(TestNomenclateBase):
def test_non_full(self):
nom = nm.Nom(self.partial_vars)
_ = {}
_.update(self.partial_vars)
_.update(self.missing_partials)
self.assertDictEqual(
{token: token_attr_dict["label"] for token, token_attr_dict in nom.state.items()}, _
)
self.assertDictEqual(nom.empty_tokens, self.missing_partials)
def test_create_empty(self):
nom = nm.Nom()
self.assertDictEqual(nom.state, self.empty_vars)
self.assertDictEqual(nom.empty_tokens, self.empty_vars)
def test_full(self):
nom = nm.Nom(self.fill_vars)
self.assertDictEqual(
{token: token_attr_dict["label"] for token, token_attr_dict in nom.state.items()},
self.fill_vars,
)
self.assertDictEqual(nom.empty_tokens, {})
|
class TestNomenclateUnset(TestNomenclateBase):
def test_non_full(self):
pass
def test_create_empty(self):
pass
def test_full(self):
pass
| 4 | 0 | 7 | 1 | 7 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 3 | 0 | 3 | 84 | 25 | 4 | 21 | 8 | 17 | 0 | 16 | 8 | 12 | 1 | 4 | 0 | 3 |
4,655 |
AndresMWeber/Nomenclate
|
tests/test_processing.py
|
tests.test_processing.TokenMatchAdjustPosition
|
class TokenMatchAdjustPosition(TokenMatchBase):
def test_valid_adjust_alongside(self):
test_re_matches = re.compile(r'(?P<token>st)').finditer('test')
token_match_end = processing.TokenMatch(next(test_re_matches), 'fl', group_name='token')
orig_start = token_match_end.start
token_match_end.adjust_position(self.token_match_start, adjust_by_sub_delta=False)
self.assertEquals(token_match_end.start,
orig_start - self.token_match_start.span)
def test_valid_adjust_end(self):
test_re_matches = re.compile(r'(?P<token>er)').finditer('tester')
token_match_end = processing.TokenMatch(next(test_re_matches), 'fl', group_name='token')
orig_start = token_match_end.start
token_match_end.adjust_position(self.token_match_start, adjust_by_sub_delta=False)
self.assertEquals(token_match_end.start,
orig_start - self.token_match_start.span)
def test_valid_adjust_double(self):
test_re_matches = re.compile(r'(?P<token>te)').finditer('lesterte')
token_match_end = processing.TokenMatch(next(test_re_matches), 'fl', group_name='token')
orig_start = token_match_end.start
token_match_end.adjust_position(self.token_match_start, adjust_by_sub_delta=False)
self.assertEquals(token_match_end.start,
orig_start - self.token_match_start.span)
def test_valid_adjust_no_move(self):
self.assertRaises(IndexError, self.token_match_start.adjust_position, self.token_match_end)
def test_invalid_adjust(self):
self.assertRaises(exceptions.OverlapError, self.token_match_start.adjust_position, self.token_match_mid)
def test_invalid_type(self):
self.assertRaises(IOError, self.token_match_start.adjust_position, 5)
|
class TokenMatchAdjustPosition(TokenMatchBase):
def test_valid_adjust_alongside(self):
pass
def test_valid_adjust_end(self):
pass
def test_valid_adjust_double(self):
pass
def test_valid_adjust_no_move(self):
pass
def test_invalid_adjust(self):
pass
def test_invalid_type(self):
pass
| 7 | 0 | 5 | 0 | 5 | 0 | 1 | 0 | 1 | 3 | 2 | 0 | 6 | 1 | 6 | 83 | 33 | 5 | 28 | 17 | 21 | 0 | 25 | 16 | 18 | 1 | 4 | 0 | 6 |
4,656 |
AndresMWeber/Nomenclate
|
tests/test_processing.py
|
tests.test_processing.TokenMatchBase
|
class TokenMatchBase(TestBase):
def setUp(self):
super(TokenMatchBase, self).setUp()
self.regex_custom_group_match = next(re.compile(r'(?P<look>test)').finditer('test'))
test_re_matches = re.compile(r'(?P<token>te)').finditer('test')
self.token_match_start = processing.TokenMatch(next(test_re_matches), 'mx', group_name='token')
test_re_matches = re.compile(r'(?P<token>es)').finditer('test')
self.token_match_mid = processing.TokenMatch(next(test_re_matches), 'lz', group_name='token')
test_re_matches = re.compile(r'(?P<token>st)').finditer('test')
self.token_match_end = processing.TokenMatch(next(test_re_matches), 'fr', group_name='token')
self.fixtures.extend([self.token_match_start,
self.token_match_mid,
self.token_match_end])
|
class TokenMatchBase(TestBase):
def setUp(self):
pass
| 2 | 0 | 16 | 4 | 12 | 0 | 1 | 0 | 1 | 2 | 1 | 6 | 1 | 4 | 1 | 77 | 17 | 4 | 13 | 7 | 11 | 0 | 11 | 7 | 9 | 1 | 3 | 0 | 1 |
4,657 |
AndresMWeber/Nomenclate
|
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/AndresMWeber_Nomenclate/tests/test_configurator.py
|
tests.test_configurator.MockConfig
|
class MockConfig(object):
test_data = (
"overall_config:\n"
" version_padding: 3\n"
"naming_formats:\n"
" node:\n"
" default: side_location_nameDecoratorVar_childtype_purpose_type\n"
" format_archive: side_name_space_purpose_decorator_childtype_type\n"
" format_lee: type_childtype_space_purpose_name_side\n"
" texturing:\n"
" shader: side_name_type\n"
"options:\n"
" discipline:\n"
" animation: AN ANI ANIM ANIMN\n"
" lighting: LT LGT LGHT LIGHT\n"
" rigging: RG RIG RIGG RIGNG\n"
" matchmove: MM MMV MMOV MMOVE\n"
" compositing: CM CMP COMP COMPG\n"
" modeling: MD MOD MODL MODEL\n"
" side:\n"
" - left\n"
" - right\n"
" - center\n"
)
def __init__(self):
self.build_test_config()
@mock.patch("nomenclate.core.file_utils.os.path.getsize")
@mock.patch("nomenclate.core.file_utils.os.path.isfile")
@mock.patch("nomenclate.core.configurator.open", mock.mock_open(read_data=test_data))
@mock.patch("nomenclate.core.file_utils.open", mock.mock_open(read_data=test_data))
def build_test_config(self, mock_isfile, mock_getsize):
mock_isfile.return_value = True
mock_getsize.return_value = 700
self.parser = config.ConfigParse()
self.fakefs = fake_filesystem.FakeFilesystem()
self.fake_file_path = "/var/env/foobar.yml"
self.fake_file = self.fakefs.create_file(
self.fake_file_path, contents=self.test_data)
fake_filesystem.FakeFile("foobar.yml", filesystem=self.fakefs)
self.parser.set_from_file(self.fake_file_path)
# test values
self.format_title = "naming_formats"
self.format_subcategory = "node"
self.default_format = "default"
self.format_test = [self.format_title,
self.format_subcategory, self.default_format]
self.discipline_path = ["options", "discipline"]
self.discipline_subsets = [
"animation",
"modeling",
"rigging",
"compositing",
"matchmove",
"lighting",
]
self.discipline_data = {
"animation": "AN ANI ANIM ANIMN",
"compositing": "CM CMP COMP COMPG",
"lighting": "LT LGT LGHT LIGHT",
"matchmove": "MM MMV MMOV MMOVE",
"modeling": "MD MOD MODL MODEL",
"rigging": "RG RIG RIGG RIGNG",
}
|
class MockConfig(object):
def __init__(self):
pass
@mock.patch("nomenclate.core.file_utils.os.path.getsize")
@mock.patch("nomenclate.core.file_utils.os.path.isfile")
@mock.patch("nomenclate.core.configurator.open", mock.mock_open(read_data=test_data))
@mock.patch("nomenclate.core.file_utils.open", mock.mock_open(read_data=test_data))
def build_test_config(self, mock_isfile, mock_getsize):
pass
| 7 | 0 | 18 | 1 | 16 | 1 | 1 | 0.02 | 1 | 1 | 1 | 0 | 2 | 11 | 2 | 2 | 65 | 4 | 60 | 16 | 53 | 1 | 20 | 15 | 17 | 1 | 1 | 0 | 2 |
4,658 |
AndresMWeber/Nomenclate
|
tests/test_tokens.py
|
tests.test_tokens.TestTokenAttrGet
|
class TestTokenAttrGet(TestTokenAttrBase):
def test_get(self):
self.assertEquals(self.token_attr.label, 'test_label')
def test_get_empty(self):
self.assertEquals(tokens.TokenAttr().label, '')
|
class TestTokenAttrGet(TestTokenAttrBase):
def test_get(self):
pass
def test_get_empty(self):
pass
| 3 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 1 | 1 | 0 | 2 | 0 | 2 | 79 | 6 | 1 | 5 | 3 | 2 | 0 | 5 | 3 | 2 | 1 | 4 | 0 | 2 |
4,659 |
AndresMWeber/Nomenclate
|
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/AndresMWeber_Nomenclate/tests/test_configurator.py
|
tests.test_configurator.TestValidateConfigFile
|
class TestValidateConfigFile(TestConfiguratorBase):
@mock.patch("nomenclate.core.file_utils.os.path.isfile")
def test_valid_file_no_file(self, mock_isfile):
mock_isfile.return_value = False
self.assertRaises(exceptions.SourceError,
self.cfg.validate_config_file, "/mock/config.yml")
|
class TestValidateConfigFile(TestConfiguratorBase):
@mock.patch("nomenclate.core.file_utils.os.path.isfile")
def test_valid_file_no_file(self, mock_isfile):
pass
| 3 | 0 | 3 | 0 | 3 | 0 | 1 | 0 | 1 | 1 | 1 | 0 | 1 | 0 | 1 | 78 | 5 | 0 | 5 | 3 | 2 | 0 | 4 | 2 | 2 | 1 | 4 | 0 | 1 |
4,660 |
AndresMWeber/Nomenclate
|
tests/test_configurator.py
|
tests.test_configurator.TestGetHandler
|
class TestGetHandler(TestConfiguratorBase):
def test_existing(self):
config.ConfigEntryFormatter.get_handler(str, list)
def test_not_existing(self):
self.assertRaises(IndexError, config.ConfigEntryFormatter.get_handler, int, str)
|
class TestGetHandler(TestConfiguratorBase):
def test_existing(self):
pass
def test_not_existing(self):
pass
| 3 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 5 | 1 | 0 | 2 | 0 | 2 | 79 | 6 | 1 | 5 | 3 | 2 | 0 | 5 | 3 | 2 | 1 | 4 | 0 | 2 |
4,661 |
AndresMWeber/Nomenclate
|
tests/test_rendering.py
|
tests.test_rendering.TestNomenclativeProcessMatches
|
class TestNomenclativeProcessMatches(TestNomenclativeBase):
def test_valid(self):
test_dict = self.token_test_dict.copy()
rendering.InputRenderer._prepend_token_match_objects(
test_dict, self.nomenclative_valid.raw_formatted_string
)
for token, value in test_dict.items():
self.nomenclative_valid.add_match(*value)
self.assertEquals(
self.nomenclative_valid.process_matches(), "left_rear_testA_joints_offset_group"
)
def test_valid_short(self):
test_dict = self.token_test_dict.copy()
rendering.InputRenderer._prepend_token_match_objects(
test_dict, self.nomenclative_valid_short.raw_formatted_string
)
for token, value in test_dict.items():
if isinstance(value, str):
pass
else:
self.nomenclative_valid_short.add_match(*value)
self.assertEquals(self.nomenclative_valid_short.process_matches(), "left_test_group")
def test_invalid(self):
self.assertEquals(
self.nomenclative_invalid.process_matches(),
self.nomenclative_invalid.raw_formatted_string,
)
|
class TestNomenclativeProcessMatches(TestNomenclativeBase):
def test_valid(self):
pass
def test_valid_short(self):
pass
def test_invalid(self):
pass
| 4 | 0 | 9 | 0 | 9 | 0 | 2 | 0 | 1 | 2 | 1 | 0 | 3 | 0 | 3 | 80 | 29 | 2 | 27 | 8 | 23 | 0 | 17 | 8 | 13 | 3 | 4 | 2 | 6 |
4,662 |
AndresMWeber/Nomenclate
|
tests/test_rendering.py
|
tests.test_rendering.TestNomenclativeBase
|
class TestNomenclativeBase(TestBase):
def setUp(self):
super(TestNomenclativeBase, self).setUp()
self.nomenclative_valid = processing.Nomenclative(
"side_location_nameDecoratorVar_childtype_purpose_type"
)
self.nomenclative_valid_short = processing.Nomenclative("side_name_type")
self.nomenclative_invalid = processing.Nomenclative("test_labelside")
test_values = tokens.TokenAttrList(
["side", "location", "name", "decorator", "var", "childtype", "purpose", "type"]
)
test_values["side"].set("left")
test_values["location"].set("rear")
test_values["name"].set("test")
test_values["decorator"].set("")
test_values["var"].set("A")
test_values["childtype"].set("joints")
test_values["purpose"].set("offset")
test_values["type"].set("group")
self.token_test_dict = test_values.to_json()
self.fixtures.append(
[
self.nomenclative_valid,
self.nomenclative_valid_short,
self.nomenclative_invalid,
self.token_test_dict,
]
)
|
class TestNomenclativeBase(TestBase):
def setUp(self):
pass
| 2 | 0 | 29 | 2 | 27 | 0 | 1 | 0 | 1 | 3 | 2 | 2 | 1 | 4 | 1 | 77 | 30 | 2 | 28 | 7 | 26 | 0 | 17 | 7 | 15 | 1 | 3 | 0 | 1 |
4,663 |
AndresMWeber/Nomenclate
|
tests/test_rendering.py
|
tests.test_rendering.TestNomenclativeAddMatch
|
class TestNomenclativeAddMatch(TestNomenclativeBase):
def test_valid(self):
test_dict = self.token_test_dict.copy()
rendering.InputRenderer._prepend_token_match_objects(
test_dict, self.nomenclative_valid.raw_formatted_string
)
for token, value in test_dict.items():
self.nomenclative_valid.add_match(*value)
self.assertEquals(
self.nomenclative_valid.process_matches(), "left_rear_testA_joints_offset_group"
)
def test_short_valid(self):
test_dict = self.token_test_dict.copy()
rendering.InputRenderer._prepend_token_match_objects(
test_dict, self.nomenclative_valid_short.raw_formatted_string
)
for token, value in test_dict.items():
if not isinstance(value, str):
self.nomenclative_valid_short.add_match(*value)
self.assertEquals(self.nomenclative_valid_short.process_matches(), "left_test_group")
def test_overlap(self):
test_dict = tokens.TokenAttrList(["name", "side"])
test_dict["name"].set("left")
test_dict["side"].set("left")
test_dict = test_dict.to_json()
test_overlap = tokens.TokenAttrList(["side_name"])
test_overlap["side_name"].set("overlapped")
test_overlap = test_overlap.to_json()
rendering.InputRenderer._prepend_token_match_objects(
test_dict, self.nomenclative_valid_short.raw_formatted_string
)
rendering.InputRenderer._prepend_token_match_objects(
test_overlap, self.nomenclative_valid_short.raw_formatted_string
)
for value in test_dict.values():
if not isinstance(value, str):
self.nomenclative_valid_short.add_match(*value)
for token, value in test_overlap.items():
if not isinstance(value, str):
self.assertRaises(
exceptions.OverlapError, self.nomenclative_valid_short.add_match, *value
)
def test_non_regex_match_object(self):
self.assertEquals(
self.nomenclative_invalid.process_matches(),
self.nomenclative_invalid.raw_formatted_string,
)
|
class TestNomenclativeAddMatch(TestNomenclativeBase):
def test_valid(self):
pass
def test_short_valid(self):
pass
def test_overlap(self):
pass
def test_non_regex_match_object(self):
pass
| 5 | 0 | 13 | 1 | 12 | 0 | 3 | 0 | 1 | 4 | 3 | 0 | 4 | 0 | 4 | 81 | 54 | 7 | 47 | 13 | 42 | 0 | 32 | 13 | 27 | 5 | 4 | 2 | 11 |
4,664 |
AndresMWeber/Nomenclate
|
tests/test_tokens_handler.py
|
tests.test_tokens_handler.TestEq
|
class TestEq(TestTokenAttrBase):
def test_not_equal(self):
other_token_dict_handler = tokens.TokenAttrList(nm.Nom().token_dict.to_json())
other_token_dict_handler.merge_json({'name': 'bob'})
self.assertFalse(self.token_attr_dict_handler == other_token_dict_handler)
def test_equal(self):
self.assertTrue(self.token_attr_dict_handler == tokens.TokenAttrList(nm.Nom().token_dict.to_json()))
def test_not_instance(self):
self.assertFalse(self.token_attr_dict_handler == 5)
|
class TestEq(TestTokenAttrBase):
def test_not_equal(self):
pass
def test_equal(self):
pass
def test_not_instance(self):
pass
| 4 | 0 | 3 | 0 | 3 | 0 | 1 | 0 | 1 | 1 | 1 | 0 | 3 | 0 | 3 | 80 | 11 | 2 | 9 | 5 | 5 | 0 | 9 | 5 | 5 | 1 | 4 | 0 | 3 |
4,665 |
AndresMWeber/Nomenclate
|
tests/test_renderers.py
|
tests.test_renderers.TestInputRendererRenderUniqueTokens
|
class TestInputRendererRenderUniqueTokens(TestInputRendererBase):
def test_all_replaced(self):
test_values = tokens.TokenAttrList(['var', 'type', 'side', 'version'])
test_values['var'].set(0)
test_values['type'].set('locator')
test_values['side'].set('left')
test_values['version'].set(5)
test_values = test_values.to_json()
self.nom.merge_dict(test_values)
self.nom.version.padding = 3
self.nom.version.prefix = 'v'
self.ir.render_unique_tokens(self.nom, test_values)
self.assertEqual(1, 1)
# self.assertEquals({token: test_values[token]['label'] for token in list(test_values)},
# {'var': 'a', 'type': 'LOC', 'side': 'l', 'version': 'v5'})
def test_some_replaced(self):
test_values = tokens.TokenAttrList(['var', 'type', 'side', 'version'])
test_values['var'].set(0)
test_values['type'].set('locator')
test_values['side'].set('left')
test_values['version'].set(5)
test_values = test_values.to_json()
self.nom.merge_dict(test_values)
self.nom.version_padding = 3
self.nom.version.prefix = 'v'
self.ir.render_unique_tokens(self.nom, test_values)
self.assertEquals(test_values,
{'var': 'A', 'type': 'LOC', 'side': 'l', 'version': 'v005'})
def test_default_renderer(self):
test_values = tokens.TokenAttrList(['var',
'type',
'side',
'version',
'john',
'purpose'])
test_values['var'].set(0)
test_values['type'].set('locator')
test_values['side'].set('left')
test_values['version'].set(5)
test_values['john'].set('six')
test_values['purpose'].set('hierarchy')
test_values = test_values.to_json()
self.nom.merge_dict(test_values)
self.nom.version.padding = 3
self.nom.version.prefix = 'v'
self.nom.format = self.nom.format + '_john'
self.ir.render_unique_tokens(self.nom, test_values)
self.assertEquals(test_values,
{'var': 'A',
'type': 'LOC',
'side': 'l',
'version': 'v005',
'john': 'six',
'purpose': 'hrc'})
def test_empty(self):
test_values = {}
self.ir.render_unique_tokens(self.nom, test_values)
self.assertEquals(test_values,
{})
def test_none_replaced(self):
test_values = tokens.TokenAttrList(['name', 'blah', 'not_me', 'la'])
test_values['name'].set('test')
test_values['blah'].set('blah')
test_values['not_me'].set('not_me')
test_values['la'].set(5)
test_values = test_values.to_json()
self.nom.merge_dict(test_values)
test_values_unchanged = test_values.copy()
test_values_unchanged['la'] = '5'
self.ir.render_unique_tokens(self.nom, test_values)
self.assertEquals(test_values, test_values_unchanged)
|
class TestInputRendererRenderUniqueTokens(TestInputRendererBase):
def test_all_replaced(self):
pass
def test_some_replaced(self):
pass
def test_default_renderer(self):
pass
def test_empty(self):
pass
def test_none_replaced(self):
pass
| 6 | 0 | 15 | 1 | 14 | 0 | 1 | 0.03 | 1 | 1 | 1 | 0 | 5 | 0 | 5 | 84 | 81 | 10 | 69 | 12 | 63 | 2 | 56 | 12 | 50 | 1 | 5 | 0 | 5 |
4,666 |
AndresMWeber/Nomenclate
|
tests/test_renderers.py
|
tests.test_renderers.TestInputRendererProcessTokenAugmentations
|
class TestInputRendererProcessTokenAugmentations(TestInputRendererBase):
def test_from_nomenclate_upper(self):
self.set_values()
self.nom.side.case = 'upper'
self.assertEquals(self.nom.get(), 'L_testObjectA_LOC')
def test_from_nomenclate_lower(self):
self.set_values()
self.nom.side.case = 'lower'
self.assertEquals(self.nom.get(), 'l_testObjectA_LOC')
def test_from_upper(self):
token_attr = tokens.TokenAttr('name', 'test')
token_attr.case = 'upper'
self.assertEquals(renderers.RenderBase.process_token_augmentations('test', token_attr),
'TEST')
def test_from_lower(self):
token_attr = tokens.TokenAttr('name', 'test')
token_attr.case = 'lower'
self.assertEquals(renderers.RenderBase.process_token_augmentations('Test', token_attr),
'test')
def test_from_none(self):
token_attr = tokens.TokenAttr('name', 'test')
self.assertEquals(renderers.RenderBase.process_token_augmentations('Test', token_attr),
'Test')
def test_from_prefix(self):
token_attr = tokens.TokenAttr(token='name', label='test')
token_attr.prefix = 'v'
self.assertEquals(renderers.RenderBase.process_token_augmentations('Test', token_attr),
'vTest')
def test_from_suffix(self):
token_attr = tokens.TokenAttr('name', 'test')
token_attr.suffix = '_r'
self.assertEquals(renderers.RenderBase.process_token_augmentations('test', token_attr),
'test_r')
|
class TestInputRendererProcessTokenAugmentations(TestInputRendererBase):
def test_from_nomenclate_upper(self):
pass
def test_from_nomenclate_lower(self):
pass
def test_from_upper(self):
pass
def test_from_lower(self):
pass
def test_from_none(self):
pass
def test_from_prefix(self):
pass
def test_from_suffix(self):
pass
| 8 | 0 | 5 | 0 | 5 | 0 | 1 | 0 | 1 | 2 | 2 | 0 | 7 | 0 | 7 | 86 | 39 | 6 | 33 | 13 | 25 | 0 | 28 | 13 | 20 | 1 | 5 | 0 | 7 |
4,667 |
AndresMWeber/Nomenclate
|
tests/test_renderers.py
|
tests.test_renderers.TestInputRendererGetVariationId
|
class TestInputRendererGetVariationId(TestInputRendererBase):
def test_get_variation_id_normal(self):
self.assertEquals(renderers.RenderVar._get_variation_id(0), 'a')
def test_get_variation_id_negative(self):
self.assertEquals(renderers.RenderVar._get_variation_id(-4), '')
def test_get_variation_id_negative_one(self):
self.assertEquals(renderers.RenderVar._get_variation_id(-1), '')
def test_get_variation_id_double_upper(self):
self.assertEquals(renderers.RenderVar._get_variation_id(1046, capital=True), 'ANG')
def test_get_variation_id_double_lower(self):
self.assertEquals(renderers.RenderVar._get_variation_id(1046, capital=False), 'ang')
|
class TestInputRendererGetVariationId(TestInputRendererBase):
def test_get_variation_id_normal(self):
pass
def test_get_variation_id_negative(self):
pass
def test_get_variation_id_negative_one(self):
pass
def test_get_variation_id_double_upper(self):
pass
def test_get_variation_id_double_lower(self):
pass
| 6 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 1 | 1 | 0 | 5 | 0 | 5 | 84 | 15 | 4 | 11 | 6 | 5 | 0 | 11 | 6 | 5 | 1 | 5 | 0 | 5 |
4,668 |
AndresMWeber/Nomenclate
|
tests/test_renderers.py
|
tests.test_renderers.TestInputRendererGetAlphanumericIndex
|
class TestInputRendererGetAlphanumericIndex(TestInputRendererBase):
def test_get__get_alphanumeric_index_integer(self):
self.assertEquals(self.ir._get_alphanumeric_index(0),
[0, 'int'])
def test_get__get_alphanumeric_index_char_start(self):
self.assertEquals(self.ir._get_alphanumeric_index('a'),
[0, 'char_lo'])
def test_get__get_alphanumeric_index_char_end(self):
self.assertEquals(self.ir._get_alphanumeric_index('z'),
[25, 'char_lo'])
def test_get__get_alphanumeric_index_char_upper(self):
self.assertEquals(self.ir._get_alphanumeric_index('B'),
[1, 'char_hi'])
def test_get__get_alphanumeric_index_error(self):
self.assertRaises(IOError, self.ir._get_alphanumeric_index, 'asdf')
|
class TestInputRendererGetAlphanumericIndex(TestInputRendererBase):
def test_get__get_alphanumeric_index_integer(self):
pass
def test_get__get_alphanumeric_index_char_start(self):
pass
def test_get__get_alphanumeric_index_char_end(self):
pass
def test_get__get_alphanumeric_index_char_upper(self):
pass
def test_get__get_alphanumeric_index_error(self):
pass
| 6 | 0 | 3 | 0 | 3 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 5 | 0 | 5 | 84 | 19 | 4 | 15 | 6 | 9 | 0 | 11 | 6 | 5 | 1 | 5 | 0 | 5 |
4,669 |
AndresMWeber/Nomenclate
|
tests/test_renderers.py
|
tests.test_renderers.TestInputRendererCleanupFormattingString
|
class TestInputRendererCleanupFormattingString(TestInputRendererBase):
def test_cleanup_format(self):
self.assertEquals(self.ir.cleanup_formatted_string('test_name _messed __ up LOC'),
'test_name_messed_upLOC')
|
class TestInputRendererCleanupFormattingString(TestInputRendererBase):
def test_cleanup_format(self):
pass
| 2 | 0 | 3 | 0 | 3 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 80 | 4 | 0 | 4 | 2 | 2 | 0 | 3 | 2 | 1 | 1 | 5 | 0 | 1 |
4,670 |
AndresMWeber/Nomenclate
|
tests/test_renderers.py
|
tests.test_renderers.TestInputRendererBase
|
class TestInputRendererBase(TestRenderersBase):
def setUp(self):
super(TestInputRendererBase, self).setUp()
self.ir = rendering.InputRenderer
self.nom = nom.Nomenclate()
self.fixtures.append([self.ir, self.nom])
def set_values(self):
self.nom.side.set('left')
self.nom.name.set('testObject')
self.nom.type.set('locator')
self.nom.var.set(0)
self.nom.var.case = 'upper'
|
class TestInputRendererBase(TestRenderersBase):
def setUp(self):
pass
def set_values(self):
pass
| 3 | 0 | 6 | 0 | 6 | 0 | 1 | 0 | 1 | 2 | 1 | 5 | 2 | 2 | 2 | 79 | 13 | 1 | 12 | 5 | 9 | 0 | 12 | 5 | 9 | 1 | 4 | 0 | 2 |
4,671 |
AndresMWeber/Nomenclate
|
tests/test_processing.py
|
tests.test_processing.TokenMatchLT
|
class TokenMatchLT(TokenMatchBase):
def test_equal(self):
self.assertFalse(self.token_match_start <
processing.TokenMatch(next(re.compile(r'(?P<token>te)').finditer('test')), 'mx'))
def test_inequal(self):
self.assertFalse(self.token_match_start < self.token_match_mid)
def test_invalid_type(self):
self.assertRaises(NotImplementedError, self.token_match_start.__lt__, 5)
|
class TokenMatchLT(TokenMatchBase):
def test_equal(self):
pass
def test_inequal(self):
pass
def test_invalid_type(self):
pass
| 4 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 2 | 1 | 0 | 3 | 0 | 3 | 80 | 10 | 2 | 8 | 4 | 4 | 0 | 7 | 4 | 3 | 1 | 4 | 0 | 3 |
4,672 |
AndresMWeber/Nomenclate
|
tests/test_processing.py
|
tests.test_processing.TokenMatchInit
|
class TokenMatchInit(TokenMatchBase):
def test_missing_group(self):
self.assertRaises(IndexError, processing.TokenMatch, self.regex_custom_group_match, 'marg')
def test_group_custom(self):
processing.TokenMatch(self.regex_custom_group_match, 'marg', group_name='look')
|
class TokenMatchInit(TokenMatchBase):
def test_missing_group(self):
pass
def test_group_custom(self):
pass
| 3 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 2 | 1 | 0 | 2 | 1 | 2 | 79 | 6 | 1 | 5 | 4 | 2 | 0 | 5 | 3 | 2 | 1 | 4 | 0 | 2 |
4,673 |
AndresMWeber/Nomenclate
|
tests/test_processing.py
|
tests.test_processing.TokenMatchGT
|
class TokenMatchGT(TokenMatchBase):
def test_equal(self):
self.assertFalse(self.token_match_start >
processing.TokenMatch(next(re.compile(r'(?P<token>te)').finditer('test')), 'mx'))
def test_inequal(self):
self.assertFalse(self.token_match_mid > self.token_match_start)
def test_invalid_type(self):
self.assertRaises(NotImplementedError, self.token_match_start.__gt__, 5)
|
class TokenMatchGT(TokenMatchBase):
def test_equal(self):
pass
def test_inequal(self):
pass
def test_invalid_type(self):
pass
| 4 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 2 | 1 | 0 | 3 | 0 | 3 | 80 | 10 | 2 | 8 | 4 | 4 | 0 | 7 | 4 | 3 | 1 | 4 | 0 | 3 |
4,674 |
AndresMWeber/Nomenclate
|
tests/test_acceptance_workflow.py
|
tests.test_acceptance_workflow.TestAcceptanceParsingExisting
|
class TestAcceptanceParsingExisting(TestBase):
def test_normal_maya_node(self):
pass
def test_working_file(self):
pass
def test_asset_file(self):
pass
def test_movie_file(self):
pass
|
class TestAcceptanceParsingExisting(TestBase):
def test_normal_maya_node(self):
pass
def test_working_file(self):
pass
def test_asset_file(self):
pass
def test_movie_file(self):
pass
| 5 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 4 | 0 | 4 | 80 | 12 | 3 | 9 | 5 | 4 | 0 | 9 | 5 | 4 | 1 | 3 | 0 | 4 |
4,675 |
AndresMWeber/Nomenclate
|
tests/test_acceptance_workflow.py
|
tests.test_acceptance_workflow.TestCreation
|
class TestCreation(TestBase):
def test_initialize_with_dict_only_one(self):
n = nom.Nomenclate({'name': 'test'})
n.new = 'default'
self.assertEquals(n.get(), 'test')
def test_initialize_with_dict_only_end_and_start(self):
n = nom.Nomenclate({'side': 'left', 'type': 'locator'})
n.new = 'default'
self.assertEquals(n.get(), 'l_LOC')
def test_initialize_with_dict_incomplete_and_swap_format_from_new_string(self):
n = nom.Nomenclate({'name': 'test', 'type': 'locator', 'var': 0, 'side': 'left'})
n.var.case = 'upper'
self.assertEquals(n.get(), 'l_testA_LOC')
n.format = 'new_nameDecoratorVar_childtype_purpose_type_side'
n.new = 'default'
self.assertEquals(n.get(), 'default_testA_LOC_l')
self.fixtures.append(n)
def test_initialize_with_dict_incomplete_and_swap_format_from_path(self):
n = nom.Nomenclate({'name': 'test', 'type': 'locator', 'var': 0, 'side': 'left'})
n.var.case = 'upper'
self.assertEquals(n.get(), 'l_testA_LOC')
n.format = ['naming_formats', 'node', 'format_archive']
self.assertEquals(n.get(), 'l_test_LOC')
self.fixtures.append(n)
def test_initialize_with_dict_complete(self):
n = nom.Nomenclate({'name': 'test',
'decorator': 'J',
'childtype': 'joint',
'purpose': 'offset',
'var': 0,
'side': 'left',
'type': 'locator',
'location': 'rear'})
n.var.case = 'upper'
self.assertEquals(n.get(), 'l_rr_testJA_joint_offset_LOC')
def test_initialize_with_attributes_incomplete(self):
n = nom.Nomenclate({'name': 'test', 'type': 'locator', 'var': 0, 'side': 'left', })
n.var.case = 'upper'
self.assertEquals(n.get(), 'l_testA_LOC')
self.fixtures.append(n)
def test_initialize_with_attributes_complete(self):
n = nom.Nomenclate()
n.name = 'test'
n.decorator = 'J'
n.childtype = 'joint'
n.purpose = 'offset'
n.var = 0
n.side = 'left'
n.type = 'locator'
n.location = 'rear'
n.var.case = 'upper'
self.fixtures.append(n)
self.assertEquals(n.get(), 'l_rr_testJA_joint_offset_LOC')
def test_initialize_from_nomenclate_object(self):
n_initial = nom.Nomenclate({'name': 'test', 'type': 'locator', 'var': 0, 'side': 'left', })
n_initial.var.case = 'upper'
n_secondary = nom.Nomenclate(n_initial)
n_secondary.var.case = 'upper'
self.assertEquals(n_secondary.get(), 'l_testA_LOC')
self.fixtures.extend([n_secondary, n_initial])
def test_initialize_from_nomenclate_state(self):
n_initial = nom.Nomenclate({'name': 'test', 'type': 'locator', 'var': 0, 'side': 'left', })
n_initial.var.case = 'upper'
state_dict = n_initial.state
n_secondary = nom.Nomenclate(state_dict)
n_secondary.var.case = 'upper'
self.assertEquals(n_secondary.get(), 'l_testA_LOC')
self.fixtures.extend([n_secondary, n_initial, state_dict])
def test_initialize_from_nomenclate_object_and_kwargs(self):
n_initial = nom.Nomenclate({'name': 'test', 'type': 'locator', 'var': 0, 'side': 'left', })
n_initial.var.case = 'upper'
n_secondary = nom.Nomenclate(n_initial, **{'name': 'blah', 'location': 'rear'})
n_secondary.var.case = 'upper'
n_initial.type.len = 3
n_secondary.type.len = 3
self.assertEquals(n_secondary.get(), 'l_rr_blahA_LOC')
self.fixtures.extend([n_secondary, n_initial])
def test_initialize_from_nomenclate_and_kwargs(self):
n_initial = nom.Nomenclate({'name': 'test', 'type': 'locator', 'var': 0, 'side': 'left', })
n_initial.var.case = 'upper'
n_secondary = nom.Nomenclate(n_initial, name='blah', location='rear')
n_secondary.var.case = 'upper'
self.assertEquals(n_secondary.get(), 'l_rr_blahA_LOC')
self.fixtures.extend([n_secondary, n_initial])
def test_initialize_and_switch_format_then_set_properties(self):
n = nom.Nomenclate({'name': 'test', 'type': 'locator', 'var': 0, 'side': 'left'})
n.var.case = 'upper'
n.initialize_format_options('new_nameDecoratorVar_childtype_purpose_type_side')
n.name = 'default'
self.assertEquals(n.get(), 'defaultA_LOC_l')
def test_initialize_with_nomenclate_and_get_kwargs(self):
n_initial = nom.Nomenclate({'name': 'test', 'type': 'locator', 'var': 0, 'side': 'left'})
n_initial.var.case = 'upper'
n_secondary = nom.Nomenclate(n_initial)
n_secondary.var.case = 'upper'
self.assertEquals(n_secondary.get(name='blah', location='rear'), 'l_rr_blahA_LOC')
self.fixtures.extend([n_secondary, n_initial])
|
class TestCreation(TestBase):
def test_initialize_with_dict_only_one(self):
pass
def test_initialize_with_dict_only_end_and_start(self):
pass
def test_initialize_with_dict_incomplete_and_swap_format_from_new_string(self):
pass
def test_initialize_with_dict_incomplete_and_swap_format_from_path(self):
pass
def test_initialize_with_dict_complete(self):
pass
def test_initialize_with_attributes_incomplete(self):
pass
def test_initialize_with_attributes_complete(self):
pass
def test_initialize_from_nomenclate_object(self):
pass
def test_initialize_from_nomenclate_state(self):
pass
def test_initialize_from_nomenclate_object_and_kwargs(self):
pass
def test_initialize_from_nomenclate_and_kwargs(self):
pass
def test_initialize_and_switch_format_then_set_properties(self):
pass
def test_initialize_with_nomenclate_and_get_kwargs(self):
pass
| 14 | 0 | 7 | 0 | 7 | 0 | 1 | 0 | 1 | 1 | 1 | 0 | 13 | 0 | 13 | 89 | 109 | 12 | 97 | 33 | 83 | 0 | 90 | 33 | 76 | 1 | 3 | 0 | 13 |
4,676 |
AndresMWeber/Nomenclate
|
tests/test_configurator.py
|
tests.test_configurator.TestConfiguratorBase
|
class TestConfiguratorBase(TestBase):
def setUp(self):
super(TestConfiguratorBase, self).setUp()
self.maxDiff = 1000
self.mock_config = MockConfig()
self.cfg = self.mock_config.parser
self.fixtures = [self.cfg, self.mock_config]
# test values
self.format_title = self.mock_config.format_title
self.format_subcategory = self.mock_config.format_subcategory
self.default_format = self.mock_config.default_format
self.format_test = self.mock_config.format_test
self.discipline_path = self.mock_config.discipline_path
self.discipline_subsets = self.mock_config.discipline_subsets
self.discipline_data = self.mock_config.discipline_data
|
class TestConfiguratorBase(TestBase):
def setUp(self):
pass
| 2 | 0 | 15 | 1 | 13 | 1 | 1 | 0.07 | 1 | 2 | 1 | 5 | 1 | 11 | 1 | 77 | 16 | 1 | 14 | 13 | 12 | 1 | 14 | 13 | 12 | 1 | 3 | 0 | 1 |
4,677 |
AndresMWeber/Nomenclate
|
tests/test_configurator.py
|
tests.test_configurator.TestFormatters
|
class TestFormatters(TestConfiguratorBase):
def test_base_formatter_init(self):
self.assertRaises(NotImplementedError, config.BaseFormatter.format_result, "")
def test_dict_to_ordered_dict(self):
self.assertEquals(config.DictToOrderedDict.format_result({}), OrderedDict())
def test_none_to_dict(self):
self.assertEquals(config.NoneToDict.format_result(None), {})
def test_int_to_list(self):
self.assertEquals(config.IntToList.format_result(1), [1])
def test_list_to_str(self):
self.assertEquals(config.ListToString.format_result(["john", "kate"]), "john kate")
|
class TestFormatters(TestConfiguratorBase):
def test_base_formatter_init(self):
pass
def test_dict_to_ordered_dict(self):
pass
def test_none_to_dict(self):
pass
def test_int_to_list(self):
pass
def test_list_to_str(self):
pass
| 6 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 7 | 5 | 0 | 5 | 0 | 5 | 82 | 15 | 4 | 11 | 6 | 5 | 0 | 11 | 6 | 5 | 1 | 4 | 0 | 5 |
4,678 |
AndresMWeber/Nomenclate
|
tests/test_configurator.py
|
tests.test_configurator.TestGet
|
class TestGet(TestConfiguratorBase):
def test_get_default_as_string(self):
self.assertEquals(
self.cfg.get([self.format_title, "node", self.default_format], return_type=str),
"side_location_nameDecoratorVar_childtype_purpose_type",
)
def test_get_options(self):
self.assertTrue(
self.checkEqual(
self.cfg.get([self.format_title], return_type=list), ["texturing", "node"]
)
)
def test_query_valid_entry(self):
self.cfg.get(self.format_test)
self.assertRaises(
exceptions.ResourceNotFoundError, self.cfg.get, [self.format_title, "submuerts"]
)
self.assertRaises(
exceptions.ResourceNotFoundError, self.cfg.get, ["faming_subsets", self.default_format]
)
self.assertRaises(
exceptions.ResourceNotFoundError, self.cfg.get, ["faming_subsets", "dubsteps"]
)
def test_get_section_ordered_dict(self):
self.assertEquals(
self.cfg.get(self.discipline_path, return_type=OrderedDict),
OrderedDict(sorted(self.discipline_data.items(), key=lambda x: x[0])),
)
def test_get_section_ordered_dict_full_path(self):
self.assertEquals(
self.cfg.get(self.discipline_path, return_type=OrderedDict, preceding_depth=-1),
{
"options": {
"discipline": OrderedDict(
sorted(self.discipline_data.items(), key=lambda x: x[0])
)
}
},
)
def test_get_section_ordered_dict_partial_path(self):
self.assertEquals(
self.cfg.get(self.discipline_path, return_type=OrderedDict, preceding_depth=0),
{"discipline": OrderedDict(sorted(self.discipline_data.items(), key=lambda x: x[0]))},
)
def test_get_disciplines_as_string(self):
self.assertTrue(
self.checkEqual(
self.cfg.get(self.discipline_path, return_type=str).split(), self.discipline_subsets
)
)
def test_get_as_string_search(self):
self.assertTrue(
self.checkEqual(self.cfg.get("animation", return_type=str), "AN ANI ANIM ANIMN")
)
def test_get_as_dict(self):
self.assertEquals(
self.cfg.get(self.discipline_path, return_type=list, preceding_depth=-1),
{self.discipline_path[0]: {self.discipline_path[1]: self.discipline_subsets}},
)
def test_get_as_dict_subdict(self):
self.assertEquals(
self.cfg.get(self.discipline_path, return_type=dict), self.discipline_data
)
def test_get(self):
self.assertTrue(
self.checkEqual(
self.cfg.get(self.discipline_path, return_type=dict), self.discipline_subsets
)
)
def test_list_sections(self):
self.assertCountEqual(
self.cfg.get([], return_type=list), ["overall_config", "options", "naming_formats"]
)
def test_list_section_options(self):
self.assertEquals(self.cfg.get(self.format_title, return_type=list), ["node", "texturing"])
def test_default_get(self):
print(self.cfg.get(return_type=str))
self.assertEquals(self.cfg.get(return_type=str), "")
def test_default_get_no_return_type(self):
self.assertEquals(self.cfg.get(), ["overall_config", "options", "naming_formats"])
|
class TestGet(TestConfiguratorBase):
def test_get_default_as_string(self):
pass
def test_get_options(self):
pass
def test_query_valid_entry(self):
pass
def test_get_section_ordered_dict(self):
pass
def test_get_section_ordered_dict_full_path(self):
pass
def test_get_section_ordered_dict_partial_path(self):
pass
def test_get_disciplines_as_string(self):
pass
def test_get_as_string_search(self):
pass
def test_get_as_dict(self):
pass
def test_get_as_dict_subdict(self):
pass
def test_get_default_as_string(self):
pass
def test_list_sections(self):
pass
def test_list_section_options(self):
pass
def test_default_get(self):
pass
def test_default_get_no_return_type(self):
pass
| 16 | 0 | 5 | 0 | 5 | 0 | 1 | 0 | 1 | 5 | 1 | 0 | 15 | 2 | 15 | 92 | 94 | 14 | 80 | 18 | 64 | 0 | 35 | 16 | 19 | 1 | 4 | 0 | 15 |
4,679 |
AndresMWeber/Nomenclate
|
tests/test_configurator.py
|
tests.test_configurator.TestGetDefaultConfigFile
|
class TestGetDefaultConfigFile(TestConfiguratorBase):
def test_existing(self):
config.ConfigParse()
def test_custom(self):
fd, temp_path = mkstemp()
f = open(temp_path, "w")
f.write(json.dumps({"name": "john", "location": "top"}))
f.close()
custom_config = config.ConfigParse(config_filename=temp_path)
self.assertDictEqual(
custom_config.config, OrderedDict([("name", "john"), ("location", "top")])
)
os.close(fd)
os.remove(temp_path)
def test_custom_empty(self):
fd, temp_path = mkstemp()
self.assertRaises(
exceptions.SourceError, config.ConfigParse.validate_config_file, temp_path
)
os.close(fd)
os.remove(temp_path)
def test_custom_no_yaml_data(self):
fd, temp_path = mkstemp()
f = open(temp_path, "w")
f.write("#Empty YAML File")
f.close()
self.assertRaises(
exceptions.SourceError, config.ConfigParse.validate_config_file, temp_path
)
os.close(fd)
os.remove(temp_path)
|
class TestGetDefaultConfigFile(TestConfiguratorBase):
def test_existing(self):
pass
def test_custom(self):
pass
def test_custom_empty(self):
pass
def test_custom_no_yaml_data(self):
pass
| 5 | 0 | 8 | 0 | 8 | 0 | 1 | 0.03 | 1 | 3 | 2 | 0 | 4 | 0 | 4 | 81 | 34 | 3 | 31 | 11 | 26 | 1 | 25 | 11 | 20 | 1 | 4 | 0 | 4 |
4,680 |
AndresMWeber/Nomenclate
|
tests/test_formatter.py
|
tests.test_formatter.TestFormatStringBase
|
class TestFormatStringBase(TestBase):
def setUp(self):
super(TestFormatStringBase, self).setUp()
self.fs = formatter.FormatString()
self.fixtures.append(self.fs)
|
class TestFormatStringBase(TestBase):
def setUp(self):
pass
| 2 | 0 | 4 | 0 | 4 | 0 | 1 | 0 | 1 | 2 | 1 | 1 | 1 | 1 | 1 | 77 | 5 | 0 | 5 | 3 | 3 | 0 | 5 | 3 | 3 | 1 | 3 | 0 | 1 |
4,681 |
AndresMWeber/Nomenclate
|
tests/test_tokens_handler.py
|
tests.test_tokens_handler.TestGetTokenAttr
|
class TestGetTokenAttr(TestTokenAttrBase):
def test_get_existing(self):
self.assertEquals(self.token_attr_dict_handler.name, tokens.TokenAttr('name', ''))
def test_get_not_existing(self):
self.assertRaises(AttributeError, getattr, self.token_attr_dict_handler, 'no')
|
class TestGetTokenAttr(TestTokenAttrBase):
def test_get_existing(self):
pass
def test_get_not_existing(self):
pass
| 3 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 2 | 1 | 0 | 2 | 0 | 2 | 79 | 6 | 1 | 5 | 3 | 2 | 0 | 5 | 3 | 2 | 1 | 4 | 0 | 2 |
4,682 |
AndresMWeber/Nomenclate
|
tests/test_processing.py
|
tests.test_processing.TokenMatchEquals
|
class TokenMatchEquals(TokenMatchBase):
def test_equal(self):
self.assertTrue(self.token_match_start,
processing.TokenMatch(next(re.compile(r'(?P<token>te)').finditer('test')), 'mx'))
def test_inequal(self):
self.assertTrue(self.token_match_start,
self.token_match_mid)
def test_invalid_type(self):
self.assertRaises(NotImplementedError, self.token_match_start.__eq__, 5)
|
class TokenMatchEquals(TokenMatchBase):
def test_equal(self):
pass
def test_inequal(self):
pass
def test_invalid_type(self):
pass
| 4 | 0 | 3 | 0 | 3 | 0 | 1 | 0 | 1 | 2 | 1 | 0 | 3 | 0 | 3 | 80 | 11 | 2 | 9 | 4 | 5 | 0 | 7 | 4 | 3 | 1 | 4 | 0 | 3 |
4,683 |
AndresMWeber/Nomenclate
|
nomenclate/core/errors.py
|
nomenclate.core.errors.NomenclateException
|
class NomenclateException(Exception):
"""Base Tabulator exception.
"""
pass
|
class NomenclateException(Exception):
'''Base Tabulator exception.
'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 8 | 0 | 0 | 0 | 10 | 4 | 0 | 2 | 1 | 1 | 2 | 2 | 1 | 1 | 0 | 3 | 0 | 0 |
4,684 |
AndresMWeber/Nomenclate
|
tests/test_acceptance_workflow.py
|
tests.test_acceptance_workflow.TestAcceptanceMaya
|
class TestAcceptanceMaya(TestBase):
pass
|
class TestAcceptanceMaya(TestBase):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 76 | 2 | 0 | 2 | 1 | 1 | 0 | 2 | 1 | 1 | 0 | 3 | 0 | 0 |
4,685 |
AndresMWeber/Nomenclate
|
nomenclate/core/errors.py
|
nomenclate.core.errors.ResourceNotFoundError
|
class ResourceNotFoundError(NomenclateException):
"""HTTP error.
"""
pass
|
class ResourceNotFoundError(NomenclateException):
'''HTTP error.
'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 10 | 4 | 0 | 2 | 1 | 1 | 2 | 2 | 1 | 1 | 0 | 4 | 0 | 0 |
4,686 |
AndresMWeber/Nomenclate
|
nomenclate/core/errors.py
|
nomenclate.core.errors.SchemeError
|
class SchemeError(NomenclateException):
"""Scheme error.
"""
pass
|
class SchemeError(NomenclateException):
'''Scheme error.
'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 10 | 4 | 0 | 2 | 1 | 1 | 2 | 2 | 1 | 1 | 0 | 4 | 0 | 0 |
4,687 |
AndresMWeber/Nomenclate
|
nomenclate/core/errors.py
|
nomenclate.core.errors.SourceError
|
class SourceError(NomenclateException):
"""Stream error.
"""
pass
|
class SourceError(NomenclateException):
'''Stream error.
'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 10 | 4 | 0 | 2 | 1 | 1 | 2 | 2 | 1 | 1 | 0 | 4 | 0 | 0 |
4,688 |
AndresMWeber/Nomenclate
|
nomenclate/core/errors.py
|
nomenclate.core.errors.ValidationError
|
class ValidationError(NomenclateException):
"""IO error.
"""
pass
|
class ValidationError(NomenclateException):
'''IO error.
'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 10 | 4 | 0 | 2 | 1 | 1 | 2 | 2 | 1 | 1 | 0 | 4 | 0 | 0 |
4,689 |
AndresMWeber/Nomenclate
|
nomenclate/core/formatter.py
|
nomenclate.core.formatter.FormatString
|
class FormatString(object):
@property
def format_order(self):
return self.processed_format_order
@format_order.setter
def format_order(self, format_target):
if format_target:
self.processed_format_order = self.get_valid_format_order(format_target)
else:
self.processed_format_order = []
def __init__(self, format_string=""):
self.processed_format_order = []
self.format_string = format_string
self.format_order = self.format_string
self.swap_format(format_string)
def swap_format(self, format_target):
try:
self.format_order = format_target
self.format_string = format_target
except exceptions.FormatError as e:
raise e
@classmethod
def parse_format_order(cls, format_target):
""" Dissects the format string and gets the order of the tokens as it finds them l->r
Splits on camel case or periods/underscores
Modified version from this:
http://stackoverflow.com/questions/2277352/python-split-a-string-at-uppercase-letters
:param format_target: str, format string we want to swap to
:return: list(str), list of the matching tokens
"""
try:
pattern = re.compile(settings.FORMAT_STRING_REGEX)
return [match.group() for match in pattern.finditer(format_target)]# if None not in match.groups()]
except TypeError:
raise exceptions.FormatError('Format string %s is not a valid input type, must be <type str>' %
format_target)
@classmethod
def get_valid_format_order(cls, format_target, format_order=None):
""" Checks to see if the target format string follows the proper style
"""
format_order = format_order or cls.parse_format_order(format_target)
cls.validate_no_token_duplicates(format_order)
format_target = cls.remove_tokens(format_target, format_order)
format_target = cls.remove_static_text(format_target)
cls.validate_separator_characters(format_target)
cls.validate_matched_parenthesis(format_target)
return format_order
@staticmethod
def remove_tokens(format_target, format_order):
for format_str in format_order:
format_target = re.sub(format_str, '', format_target, count=1)
return format_target
@staticmethod
def remove_static_text(format_target):
return re.sub(settings.REGEX_STATIC_TOKEN, '', format_target)
@classmethod
def validate_separator_characters(cls, separator_characters):
for char in separator_characters:
if char not in settings.SEPARATORS:
msg = "You have specified an invalid format string %s, must be separated by %s." % (
separator_characters,
settings.SEPARATORS)
raise exceptions.FormatError(msg)
@classmethod
def validate_no_token_duplicates(cls, format_order):
if len(format_order) != len(list(set([order.lower() for order in format_order]))):
raise exceptions.FormatError("Format string has duplicate token names (capitalization insensitive).")
@classmethod
def validate_matched_parenthesis(cls, format_target):
""" Adapted from https://stackoverflow.com/questions/6701853/parentheses-pairing-issue
:param format_order:
:return:
"""
iparens = iter('(){}[]<>')
parens = dict(zip(iparens, iparens))
closing = parens.values()
def balanced(astr):
stack = []
for c in astr:
d = parens.get(c, None)
if d:
stack.append(d)
elif c in closing:
if not stack or c != stack.pop():
return False
return not stack
if format_target:
if not balanced(format_target):
raise exceptions.BalanceError("Format string has unmatching parentheses.")
def __str__(self):
return str(self.format_string)
|
class FormatString(object):
@property
def format_order(self):
pass
@format_order.setter
def format_order(self):
pass
def __init__(self, format_string=""):
pass
def swap_format(self, format_target):
pass
@classmethod
def parse_format_order(cls, format_target):
''' Dissects the format string and gets the order of the tokens as it finds them l->r
Splits on camel case or periods/underscores
Modified version from this:
http://stackoverflow.com/questions/2277352/python-split-a-string-at-uppercase-letters
:param format_target: str, format string we want to swap to
:return: list(str), list of the matching tokens
'''
pass
@classmethod
def get_valid_format_order(cls, format_target, format_order=None):
''' Checks to see if the target format string follows the proper style
'''
pass
@staticmethod
def remove_tokens(format_target, format_order):
pass
@staticmethod
def remove_static_text(format_target):
pass
@classmethod
def validate_separator_characters(cls, separator_characters):
pass
@classmethod
def validate_no_token_duplicates(cls, format_order):
pass
@classmethod
def validate_matched_parenthesis(cls, format_target):
''' Adapted from https://stackoverflow.com/questions/6701853/parentheses-pairing-issue
:param format_order:
:return:
'''
pass
def balanced(astr):
pass
def __str__(self):
pass
| 23 | 3 | 7 | 0 | 6 | 1 | 2 | 0.18 | 1 | 8 | 2 | 0 | 5 | 2 | 12 | 12 | 107 | 16 | 78 | 36 | 55 | 14 | 64 | 26 | 50 | 5 | 1 | 3 | 26 |
4,690 |
AndresMWeber/Nomenclate
|
tests/basetest.py
|
tests.basetest.TestBase
|
class TestBase(unittest.TestCase):
def setUp(self):
super(TestBase, self).setUp()
self.fixtures = []
def tearDown(self):
super(TestBase, self).tearDown()
for fixture in self.fixtures:
del fixture
@staticmethod
def checkEqual(list_a, list_b):
return len(list_a) == len(list_b) and sorted(list_a) == sorted(list_b)
def assertDictEqual(self, d1, d2, msg=None): # assertEqual uses for dicts
for k, v1 in d1.items():
self.assertIn(k, d2, msg)
v2 = d2[k]
if isinstance(v1, Iterable) and not isinstance(v1, str):
self.checkEqual(v1, v2)
else:
self.assertEqual(v1, v2, msg)
return True
|
class TestBase(unittest.TestCase):
def setUp(self):
pass
def tearDown(self):
pass
@staticmethod
def checkEqual(list_a, list_b):
pass
def assertDictEqual(self, d1, d2, msg=None):
pass
| 6 | 0 | 5 | 0 | 5 | 0 | 2 | 0.05 | 1 | 2 | 0 | 16 | 3 | 1 | 4 | 76 | 23 | 3 | 20 | 10 | 14 | 1 | 18 | 9 | 13 | 3 | 2 | 2 | 7 |
4,691 |
AndresMWeber/Nomenclate
|
tests/test_processing.py
|
tests.test_processing.TokenMatchContains
|
class TokenMatchContains(TokenMatchBase):
def test_does_not_contain(self):
self.assertFalse(self.token_match_start in self.token_match_end)
def test_contains(self):
self.assertTrue(self.token_match_start in self.token_match_mid)
def test_invalid_type(self):
self.assertRaises(NotImplementedError, self.token_match_start.__contains__, 5)
|
class TokenMatchContains(TokenMatchBase):
def test_does_not_contain(self):
pass
def test_contains(self):
pass
def test_invalid_type(self):
pass
| 4 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 3 | 1 | 3 | 80 | 9 | 2 | 7 | 5 | 3 | 0 | 7 | 4 | 3 | 1 | 4 | 0 | 3 |
4,692 |
AndresMWeber/Nomenclate
|
tests/test_tokens_handler.py
|
tests.test_tokens_handler.TestPurge
|
class TestPurge(TestTokenAttrBase):
def test_default(self):
handler = tokens.TokenAttrList(self.nomenclate.state)
handler.purge_tokens()
self.assertEquals(handler.token_attrs, [])
def test_input(self):
handler = tokens.TokenAttrList(self.nomenclate.state)
handler.purge_tokens([token.token for token in handler.token_attrs])
self.assertEquals(handler.token_attrs, [])
|
class TestPurge(TestTokenAttrBase):
def test_default(self):
pass
def test_input(self):
pass
| 3 | 0 | 4 | 0 | 4 | 0 | 1 | 0 | 1 | 1 | 1 | 0 | 2 | 0 | 2 | 79 | 10 | 1 | 9 | 5 | 6 | 0 | 9 | 5 | 6 | 1 | 4 | 0 | 2 |
4,693 |
AndresMWeber/Nomenclate
|
tests/test_tools.py
|
tests.test_tools.TestGetKeysContaining
|
class TestGetKeysContaining(TestBase):
def test_simple(self):
self.assertEquals(get_keys_containing('test', {'test': 1}), 1)
def test_not_existing(self):
self.assertEquals(get_keys_containing('mest', {'test': 1}), None)
def test_mock_config_find(self):
self.checkEqual(
list(get_keys_containing('naming_formats', OrderedDict([('overall_config', {'version_padding': 3}),
('options', {
'discipline': {'animation': 'AN ANI ANIM ANIMN',
'lighting': 'LT LGT LGHT LIGHT',
'compositing': 'CM CMP COMP COMPG',
'rigging': 'RG RIG RIGG RIGNG',
'modeling': 'MD MOD MODL MODEL',
'matchmove': 'MM MMV MMOV MMOVE'},
'side': ['left', 'right', 'center']}),
('naming_formats', {
'node': {
'default': 'side_location_nameDecoratorVar_childtype_purpose_type',
'format_archive': 'side_name_space_purpose_decorator_childtype_type',
'format_lee': 'type_childtype_space_purpose_name_side'},
'texturing': {'shader': 'side_name_type'}})]))),
['node', 'texturing'])
|
class TestGetKeysContaining(TestBase):
def test_simple(self):
pass
def test_not_existing(self):
pass
def test_mock_config_find(self):
pass
| 4 | 0 | 7 | 0 | 7 | 0 | 1 | 0 | 1 | 2 | 0 | 0 | 3 | 0 | 3 | 79 | 25 | 2 | 23 | 4 | 19 | 0 | 7 | 4 | 3 | 1 | 3 | 0 | 3 |
4,694 |
AndresMWeber/Nomenclate
|
tests/test_tools.py
|
tests.test_tools.TestGenDictKeyMatches
|
class TestGenDictKeyMatches(TestBase):
def test_with_nested(self):
self.checkEqual(list(gen_dict_key_matches('name', {1: 1, 2: 2, 3: 3, 'test': {'name': 'mesh',
'test': {'name': 'bah'}},
'name': 'test', 'discipline': 'lots'})),
['mesh', 'bah', 'test'])
def test_not_nested(self):
self.assertListEqual(list(gen_dict_key_matches('name',
{1: 1, 2: 2, 3: 3, 'name': 'mesh', 'discipline': 'lots'})),
['mesh'])
def test_list(self):
self.checkEqual(list(gen_dict_key_matches('name',
{1: 1, 2: 2, 3: 3, 'test': {'name': 'mesh',
'test': {'name': 'bah'},
'suffixes': {'name':
{'bah': 'fah'}}},
'list': [{'name': 'nested_list'}, 5]})),
['mesh', 'bah', {'bah': 'fah'}, 'nested_list'])
def test_empty(self):
self.assertListEqual(list(gen_dict_key_matches('name', {})),
[])
def test_simple(self):
self.assertEquals(next(gen_dict_key_matches('test', {'test': 1})), 1)
def test_simple_with_path(self):
self.assertEquals(next(gen_dict_key_matches('test', {'test': 1}, full_path=True)), (['test'], 1))
def test_list_full_path(self):
self.checkEqual(list(gen_dict_key_matches('name',
{1: 1, 2: 2, 3: 3, 'test': {'name': 'mesh',
'test': {'name': 'bah'},
'suffixes': {'name':
{'bah': 'fah'}}},
'list': [{'name': 'nested_list'}, 5]},
full_path=True)),
['mesh', 'bah', {'bah': 'fah'}, 'nested_list'])
def test_mock_config_find(self):
self.checkEqual(
list(get_keys_containing('naming_formats', OrderedDict([('overall_config', {'version_padding': 3}),
('options', {
'discipline': {
'animation': 'AN ANI ANIM ANIMN',
'lighting': 'LT LGT LGHT LIGHT',
'compositing': 'CM CMP COMP COMPG',
'rigging': 'RG RIG RIGG RIGNG',
'modeling': 'MD MOD MODL MODEL',
'matchmove': 'MM MMV MMOV MMOVE'},
'side': ['left', 'right', 'center']}),
('naming_formats', {
'node': {
'default': 'side_location_nameDecoratorVar_childtype_purpose_type',
'format_archive': 'side_name_space_purpose_decorator_childtype_type',
'format_lee': 'type_childtype_space_purpose_name_side'},
'texturing': {
'shader': 'side_name_type'}})]))),
['node', 'texturing'])
|
class TestGenDictKeyMatches(TestBase):
def test_with_nested(self):
pass
def test_not_nested(self):
pass
def test_list(self):
pass
def test_empty(self):
pass
def test_simple(self):
pass
def test_simple_with_path(self):
pass
def test_list_full_path(self):
pass
def test_mock_config_find(self):
pass
| 9 | 0 | 7 | 0 | 7 | 0 | 1 | 0 | 1 | 2 | 0 | 0 | 8 | 0 | 8 | 84 | 61 | 7 | 54 | 9 | 45 | 0 | 17 | 9 | 8 | 1 | 3 | 0 | 8 |
4,695 |
AndresMWeber/Nomenclate
|
tests/test_tools.py
|
tests.test_tools.TestCombineDicts
|
class TestCombineDicts(TestBase):
def test_with_dict_with_nomenclate_object(self):
self.assertDictEqual(combine_dicts({1: 1, 2: 2, 3: 3}, nm.Nom(name='test', purpose='lots').state),
{'decorator': '', 1: 1, 2: 2, 3: 3, 'name': 'test', 'type': '', 'side': '',
'childtype': '', 'var': '', 'location': '', 'purpose': 'lots'})
def test_only_dicts(self):
self.assertDictEqual(combine_dicts({1: 1, 2: 2, 3: 3}, {4: 4, 5: 5, 6: 6}),
{1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6})
def test_no_dicts_or_kwargs(self):
self.assertDictEqual(combine_dicts('five', 5, None, [], 'haha'),
{})
def test_kwargs(self):
self.assertDictEqual(combine_dicts(parse='test', plush=5),
{'parse': 'test', 'plush': 5})
def test_dicts_and_kwargs(self):
self.assertDictEqual(combine_dicts({1: 1, 2: 2, 3: 3}, {4: 4, 5: 5, 6: 6}, parse='test', plush=5),
{'parse': 'test', 'plush': 5, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6})
def test_dicts_and_kwargs_with_dict_overlaps(self):
self.assertDictEqual(combine_dicts({1: 1, 2: 2, 3: 3}, {2: 4, 4: 5, 5: 3}, parse='test', plush=5),
{'parse': 'test', 'plush': 5, 1: 1, 2: 4, 3: 3, 4: 5, 5: 3})
def test_dicts_and_kwargs_and_ignorables(self):
self.assertDictEqual(combine_dicts({1: 1, 2: 2, 3: 3}, 5, 'the', None, parse='test', plush=5),
{'parse': 'test', 'plush': 5, 1: 1, 2: 2, 3: 3})
|
class TestCombineDicts(TestBase):
def test_with_dict_with_nomenclate_object(self):
pass
def test_only_dicts(self):
pass
def test_no_dicts_or_kwargs(self):
pass
def test_kwargs(self):
pass
def test_dicts_and_kwargs(self):
pass
def test_dicts_and_kwargs_with_dict_overlaps(self):
pass
def test_dicts_and_kwargs_and_ignorables(self):
pass
| 8 | 0 | 3 | 0 | 3 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 7 | 0 | 7 | 83 | 29 | 6 | 23 | 8 | 15 | 0 | 15 | 8 | 7 | 1 | 3 | 0 | 7 |
4,696 |
AndresMWeber/Nomenclate
|
tests/test_tokens_handler.py
|
tests.test_tokens_handler.TestTokenAttrs
|
class TestTokenAttrs(TestTokenAttrBase):
def test_get(self):
self.checkEqual(list(self.token_attr_dict_handler.token_attrs),
[tokens.TokenAttr('Var', ''),
tokens.TokenAttr('purpose', ''),
tokens.TokenAttr('type', ''),
tokens.TokenAttr('side', ''),
tokens.TokenAttr('location', ''),
tokens.TokenAttr('childtype', ''),
tokens.TokenAttr('name', ''),
tokens.TokenAttr('Decorator', '')])
|
class TestTokenAttrs(TestTokenAttrBase):
def test_get(self):
pass
| 2 | 0 | 10 | 0 | 10 | 0 | 1 | 0 | 1 | 2 | 1 | 0 | 1 | 0 | 1 | 78 | 11 | 0 | 11 | 2 | 9 | 0 | 3 | 2 | 1 | 1 | 4 | 0 | 1 |
4,697 |
AndresMWeber/Nomenclate
|
tests/test_tokens_handler.py
|
tests.test_tokens_handler.TestTokenAttrBase
|
class TestTokenAttrBase(TestBase):
def setUp(self):
super(TestTokenAttrBase, self).setUp()
self.nomenclate = nm.Nom()
self.token_attr_dict_handler = tokens.TokenAttrList(self.nomenclate.token_dict.to_json())
self.fixtures.append(self.token_attr_dict_handler)
|
class TestTokenAttrBase(TestBase):
def setUp(self):
pass
| 2 | 0 | 5 | 0 | 5 | 0 | 1 | 0 | 1 | 2 | 1 | 5 | 1 | 2 | 1 | 77 | 6 | 0 | 6 | 4 | 4 | 0 | 6 | 4 | 4 | 1 | 3 | 0 | 1 |
4,698 |
AndresMWeber/Nomenclate
|
tests/test_acceptance_workflow.py
|
tests.test_acceptance_workflow.TestAcceptanceNamingFiletypes
|
class TestAcceptanceNamingFiletypes(TestBase):
def test_saving_maya_file(self):
n = nom.Nomenclate(name='SH010', var=0, ext='mb', initials='aw', discipline='animation', version=5)
n.var.case = 'upper'
n.version.prefix = 'v'
n.discipline.length = 4
n.initialize_format_options('working_file')
self.assertEquals(n.format, 'name_discipline_lodDecoratorVar_version_initials.ext')
self.assertEquals(n.get(), 'SH010_ANIM_A_v005_aw.mb')
self.fixtures.append(n)
def test_saving_movie_file(self):
n = nom.Nomenclate()
n.initialize_format_options('techops_file')
n.version.prefix = 'v'
n.version1.prefix = 'v'
n.merge_dict({'shot': 'LSC_sh01',
'version': 8,
'name': 'Nesquick',
'type': 'SFX_MS',
'status': 'WIP',
'date': 'September 21, 2005',
'filetype': 'Quicktime',
'var': 0,
'ext': 'mov',
'initials': 'aw',
'discipline': 'animation',
'quality': '540p',
'version1': 3,
'version_padding': 1,
'version1_format': 'v#',
'version1_padding': 1})
n.var.case = 'upper'
self.assertEquals('LSC_sh01_v8_Nesquick_SFX_MS_WIP_v3_2005-09-21-540p_Quicktime.mov', n.get())
n.date_format = '%m%d%y'
self.assertEquals('LSC_sh01_v8_Nesquick_SFX_MS_WIP_v3_092105-540p_Quicktime.mov', n.get())
self.fixtures.append(n)
|
class TestAcceptanceNamingFiletypes(TestBase):
def test_saving_maya_file(self):
pass
def test_saving_movie_file(self):
pass
| 3 | 0 | 18 | 1 | 18 | 1 | 1 | 0.03 | 1 | 1 | 1 | 0 | 2 | 0 | 2 | 78 | 38 | 2 | 36 | 5 | 33 | 1 | 21 | 5 | 18 | 1 | 3 | 0 | 2 |
4,699 |
AndresMWeber/Nomenclate
|
nomenclate/core/tools.py
|
nomenclate.core.tools.Serializable
|
class Serializable(object):
SERIALIZE_ATTRS = []
def serialize(self):
return self.to_json()
def deserialize(self, blob):
return self.from_json(blob)
def merge_serialization(self, blob):
return self.merge_json(blob)
def to_json(self):
return {attr: getattr(self, attr) for attr in self.SERIALIZE_ATTRS}
def merge_json(self, json_blob):
for search_attr in [
attr for attr in self.SERIALIZE_ATTRS if json_blob.get(attr) is not None
]:
json_attr = json_blob[search_attr]
setattr(self, search_attr, json_attr)
return True
@classmethod
def from_json(cls, json_blob):
return cls(
**{
attr: json_blob[attr]
for attr in cls.SERIALIZE_ATTRS
if json_blob.get(attr) is not None
}
)
|
class Serializable(object):
def serialize(self):
pass
def deserialize(self, blob):
pass
def merge_serialization(self, blob):
pass
def to_json(self):
pass
def merge_json(self, json_blob):
pass
@classmethod
def from_json(cls, json_blob):
pass
| 8 | 0 | 4 | 0 | 4 | 0 | 1 | 0 | 1 | 0 | 0 | 3 | 5 | 0 | 6 | 6 | 32 | 6 | 26 | 11 | 18 | 0 | 17 | 10 | 10 | 2 | 1 | 1 | 7 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.