def tearDownClass(cls) -> None:
     connection = Connection('simple')
     connection.disconnect()
     connection = Connection('linked')
     connection.disconnect()
     connection = Connection('chained')
     connection.disconnect()
Ejemplo n.º 2
0
 def setUpClass(cls) -> None:
     connection = Connection('simple')
     connection.set_url('mongodb://localhost:27017/simple')
     connection.connect()
     connection = Connection('linked')
     connection.set_url('mongodb://localhost:27017/linked')
     connection.connect()
Ejemplo n.º 3
0
 def setUp(self) -> None:
     collection = Connection.get_collection(SimpleSong)
     collection.delete_many({})
     collection = Connection.get_collection(SimpleArtist)
     collection.delete_many({})
     collection = Connection.get_collection(LinkedAuthor)
     collection.delete_many({})
     collection = Connection.get_collection(LinkedPost)
     collection.delete_many({})
     collection = Connection.get_collection(LinkedProfile)
     collection.delete_many({})
     collection = Connection.get_collection(LinkedUser)
     collection.delete_many({})
     collection = Connection.get_collection(LinkedStudent)
     collection.delete_many({})
     collection = Connection.get_collection(LinkedCourse)
     collection.delete_many({})
     collection = Connection('linked').collection('linkedcoursesstudents'
                                                  'linkedstudentscourses')
     collection.delete_many({})
     collection = Connection.get_collection(SimpleRecord)
     collection.delete_many({})
     collection = Connection.get_collection(LinkedAlbum)
     collection.delete_many({})
     collection = Connection.get_collection(LinkedArtist)
     collection.delete_many({})
     collection = Connection('linked').collection(
         'linkedalbumsartistslinkedartistsalbums')
     collection.delete_many({})
     collection = Connection.get_collection(LinkedSong)
     collection.delete_many({})
     collection = Connection.get_collection(LinkedSinger)
     collection.delete_many({})
Ejemplo n.º 4
0
 def test_many_many_unlink_is_saved(self):
     course1 = LinkedCourse(name='C1')
     course2 = LinkedCourse(name='C2')
     student1 = LinkedStudent(name='S1')
     student2 = LinkedStudent(name='S2')
     course1.students = [student1, student2]
     course2.students = [student1, student2]
     course1.save()
     course1.students.remove(student1)
     course1.save()
     collname = 'linkedcoursesstudentslinkedstudentscourses'
     collection = Connection('linked').collection(collname)
     self.assertEqual(collection.count_documents({}), 3)
Ejemplo n.º 5
0
 def test_many_many_can_be_nullified(self):
     course1 = LinkedCourse(name='C1')
     course2 = LinkedCourse(name='C2')
     student1 = LinkedStudent(name='S1')
     student2 = LinkedStudent(name='S2')
     course1.students = [student1, student2]
     course2.students = [student1, student2]
     course1.save() # this triggers save also for course2
     collname = 'linkedcoursesstudentslinkedstudentscourses'
     collection = Connection('linked').collection(collname)
     self.assertEqual(collection.count_documents({}), 4)
     course1.delete()
     self.assertEqual(collection.count_documents({}), 2)
Ejemplo n.º 6
0
 def test_many_many_denies_deletion(self):
     c1 = LinkedCompany(name='C1')
     c2 = LinkedCompany(name='C2')
     o1 = LinkedOwner(name='O1')
     o2 = LinkedOwner(name='O2')
     c1.owners = [o1, o2]
     c2.owners = [o1, o2]
     o1.save()
     collection = Connection.get_collection(LinkedCompany)
     self.assertEqual(collection.count_documents({}), 2)
     collection = Connection.get_collection(LinkedOwner)
     self.assertEqual(collection.count_documents({}), 2)
     collection = Connection('linked').collection('linkedcompaniesowners'
                                                  'linkedownerscompanies')
     self.assertEqual(collection.count_documents({}), 4)
     self.assertRaises(DeletionDeniedException, o1.delete)
     collection = Connection.get_collection(LinkedCompany)
     self.assertEqual(collection.count_documents({}), 2)
     collection = Connection.get_collection(LinkedOwner)
     self.assertEqual(collection.count_documents({}), 2)
     collection = Connection('linked').collection('linkedcompaniesowners'
                                                  'linkedownerscompanies')
     self.assertEqual(collection.count_documents({}), 4)
Ejemplo n.º 7
0
 def test_many_many_cascade_delete(self):
     soldier1 = LinkedSoldier(name='S1')
     soldier2 = LinkedSoldier(name='S2')
     bomb1 = LinkedBomb(name='B1')
     bomb2 = LinkedBomb(name='B2')
     soldier1.bombs = [bomb1, bomb2]
     soldier2.bombs = [bomb1, bomb2]
     soldier1.save()
     soldier2.save()
     collection = Connection.get_collection(LinkedSoldier)
     self.assertEqual(collection.count_documents({}), 2)
     collection = Connection.get_collection(LinkedBomb)
     self.assertEqual(collection.count_documents({}), 2)
     collection = Connection('linked').collection('linkedbombssoldiers'
                                                  'linkedsoldiersbombs')
     self.assertEqual(collection.count_documents({}), 4)
     soldier1.delete()
     collection = Connection.get_collection(LinkedSoldier)
     self.assertEqual(collection.count_documents({}), 0)
     collection = Connection.get_collection(LinkedBomb)
     self.assertEqual(collection.count_documents({}), 0)
     collection = Connection('linked').collection('linkedbombssoldiers'
                                                  'linkedsoldiersbombs')
     self.assertEqual(collection.count_documents({}), 0)
Ejemplo n.º 8
0
 def setUp(self) -> None:
     collection = Connection.get_collection(PLUser)
     collection.delete_many({})
     collection = Connection.get_collection(PLArticle)
     collection.delete_many({})
     # collection = Connection.get_collection(LLPLUser)
     # collection.delete_many({})
     # collection = Connection.get_collection(LLPLArticle)
     # collection.delete_many({})
     collection = Connection.get_collection(LJPLUser)
     collection.delete_many({})
     collection = Connection.get_collection(LJPLArticle)
     collection.delete_many({})
     collection = Connection('preload').collection(
         'ljplarticlesauthorsljplusersarticles')
     collection.delete_many({})
 def setUp(self) -> None:
     collection = Connection.get_collection(LinkedAccount)
     collection.delete_many({})
     collection = Connection.get_collection(LinkedBalance)
     collection.delete_many({})
     collection = Connection.get_collection(LinkedSong)
     collection.delete_many({})
     collection = Connection.get_collection(LinkedSinger)
     collection.delete_many({})
     collection = Connection.get_collection(LinkedAlbum)
     collection.delete_many({})
     collection = Connection.get_collection(LinkedArtist)
     collection.delete_many({})
     collection = Connection('linked').collection('linkedalbumsartists'
                                                  'linkedartistsalbums')
     collection.delete_many({})
Ejemplo n.º 10
0
 def test_many_many_cascade_deny_triggers_partial_deletion(self):
     c1 = LinkedCompany(name='C1')
     c2 = LinkedCompany(name='C2')
     o1 = LinkedOwner(name='O1')
     o2 = LinkedOwner(name='O2')
     c1.owners = [o1, o2]
     c2.owners = [o1, o2]
     c1.save()
     c1.delete()
     collection = Connection.get_collection(LinkedCompany)
     self.assertEqual(collection.count_documents({}), 1)
     collection = Connection.get_collection(LinkedOwner)
     self.assertEqual(collection.count_documents({}), 2)
     collection = Connection('linked').collection('linkedcompaniesowners'
                                                  'linkedownerscompanies')
     self.assertEqual(collection.count_documents({}), 2)
 def setUp(self) -> None:
     collection = Connection.get_collection(SimpleSong)
     collection.delete_many({})
     collection = Connection.get_collection(SimpleArtist)
     collection.delete_many({})
     collection = Connection.get_collection(LinkedAuthor)
     collection.delete_many({})
     collection = Connection.get_collection(LinkedPost)
     collection.delete_many({})
     collection = Connection.get_collection(LinkedProfile)
     collection.delete_many({})
     collection = Connection.get_collection(LinkedUser)
     collection.delete_many({})
     collection = Connection.get_collection(LinkedStudent)
     collection.delete_many({})
     collection = Connection.get_collection(LinkedCourse)
     collection.delete_many({})
     collection = Connection('linked').collection('linkedcoursesstudents'
                                                  'linkedstudentscourses')
     collection.delete_many({})
     collection = Connection.get_collection(ChainedUser)
     collection.delete_many({})
     collection = Connection.get_collection(ChainedProfile)
     collection.delete_many({})
     collection = Connection.get_collection(ChainedAddress)
     collection.delete_many({})
     collection = Connection.get_collection(LinkedSong)
     collection.delete_many({})
     collection = Connection.get_collection(LinkedSinger)
     collection.delete_many({})
     collection = Connection.get_collection(TodoList)
     collection.delete_many({})
     collection = Connection.get_collection(TodoListOwner)
     collection.delete_many({})
     collection = Connection.get_collection(PopSong)
     collection.delete_many({})
     collection = Connection.get_collection(PopSinger)
     collection.delete_many({})
     collection = Connection.get_collection(HiphopSong)
     collection.delete_many({})
     collection = Connection.get_collection(HiphopSinger)
     collection.delete_many({})
     collection = Connection.get_collection(MusicProduct)
     collection.delete_many({})
     collection = Connection.get_collection(MusicUser)
     collection.delete_many({})
Ejemplo n.º 12
0
 def setUp(self) -> None:
     collection = Connection.get_collection(SimpleStrId)
     collection.delete_many({})
     collection = Connection.get_collection(LinkedStrIdAuthor)
     collection.delete_many({})
     collection = Connection.get_collection(LinkedStrIdArticle)
     collection.delete_many({})
     collection = Connection.get_collection(LinkedStrIdSinger)
     collection.delete_many({})
     collection = Connection.get_collection(LinkedStrIdSong)
     collection.delete_many({})
     collection = Connection.get_collection(LinkedStrIdUser)
     collection.delete_many({})
     collection = Connection.get_collection(LinkedStrIdProduct)
     collection.delete_many({})
     collection = Connection('linked').collection(
         join_table_name(LinkedStrIdUser.cdef.field_named('products')))
     collection.delete_many({})
Ejemplo n.º 13
0
 def tearDownClass(cls) -> None:
     connection = Connection('simple')
     connection.disconnect()
 def tearDownClass(cls) -> None:
     connection = Connection('linked')
     connection.disconnect()
Ejemplo n.º 15
0
 def setUp(self) -> None:
     collection = Connection.get_collection(SimpleSong)
     collection.delete_many({})
     collection = Connection.get_collection(SimpleArtist)
     collection.delete_many({})
     collection = Connection.get_collection(LinkedAuthor)
     collection.delete_many({})
     collection = Connection.get_collection(LinkedPost)
     collection.delete_many({})
     collection = Connection.get_collection(LinkedUser)
     collection.delete_many({})
     collection = Connection.get_collection(LinkedProfile)
     collection.delete_many({})
     collection = Connection.get_collection(LinkedStudent)
     collection.delete_many({})
     collection = Connection.get_collection(LinkedCourse)
     collection.delete_many({})
     collection = Connection('linked').collection('linkedcoursesstudents'
                                                  'linkedstudentscourses')
     collection.delete_many({})
     collection = Connection.get_collection(LinkedOrder)
     collection.delete_many({})
     collection = Connection.get_collection(LinkedBuyer)
     collection.delete_many({})
     collection.delete_many({})
     collection = Connection.get_collection(LinkedCOrder)
     collection.delete_many({})
     collection = Connection.get_collection(LinkedCBuyer)
     collection.delete_many({})
     collection = Connection.get_collection(LinkedAccount)
     collection.delete_many({})
     collection = Connection.get_collection(LinkedBalance)
     collection.delete_many({})
     collection = Connection.get_collection(LinkedBomb)
     collection.delete_many({})
     collection = Connection.get_collection(LinkedSoldier)
     collection.delete_many({})
     collection = Connection('linked').collection('linkedbombssoldiers'
                                                  'linkedsoldiersbombs')
     collection.delete_many({})
     collection = Connection.get_collection(LinkedCProfile)
     collection.delete_many({})
     collection = Connection.get_collection(LinkedDUser)
     collection.delete_many({})
     collection = Connection.get_collection(LinkedDProfile)
     collection.delete_many({})
     collection = Connection.get_collection(LinkedCUser)
     collection.delete_many({})
     collection = Connection.get_collection(LinkedNote)
     collection.delete_many({})
     collection = Connection.get_collection(LinkedNotebook)
     collection.delete_many({})
     collection = Connection.get_collection(LinkedRNote)
     collection.delete_many({})
     collection = Connection.get_collection(LinkedRNotebook)
     collection.delete_many({})
     collection = Connection.get_collection(LinkedCompany)
     collection.delete_many({})
     collection = Connection.get_collection(LinkedOwner)
     collection.delete_many({})
     collection = Connection('linked').collection('linkedcompaniesowners'
                                                  'linkedownerscompanies')
     collection.delete_many({})
Ejemplo n.º 16
0
 def setUpClass(cls) -> None:
     connection = Connection('preload')
     connection.set_url('mongodb://localhost:27017/preload')
     connection.connect()
Ejemplo n.º 17
0
 def tearDownClass(cls) -> None:
     connection = Connection('preload')
     connection.disconnect()