def test_compare_particles_datasets_not_equal(self):
        # given
        particles = Particles(name="test")
        reference = Particles(name="test_ref")

        particle_list = create_particles_with_id()
        bond_list = create_bonds()
        data = create_data_container()

        particles.add_particles(particle_list)
        reference.add_particles(particle_list)

        particles.add_bonds(bond_list)
        reference.add_bonds(bond_list)

        particles.data = data
        reference.data = data

        # when/then
        with self.assertRaises(AssertionError):
            compare_particles_datasets(particles, reference, testcase=self)

        # given
        test_particles = create_particles_with_id()

        particles = Particles(name=reference.name)
        particles.add_particles(test_particles)
        particles.add_bonds(bond_list)
        particles.data = data

        # when/then
        with self.assertRaises(AssertionError):
            compare_particles_datasets(particles, reference, testcase=self)

        # given
        test_bonds = create_bonds()

        particles = Particles(name=reference.name)
        particles.add_particles(particle_list)
        particles.add_bonds(test_bonds)
        particles.data = data

        # when/then
        with self.assertRaises(AssertionError):
            compare_particles_datasets(particles, reference, testcase=self)

        # given
        test_data = DataContainer()

        particles = Particles(name=reference.name)
        particles.add_particles(particle_list)
        particles.add_bonds(bond_list)
        particles.data = test_data

        # when/then
        with self.assertRaises(AssertionError):
            compare_particles_datasets(particles, reference, testcase=self)
Beispiel #2
0
    def test_compare_particles_datasets_not_equal(self):
        # given
        particles = Particles(name="test")
        reference = Particles(name="test_ref")

        particle_list = create_particles_with_id()
        bond_list = create_bonds()
        data = create_data_container()

        particles.add(particle_list)
        reference.add(particle_list)

        particles.add(bond_list)
        reference.add(bond_list)

        particles.data = data
        reference.data = data

        # when/then
        with self.assertRaises(AssertionError):
            compare_particles_datasets(particles, reference, testcase=self)

        # given
        test_particles = create_particles_with_id()

        particles = Particles(name=reference.name)
        particles.add(test_particles)
        particles.add(bond_list)
        particles.data = data

        # when/then
        with self.assertRaises(AssertionError):
            compare_particles_datasets(particles, reference, testcase=self)

        # given
        test_bonds = create_bonds()

        particles = Particles(name=reference.name)
        particles.add(particle_list)
        particles.add(test_bonds)
        particles.data = data

        # when/then
        with self.assertRaises(AssertionError):
            compare_particles_datasets(particles, reference, testcase=self)

        # given
        test_data = DataContainer()

        particles = Particles(name=reference.name)
        particles.add(particle_list)
        particles.add(bond_list)
        particles.data = test_data

        # when/then
        with self.assertRaises(AssertionError):
            compare_particles_datasets(particles, reference, testcase=self)
 def setUp(self):
     self.addTypeEqualityFunc(Bond, partial(compare_bonds, testcase=self))
     self.particle_list = create_particles(restrict=self.supported_cuba())
     self.container = self.container_factory("foo")
     self.container.add_particles(self.particle_list)
     self.bond_list = create_bonds(restrict=self.supported_cuba(), particles=self.particle_list)
     self.ids = self.container.add_bonds(self.bond_list)
 def test_create_bonds(self):
     n = 7
     bonds = create_bonds(n=n)
     self.assertEqual(len(bonds), n)
     uids = set()
     for index, bond in enumerate(bonds):
         self.assertIsInstance(bond, Bond)
         compare_data_containers(
             bond.data, create_data_container(constant=index),
             testcase=self)
         self.assertEqual(len(bond.particles), n)
         uids.update(bond.particles)
     self.assertEqual(len(uids), n*n)
Beispiel #5
0
 def test_create_bonds(self):
     n = 7
     bonds = create_bonds(n=n)
     self.assertEqual(len(bonds), n)
     uids = set()
     for index, bond in enumerate(bonds):
         self.assertIsInstance(bond, Bond)
         compare_data_containers(bond.data,
                                 create_data_container(constant=index),
                                 testcase=self)
         self.assertEqual(len(bond.particles), n)
         uids.update(bond.particles)
     self.assertEqual(len(uids), n * n)
 def test_create_bonds_with_particles(self):
     n = 7
     particles = create_particles(n=100)
     for particle in particles:
         particle.uid = uuid.uuid4()
     bonds = create_bonds(n=n, particles=particles)
     uids = set()
     self.assertEqual(len(bonds), n)
     for index, bond in enumerate(bonds):
         self.assertIsInstance(bond, Bond)
         compare_data_containers(
             bond.data, create_data_container(constant=index),
             testcase=self)
         self.assertEqual(len(bond.particles), n)
         uids.update(bond.particles)
     self.assertLessEqual(len(uids), n**2)
Beispiel #7
0
 def test_create_bonds_with_particles(self):
     n = 7
     particles = create_particles(n=100)
     for particle in particles:
         particle.uid = uuid.uuid4()
     bonds = create_bonds(n=n, particles=particles)
     uids = set()
     self.assertEqual(len(bonds), n)
     for index, bond in enumerate(bonds):
         self.assertIsInstance(bond, Bond)
         compare_data_containers(bond.data,
                                 create_data_container(constant=index),
                                 testcase=self)
         self.assertEqual(len(bond.particles), n)
         uids.update(bond.particles)
     self.assertLessEqual(len(uids), n**2)
    def test_compare_particles_datasets_equal(self):
        # given
        particles = Particles(name="test")
        reference = Particles(name="test")

        particle_list = create_particles_with_id()
        bond_list = create_bonds()
        data = DataContainer()

        particles.add_particles(particle_list)
        reference.add_particles(particle_list)

        particles.add_bonds(bond_list)
        reference.add_bonds(bond_list)

        particles.data = data
        reference.data = data

        # this should pass without problems
        compare_particles_datasets(particles, reference, testcase=self)
Beispiel #9
0
    def test_compare_particles_datasets_equal(self):
        # given
        particles = Particles(name="test")
        reference = Particles(name="test")

        particle_list = create_particles_with_id()
        bond_list = create_bonds()
        data = DataContainer()

        particles.add(particle_list)
        reference.add(particle_list)

        particles.add(bond_list)
        reference.add(bond_list)

        particles.data = data
        reference.data = data

        # this should pass without problems
        compare_particles_datasets(particles, reference, testcase=self)