def test_create_simple_sheet(self): test_file = self.add_file("file.pdf") db.session.commit() data = {"author_name": u"Bach", "arranger_name": u"Bream", "files": [test_file], "instrument_name": u"guitar"} with self.assertRaises(TypeError): Sheet.create_sheet(**data) data = {"author_name": u"Bach", "arranger_name": u"Bream", "files": [test_file], "name": "BWV 1001"} with self.assertRaises(TypeError): Sheet.create_sheet(**data) data = { "author_name": u"Bach", "arranger_name": u"Bream", "files": [test_file], "instrument_name": u"guitar", "name": "BWV 1001", } Sheet.create_sheet(**data) self.assertEqual(len(Sheet.query.all()), 1) test_sheet = Sheet.query.get(1) self.assertEqual(test_sheet.author.name, "Bach") self.assertEqual(test_sheet.arranger.name, "Bream") self.assertIn(test_file, test_sheet.files) guitar = Instrument.query.filter_by(name="guitar").first() self.assertIn(guitar, test_sheet.instruments) names = [i.name for i in test_sheet.names] self.assertIn("BWV 1001", names)
def test_create_sheet(self): # author_name, arranger_name - string parameters, # files - list of file objects, # instrument_names - list of names of instruments, # names - list of sheet names, # parent - sheet object test_file = self.add_file("file.pdf") db.session.commit() data = { "author_name": u"Bach", "arranger_name": u"Bream", "files": [test_file], "instrument_names": [u"guitar"], "names": ["BWV 1001"], } Sheet.create_sheet(**data) self.assertEqual(len(Sheet.query.all()), 1) test_sheet = Sheet.query.get(1) self.assertEqual(test_sheet.author.name, "Bach") self.assertEqual(test_sheet.arranger.name, "Bream") self.assertIn(test_file, test_sheet.files) guitar = Instrument.query.filter_by(name="guitar").first() self.assertIn(guitar, test_sheet.instruments) names = [i.name for i in test_sheet.names] self.assertIn("BWV 1001", names) test_file2 = self.add_file("file.pdf") db.session.commit() data2 = { "author_name": u"Bach", "arranger_name": u"Bream", "files": [test_file2], "instrument_names": [u"guitar"], "names": ["Allegro"], "parent": test_sheet, } test_sheet2 = Sheet.create_sheet(**data2) self.assertEqual(test_sheet2.parent, test_sheet) self.assertIn(test_sheet2, test_sheet.childrens)
def test_create_without_arranger(self): test_file = self.add_file("file.pdf") db.session.commit() data = {"author_name": u"Bach", "files": [test_file], "instrument_name": u"guitar", "name": "BWV 1001"} Sheet.create_sheet(**data) self.assertEqual(len(Sheet.query.all()), 1)