From 637445f98eba4dd44dbcb4d0450a06ea1b9aabda Mon Sep 17 00:00:00 2001 From: matijakolaric Date: Sat, 17 Apr 2021 14:50:09 +0200 Subject: [PATCH] tests back to 100% --- music_publisher/tests/CW210001052_DMP.V21 | 6 ++-- music_publisher/tests/tests.py | 34 ++++++++++++++++++----- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/music_publisher/tests/CW210001052_DMP.V21 b/music_publisher/tests/CW210001052_DMP.V21 index d37f710..ec45e23 100644 --- a/music_publisher/tests/CW210001052_DMP.V21 +++ b/music_publisher/tests/CW210001052_DMP.V21 @@ -7,8 +7,8 @@ ACK0000000300000000201805160910510000100000003NWRTHREE ACK0000000400000000201805160910510000100000004NWRX DMP000025 20180607NP GRT000010000005000000007 GRHISW0000202.100020180607 -ISW0000000000000000MUSIC PUB CARTOONS DMP000001 00000000 UNC000000Y MOD UNSUNS N00000000000 N -ISW0000000100000000MUSIC PUB CARTOONS DMP000001 T123456789500000000 UNC000000Y MOD UNSUNS N00000000000 N -ISW0000000200000000MUSIC PUB CARTOONS DMP000001 T123456789400000000 UNC000000Y MOD UNSUNS N00000000000 N +ISW0000000000000000MUSIC PUB CARTOONS MK000001 T322123423400000000 UNC000000Y MOD UNSUNS N00000000000 N +ISW0000000100000000MUSIC PUB CARTOONS MK000001 T123456789300000000 UNC000000Y MOD UNSUNS N00000000000 N +ISW0000000200000000MUSIC PUB CARTOONS MK000001 T123456789400000000 UNC000000Y MOD UNSUNS N00000000000 N GRT000020000003000000003 TRL000010000008000000014 \ No newline at end of file diff --git a/music_publisher/tests/tests.py b/music_publisher/tests/tests.py index 52b6d33..6c85ca4 100644 --- a/music_publisher/tests/tests.py +++ b/music_publisher/tests/tests.py @@ -1026,8 +1026,11 @@ def test_ack_import_and_work_filters(self): data.update({'acknowledgement_file': mockfile}) response = self.client.post(url, data, follow=False) self.assertEqual(response.status_code, 302) - self.assertEqual( - music_publisher.models.ACKImport.objects.first().report, '') + self.assertIn( + 'A different ISWC exists for work MK000001: THE MODIFIED WORK ' + '(SMITH): T3221234234 (old) vs T1234567893 (new).', + music_publisher.models.ACKImport.objects.first().report + ) """This file has also ISWC codes.""" mock = StringIO() @@ -1044,7 +1047,7 @@ def test_ack_import_and_work_filters(self): # At this point, there is a different ISWC in one of the works response = self.client.post(url, data, follow=False) messages = list(get_messages(response.wsgi_request)) - self.assertEqual(len(messages), 2) + self.assertEqual(len(messages), 3) self.assertIn( 'Conflicting ISWCs found for work', str(messages[0]), @@ -1112,7 +1115,10 @@ def test_ack_import_and_work_filters(self): url = base_url + '?in_cwr=Y&ack_society=21&has_iswc=Y&has_rec=Y' response = self.client.get(url, follow=False) self.assertEqual(response.status_code, 200) - url = base_url + '?in_cwr=N&ack_status=RA&has_iswc=N&has_rec=N' + url = base_url + '?in_cwr=N&ack_society=21&ack_status=RA&has_iswc=N&has_rec=N' + response = self.client.get(url, follow=False) + self.assertEqual(response.status_code, 200) + url = base_url + '?ack_status=RA&has_iswc=N&has_rec=N' response = self.client.get(url, follow=False) self.assertEqual(response.status_code, 200) @@ -1364,6 +1370,20 @@ def test_data_import_and_royalty_calculations(self): # The file must be processed in under 10 seconds self.assertLess((time_after - time_before).total_seconds(), 15) + # TEST BAD + with open(TEST_CWR2_FILENAME) as csvfile: + mock = StringIO() + mock.write(csvfile.read()) + mockfile = InMemoryUploadedFile( + mock, 'statement_file', 'statement.csv', + 'text', 0, None) + url = reverse('royalty_calculation') + response = self.client.get(url) + data = get_data_from_response(response) + data.update({'in_file': mockfile}) + response = self.client.post(url, data, follow=False) + + @override_settings(REQUIRE_SAAN=False, REQUIRE_PUBLISHER_FEE=False) def test_bad_data_import(self): """Test bad data import.""" @@ -1912,9 +1932,9 @@ def test_work(self): ACK0000000400000000201805160910510000100000004NWRX DMP000025 20180607NP GRT000010000005000000007 GRHISW0000202.100020180607 -ISW0000000000000000MUSIC PUB CARTOONS DMP000001 00000000 UNC000000Y MOD UNSUNS N00000000000 N -ISW0000000100000000MUSIC PUB CARTOONS DMP000001 T123456789500000000 UNC000000Y MOD UNSUNS N00000000000 N -ISW0000000200000000MUSIC PUB CARTOONS DMP000001 T123456789400000000 UNC000000Y MOD UNSUNS N00000000000 N +ISW0000000000000000MUSIC PUB CARTOONS MK000001 T322123423400000000 UNC000000Y MOD UNSUNS N00000000000 N +ISW0000000100000000MUSIC PUB CARTOONS MK000001 T123456789300000000 UNC000000Y MOD UNSUNS N00000000000 N +ISW0000000200000000MUSIC PUB CARTOONS XX000001 T123456789400000000 UNC000000Y MOD UNSUNS N00000000000 N GRT000020000003000000003 TRL000010000008000000014"""