def test_sample_instantiation(self):
        # Check that values have not been instantiated
        sampler = LazyEmbeddingComposite(MockSampler())
        self.assertIsNone(sampler.embedding)
        self.assertIsNone(sampler.nodelist)
        self.assertIsNone(sampler.edgelist)
        self.assertIsNone(sampler.adjacency)
        self.assertIsNone(sampler.parameters)
        self.assertIsNone(sampler.properties)

        # Set up BQM and sample
        csp = dbc.ConstraintSatisfactionProblem(dbc.BINARY)
        csp.add_constraint(and_gate(['a', 'b', 'c']))
        bqm = dbc.stitch(csp)
        sampler.sample(bqm)

        # Check that values have been populated
        self.assertIsNotNone(sampler.embedding)
        self.assertEqual(sampler.nodelist, ['a', 'b', 'c'])
        self.assertEqual(sampler.edgelist, [('a', 'b'), ('a', 'c'),
                                            ('b', 'c')])
        self.assertEqual(sampler.adjacency, {
            'a': {'b', 'c'},
            'b': {'a', 'c'},
            'c': {'a', 'b'}
        })
        self.assertIsNotNone(sampler.parameters)
        self.assertIsNotNone(sampler.properties)
    def test_same_embedding(self):
        sampler = LazyEmbeddingComposite(MockSampler())

        # Set up Ising and sample
        h = {'a': 1, 'b': 1, 'c': 1}
        J = {('a', 'b'): 3, ('b', 'c'): -2, ('a', 'c'): 1}
        sampler.sample_ising(h, J)

        # Store embedding
        prev_embedding = sampler.embedding

        # Check that the same embedding is used
        csp2 = dbc.ConstraintSatisfactionProblem(dbc.BINARY)
        csp2.add_constraint(or_gate(['a', 'b', 'c']))
        bqm2 = dbc.stitch(csp2)
        sampler.sample(bqm2)

        self.assertEqual(sampler.embedding, prev_embedding)