Code Review
/
modeling
/
etsicatalog.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Update python2 to python3
[modeling/etsicatalog.git]
/
genericparser
/
packages
/
tests
/
test_ns_descriptor.py
diff --git
a/genericparser/packages/tests/test_ns_descriptor.py
b/genericparser/packages/tests/test_ns_descriptor.py
index
862030a
..
36933ac
100644
(file)
--- a/
genericparser/packages/tests/test_ns_descriptor.py
+++ b/
genericparser/packages/tests/test_ns_descriptor.py
@@
-78,7
+78,9
@@
class TestNsDescriptor(TestCase):
)
response.data.pop('id')
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
)
response.data.pop('id')
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
- self.assertEqual(expected_reponse_data, response.data)
+ # self.assertEqual(expected_reponse_data, response.data)
+ for key, value in expected_reponse_data.items():
+ self.assertEqual(response.data[key], value)
def test_query_multiple_nsds_normal(self):
expected_reponse_data = [
def test_query_multiple_nsds_normal(self):
expected_reponse_data = [
@@
-175,9
+177,9
@@
class TestNsDescriptor(TestCase):
userDefinedData=user_defined_data_json,
).save()
userDefinedData=user_defined_data_json,
).save()
- with open('nsd_content.txt', 'w
b
') as fp:
+ with open('nsd_content.txt', 'w
t
') as fp:
fp.write('test')
fp.write('test')
- with open('nsd_content.txt', 'r
b
') as fp:
+ with open('nsd_content.txt', 'r
t
') as fp:
resp = self.client.put(
"/api/nsd/v1/ns_descriptors/22/nsd_content",
{'file': fp},
resp = self.client.put(
"/api/nsd/v1/ns_descriptors/22/nsd_content",
{'file': fp},
@@
-195,9
+197,9
@@
class TestNsDescriptor(TestCase):
os.remove('nsd_content.txt')
def test_nsd_content_upload_failure(self):
os.remove('nsd_content.txt')
def test_nsd_content_upload_failure(self):
- with open('nsd_content.txt', 'w
b
') as fp:
+ with open('nsd_content.txt', 'w
t
') as fp:
fp.write('test')
fp.write('test')
- with open('nsd_content.txt', 'r
b
') as fp:
+ with open('nsd_content.txt', 'r
t
') as fp:
response = self.client.put(
"/api/nsd/v1/ns_descriptors/22/nsd_content",
{'file': fp},
response = self.client.put(
"/api/nsd/v1/ns_descriptors/22/nsd_content",
{'file': fp},
@@
-205,7
+207,7
@@
class TestNsDescriptor(TestCase):
self.assertEqual(response.status_code, status.HTTP_500_INTERNAL_SERVER_ERROR)
def test_nsd_content_download_normal(self):
self.assertEqual(response.status_code, status.HTTP_500_INTERNAL_SERVER_ERROR)
def test_nsd_content_download_normal(self):
- with open('nsd_content.txt', 'w
b
') as fp:
+ with open('nsd_content.txt', 'w
t
') as fp:
fp.writelines('test1')
fp.writelines('test2')
NSPackageModel.objects.create(
fp.writelines('test1')
fp.writelines('test2')
NSPackageModel.objects.create(
@@
-220,7
+222,7
@@
class TestNsDescriptor(TestCase):
for data in response.streaming_content:
file_content = '%s%s' % (file_content, data)
self.assertEqual(response.status_code, status.HTTP_200_OK)
for data in response.streaming_content:
file_content = '%s%s' % (file_content, data)
self.assertEqual(response.status_code, status.HTTP_200_OK)
- self.assertEqual(
'test1test2'
, file_content)
+ self.assertEqual(
"b'test1test2'"
, file_content)
os.remove('nsd_content.txt')
def test_nsd_content_download_when_ns_not_exist(self):
os.remove('nsd_content.txt')
def test_nsd_content_download_when_ns_not_exist(self):
@@
-237,7
+239,7
@@
class TestNsDescriptor(TestCase):
self.assertEqual(response.status_code, status.HTTP_500_INTERNAL_SERVER_ERROR)
def test_nsd_content_partial_download_normal(self):
self.assertEqual(response.status_code, status.HTTP_500_INTERNAL_SERVER_ERROR)
def test_nsd_content_partial_download_normal(self):
- with open('nsd_content.txt', 'w
b
') as fp:
+ with open('nsd_content.txt', 'w
t
') as fp:
fp.writelines('test1')
fp.writelines('test2')
NSPackageModel(
fp.writelines('test1')
fp.writelines('test2')
NSPackageModel(
@@
-255,7
+257,7
@@
class TestNsDescriptor(TestCase):
for data in response.streaming_content:
partial_file_content = '%s%s' % (partial_file_content, data)
self.assertEqual(response.status_code, status.HTTP_200_OK)
for data in response.streaming_content:
partial_file_content = '%s%s' % (partial_file_content, data)
self.assertEqual(response.status_code, status.HTTP_200_OK)
- self.assertEqual(
'test2'
, partial_file_content)
+ self.assertEqual(
"b'test2'"
, partial_file_content)
os.remove('nsd_content.txt')
@mock.patch.object(NsDescriptor, 'create')
os.remove('nsd_content.txt')
@mock.patch.object(NsDescriptor, 'create')
@@
-286,9
+288,9
@@
class TestNsDescriptor(TestCase):
@mock.patch.object(NsDescriptor, 'upload')
def test_upload_when_catch_exception(self, mock_upload):
mock_upload.side_effect = TypeError("integer type")
@mock.patch.object(NsDescriptor, 'upload')
def test_upload_when_catch_exception(self, mock_upload):
mock_upload.side_effect = TypeError("integer type")
- with open('nsd_content.txt', 'w
b
') as fp:
+ with open('nsd_content.txt', 'w
t
') as fp:
fp.write('test')
fp.write('test')
- with open('nsd_content.txt', 'r
b
') as fp:
+ with open('nsd_content.txt', 'r
t
') as fp:
response = self.client.put("/api/nsd/v1/ns_descriptors/22/nsd_content", {'file': fp})
self.assertEqual(response.status_code, status.HTTP_500_INTERNAL_SERVER_ERROR)
os.remove('nsd_content.txt')
response = self.client.put("/api/nsd/v1/ns_descriptors/22/nsd_content", {'file': fp})
self.assertEqual(response.status_code, status.HTTP_500_INTERNAL_SERVER_ERROR)
os.remove('nsd_content.txt')