Ejemplo n.º 1
0
    def test_moc_update(self):
        facility_id = self.db.ensure_facility('moc testing facility')

        moc = MOC(order=5, cells=(1, 2, 3))

        moc_id = self.db.add_moc(facility_id, 'test', 'test', FormatType.PLAIN,
                                 True, moc)
        self.assertIsInstance(moc_id, int)

        self.assertEqual(self.db.update_moc_cell(moc_id, moc, block_pause=0),
                         {5: 'insert'})
        self.assertEqual(self.db._get_moc_from_cell(moc_id), moc)

        moc.add(7, (1001, 1002, 1003))

        self.assertEqual(self.db.update_moc_cell(moc_id, moc, block_pause=0), {
            5: 'unchanged',
            7: 'insert'
        })
        self.assertEqual(self.db._get_moc_from_cell(moc_id), moc)

        moc.add(5, (11, 12, 13))
        moc.remove(7, (1001, 1002, 1003))
        self.assertEqual(self.db.update_moc_cell(moc_id, moc, block_pause=0), {
            5: 'individual',
            7: 'delete'
        })
        self.assertEqual(self.db._get_moc_from_cell(moc_id), moc)

        moc.add(5, (21, 22, 23))
        self.assertEqual(self.db.update_moc_cell(moc_id, moc, block_pause=0),
                         {5: 'individual'})
        self.assertEqual(self.db._get_moc_from_cell(moc_id), moc)

        moc.add(5, (31, 32, 33))
        moc.remove(5, (1, 2, 3, 11, 12, 13))
        self.assertEqual(self.db.update_moc_cell(moc_id, moc, block_pause=0),
                         {5: 'bulk'})
        self.assertEqual(self.db._get_moc_from_cell(moc_id), moc)

        # Check the MOC really ended up as expected.
        self.assertEqual(list(moc), [(5, frozenset((21, 22, 23, 31, 32, 33)))])
Ejemplo n.º 2
0
    def test_moc_update(self):
        facility_id = self.db.ensure_facility('moc testing facility')

        moc = MOC(order=5, cells=(1, 2, 3))

        moc_id = self.db.add_moc(facility_id, 'test', 'test', FormatType.PLAIN,
                                 True, moc)
        self.assertIsInstance(moc_id, int)

        self.assertEqual(self.db.update_moc_cell(moc_id, moc, block_pause=0), {
            5: 'insert'})
        self.assertEqual(self.db._get_moc_from_cell(moc_id), moc)

        moc.add(7, (1001, 1002, 1003))

        self.assertEqual(self.db.update_moc_cell(moc_id, moc, block_pause=0), {
            5: 'unchanged',
            7: 'insert'})
        self.assertEqual(self.db._get_moc_from_cell(moc_id), moc)

        moc.add(5, (11, 12, 13))
        moc.remove(7, (1001, 1002, 1003))
        self.assertEqual(self.db.update_moc_cell(moc_id, moc, block_pause=0), {
            5: 'individual',
            7: 'delete'})
        self.assertEqual(self.db._get_moc_from_cell(moc_id), moc)

        moc.add(5, (21, 22, 23))
        self.assertEqual(self.db.update_moc_cell(moc_id, moc, block_pause=0), {
            5: 'individual'})
        self.assertEqual(self.db._get_moc_from_cell(moc_id), moc)

        moc.add(5, (31, 32, 33))
        moc.remove(5, (1, 2, 3, 11, 12, 13))
        self.assertEqual(self.db.update_moc_cell(moc_id, moc, block_pause=0), {
            5: 'bulk'})
        self.assertEqual(self.db._get_moc_from_cell(moc_id), moc)

        # Check the MOC really ended up as expected.
        self.assertEqual(list(moc), [(5, frozenset((21, 22, 23, 31, 32, 33)))])
Ejemplo n.º 3
0
 def test_remove(self):
     m = MOC(4, (10, 11, 12, 13))
     m.remove(4, (10, 13))
     self.assertEqual(m, MOC(4, (11, 12)))
Ejemplo n.º 4
0
 def test_remove(self):
     m = MOC(4, (10, 11, 12, 13))
     m.remove(4, (10, 13))
     self.assertEqual(m, MOC(4, (11, 12)))