def test_scoped_named(self):
        c1 = self.make_container()
        d1 = ScopedNamedDocument(title=u"Hello", content=u"World", container=c1)
        u = User(username=u'foo')
        self.session.add(d1)
        self.session.commit()
        self.assertEqual(ScopedNamedDocument.get(c1, u'hello'), d1)
        self.assertEqual(d1.name, u'hello')
        self.assertEqual(d1.permissions(user=u), set([]))
        self.assertEqual(d1.permissions(user=u, inherited=set(['view'])), set(['view']))

        d2 = ScopedNamedDocument(title=u"Hello", content=u"Again", container=c1)
        self.session.add(d2)
        self.session.commit()
        self.assertEqual(d2.name, u'hello2')

        c2 = self.make_container()
        d3 = ScopedNamedDocument(title=u"Hello", content=u"Once More", container=c2)
        self.session.add(d3)
        self.session.commit()
        self.assertEqual(d3.name, u'hello')

        c3 = BaseContainer()
        self.session.add(c3)
        d4 = ScopedNamedDocument(title=u"Hello", container=c3)
        self.session.commit()
        self.assertEqual(d4.permissions(user=u), set([]))

        # test insert in BaseScopedNameMixin's upsert
        d4 = ScopedNamedDocument.upsert(c1, u'hello4', title=u'Hello 4', content=u'scoped named doc')
        self.session.commit()
        d4_persisted = ScopedNamedDocument.get(c1, u'hello4')
        self.assertEqual(d4_persisted, d4)
        self.assertEqual(d4_persisted.content, u'scoped named doc')

        # test update in BaseScopedNameMixin's upsert
        d5 = ScopedNamedDocument.upsert(c1, u'hello4', container=c2, title=u'Hello5', content=u'scoped named doc')
        d5.make_name()
        self.session.commit()
        d5_persisted = ScopedNamedDocument.get(c2, u'hello5')
        self.assertEqual(d5_persisted, d5)
        self.assertEqual(d5_persisted.content, u'scoped named doc')

        with self.assertRaises(TypeError) as insert_error:
            ScopedNamedDocument.upsert(c1, u'invalid1', title=u'Invalid1', non_existent_field=u"I don't belong here.")
        self.assertEqual(TypeError, insert_error.expected)

        ScopedNamedDocument.upsert(c1, u'valid1', title=u'Valid1')
        self.session.commit()
        with self.assertRaises(TypeError) as update_error:
            ScopedNamedDocument.upsert(c1, u'valid1', title=u'Invalid1', non_existent_field=u"I don't belong here.")
            self.session.commit()
        self.assertEqual(TypeError, update_error.expected)
Initialization that is performed at the begining of the run (after the device has
dataset/ETHPy150Open hasgeek/coaster/tests/test_models.py/TestCoasterModels.test_scoped_named--crossover with--dataset/ETHPy150Open ARM-software/workload-automation/wlauto/core/device.py/Device.initialize