def testWeights(self, mock_open, mock_lschema): mock_avrofile = mock.create_autospec(output.DataFileWriter) filename = filename_date(logger, self.globopts['OutputPoem'.lower()], self.jobdir) m = output.AvroWriter(self.globopts['AvroSchemasPoem'.lower()], filename) m.datawrite = mock_avrofile m.write(self.poem) mock_open.assert_called_with(filename, 'w+') mock_lschema.assert_called_with(self.globopts['AvroSchemasPoem'.lower()]) self.assertTrue(mock_avrofile.append.called) self.assertEqual(mock_avrofile.append.call_count, 3) self.assertEqual(mock_avrofile.append.mock_calls.index(mock.call(self.poem[0])), 0) self.assertEqual(mock_avrofile.append.mock_calls.index(mock.call(self.poem[1])), 1) self.assertEqual(mock_avrofile.append.mock_calls.index(mock.call(self.poem[2])), 2)
def testWeights(self, mock_open, mock_lschema): mock_avrofile = mock.create_autospec(output.DataFileWriter) filename = filename_date(logger, self.globopts['OutputPoem'.lower()], self.jobdir) m = output.AvroWriter(self.globopts['AvroSchemasPoem'.lower()], filename) m.datawrite = mock_avrofile m.write(self.poem) mock_open.assert_called_with(filename, 'w+') mock_lschema.assert_called_with( self.globopts['AvroSchemasPoem'.lower()]) self.assertTrue(mock_avrofile.append.called) self.assertEqual(mock_avrofile.append.call_count, 3) self.assertEqual( mock_avrofile.append.mock_calls.index(mock.call(self.poem[0])), 0) self.assertEqual( mock_avrofile.append.mock_calls.index(mock.call(self.poem[1])), 1) self.assertEqual( mock_avrofile.append.mock_calls.index(mock.call(self.poem[2])), 2)