X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=genericparser%2Fpackages%2Ftests%2Ftest_ns_descriptor.py;h=36933ac8983e3f1a20780488a52d03d53291c36e;hb=aef67d1a1fb076f154f9f7595b54590fc7499ee6;hp=743e181d2f08c66907fb0fe3078c401cf8ef0d8f;hpb=7d0fa869b75947729dbe340f8285bc018fa849c4;p=modeling%2Fetsicatalog.git diff --git a/genericparser/packages/tests/test_ns_descriptor.py b/genericparser/packages/tests/test_ns_descriptor.py index 743e181..36933ac 100644 --- a/genericparser/packages/tests/test_ns_descriptor.py +++ b/genericparser/packages/tests/test_ns_descriptor.py @@ -177,9 +177,9 @@ class TestNsDescriptor(TestCase): userDefinedData=user_defined_data_json, ).save() - with open('nsd_content.txt', 'wb') as fp: + with open('nsd_content.txt', 'wt') as fp: fp.write('test') - with open('nsd_content.txt', 'rb') as fp: + with open('nsd_content.txt', 'rt') as fp: resp = self.client.put( "/api/nsd/v1/ns_descriptors/22/nsd_content", {'file': fp}, @@ -197,9 +197,9 @@ class TestNsDescriptor(TestCase): os.remove('nsd_content.txt') def test_nsd_content_upload_failure(self): - with open('nsd_content.txt', 'wb') as fp: + with open('nsd_content.txt', 'wt') as fp: fp.write('test') - with open('nsd_content.txt', 'rb') as fp: + with open('nsd_content.txt', 'rt') as fp: response = self.client.put( "/api/nsd/v1/ns_descriptors/22/nsd_content", {'file': fp}, @@ -207,7 +207,7 @@ class TestNsDescriptor(TestCase): self.assertEqual(response.status_code, status.HTTP_500_INTERNAL_SERVER_ERROR) def test_nsd_content_download_normal(self): - with open('nsd_content.txt', 'wb') as fp: + with open('nsd_content.txt', 'wt') as fp: fp.writelines('test1') fp.writelines('test2') NSPackageModel.objects.create( @@ -222,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) - 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): @@ -239,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): - with open('nsd_content.txt', 'wb') as fp: + with open('nsd_content.txt', 'wt') as fp: fp.writelines('test1') fp.writelines('test2') NSPackageModel( @@ -257,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) - self.assertEqual('test2', partial_file_content) + self.assertEqual("b'test2'", partial_file_content) os.remove('nsd_content.txt') @mock.patch.object(NsDescriptor, 'create') @@ -288,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") - with open('nsd_content.txt', 'wb') as fp: + with open('nsd_content.txt', 'wt') as fp: fp.write('test') - with open('nsd_content.txt', 'rb') as fp: + with open('nsd_content.txt', 'rt') 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')