Skip to content
Snippets Groups Projects
Commit a6d8be34 authored by Thorge Petersen's avatar Thorge Petersen
Browse files

Some fixes for tpsh testcases

parent 7bc667ec
No related branches found
No related tags found
1 merge request!41Version 2.0.0
...@@ -67,7 +67,7 @@ def correct_missing_relationship(pkg_dict, pkg_relationships_from_model): ...@@ -67,7 +67,7 @@ def correct_missing_relationship(pkg_dict, pkg_relationships_from_model):
relationship_for_package = { relationship_for_package = {
'__extras': { '__extras': {
'object_package_id': relationship_from_model.object_package_id, 'object_package_id': relationship_from_model.object_package_id,
#'revision_id': relationship_from_model.revision_id, 'revision_id': relationship_from_model.revision_id,
'subject_package_id': relationship_from_model.subject_package_id, 'subject_package_id': relationship_from_model.subject_package_id,
}, },
'comment': relationship_from_model.subject_package_id, 'comment': relationship_from_model.subject_package_id,
......
...@@ -90,10 +90,12 @@ def add_to_collection(collection_id, package_name): ...@@ -90,10 +90,12 @@ def add_to_collection(collection_id, package_name):
def check_password(password): def check_password(password):
return (len(password) >= 8 and return (
len(password) >= 8 and
any(c.islower() for c in password) and any(c.islower() for c in password) and
any(c.isupper() for c in password) and any(c.isupper() for c in password) and
any((c.isalpha()==False) for c in password)) #Number or Special character any(not c.isalpha() for c in password)
)
PASSWORD_ERROR_MESSAGE = {'security': ['Passwort muss mindestens acht Zeichen, einen Gross-, einen Kleinbuchstaben und entweder eine Zahl oder ein Sondernzeichen enthalten!']} PASSWORD_ERROR_MESSAGE = {'security': ['Passwort muss mindestens acht Zeichen, einen Gross-, einen Kleinbuchstaben und entweder eine Zahl oder ein Sondernzeichen enthalten!']}
......
...@@ -24,17 +24,17 @@ class testHashException(unittest.TestCase): ...@@ -24,17 +24,17 @@ class testHashException(unittest.TestCase):
def test_with_correct_hash(self): def test_with_correct_hash(self):
resource = {'package_id':'Test_id', 'hash':self.hash_for_text} resource = {'package_id':'Test_id', 'hash':self.hash_for_text}
with patch("builtins.open", mock_open(read_data=self.text)) as mock_file: with patch("builtins.open", mock_open(read_data=self.text.encode('utf-8'))) as mock_file:
with open('some/file') as f: with open('some/file') as f:
assert _raise_validation_error_if_hash_values_differ(f, resource) == None assert _raise_validation_error_if_hash_values_differ(f, resource) == None
def test_with_wrong_hash(self): def test_with_wrong_hash(self):
resource = {'package_id':'Test_id', 'hash':'incorrect_hash'} resource = {'package_id':'Test_id', 'hash':'incorrect_hash'}
with patch("builtins.open", mock_open(read_data=self.text)) as mock_file: with patch("builtins.open", mock_open(read_data=self.text.encode('utf-8'))) as mock_file:
with open('some/file') as f: with open('some/file') as f:
with pytest.raises(logic.ValidationError) as e: with pytest.raises(logic.ValidationError) as e:
_raise_validation_error_if_hash_values_differ(f, resource) _raise_validation_error_if_hash_values_differ(f, resource)
exception_upload = e.exception.error_dict.get('upload') exception_upload = e.value.error_dict.get('upload')
assert exception_upload[0] == 'Berechneter Hash und mitgelieferter Hash sind unterschiedlich' assert exception_upload[0] == 'Berechneter Hash und mitgelieferter Hash sind unterschiedlich'
def test_mock_file(self): def test_mock_file(self):
......
...@@ -156,8 +156,7 @@ class Test_correct_missing_relationship(unittest.TestCase): ...@@ -156,8 +156,7 @@ class Test_correct_missing_relationship(unittest.TestCase):
for key in ('object_package_id', 'revision_id', 'subject_package_id'): for key in ('object_package_id', 'revision_id', 'subject_package_id'):
assert pkg_dict is not None assert pkg_dict is not None
assert from_extras(pkg_dict, key) == from_extras(expected_pkg_dict, key assert from_extras(pkg_dict, key) == from_extras(expected_pkg_dict, key)
)
class Test_get_language_of_package(unittest.TestCase): class Test_get_language_of_package(unittest.TestCase):
......
...@@ -17,7 +17,7 @@ class Test_PasswordValidation(unittest.TestCase): ...@@ -17,7 +17,7 @@ class Test_PasswordValidation(unittest.TestCase):
self.assert_password_valid('Passwort1 :) :P :D') self.assert_password_valid('Passwort1 :) :P :D')
def test_umlaute(self): def test_umlaute(self):
self.assert_password_valid('Pässword') self.assert_password_valid('Pässword1')
def test_no_uppercase(self): def test_no_uppercase(self):
self.assert_password_invalid('passwort1') self.assert_password_invalid('passwort1')
...@@ -26,7 +26,7 @@ class Test_PasswordValidation(unittest.TestCase): ...@@ -26,7 +26,7 @@ class Test_PasswordValidation(unittest.TestCase):
self.assert_password_invalid('PASSWORT1') self.assert_password_invalid('PASSWORT1')
def test_no_letters(self): def test_no_letters(self):
self.assert_password_invalid('37459073245!!?===))/=$§äüöÄÜÖ') self.assert_password_invalid('37459073245!!?===))/=$§')
def test_only_letters(self): def test_only_letters(self):
self.assert_password_invalid('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz') self.assert_password_invalid('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz')
......
...@@ -48,7 +48,7 @@ class TestODSHDCATdeProfileParseDatasetWithCollection(unittest.TestCase): ...@@ -48,7 +48,7 @@ class TestODSHDCATdeProfileParseDatasetWithCollection(unittest.TestCase):
def test_parse_type_does_not_add_collection_to_dataset_dict(self): def test_parse_type_does_not_add_collection_to_dataset_dict(self):
dataset_dict = {} dataset_dict = {}
self.profile._parse_type(dataset_dict, self.dataset_ref_with_collection_member) self.profile._parse_type(dataset_dict, self.dataset_ref_with_collection_member)
nt.assert_not_in('type', dataset_dict) assert 'type' not in dataset_dict
def test_belongs_to_collection_returns_true(self): def test_belongs_to_collection_returns_true(self):
dataset_dict = {} dataset_dict = {}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment