コード例 #1
0
 def test_from_dict__index_exists(self, m_q):
     """Do not allow from_dict_ to create an Index w/ id already in use."""
     old_idx = Index()
     old_idx.id = 42
     m_q.get.return_value = old_idx
     idx = Index()
     idx.id = 42
     idx.position = 3
     idx.name = 'Annual'
     idx.slug = 'annual'
     idx.description = 'Not built to last.'
     d = idx.dict_
     with pytest.raises(ValueError):
         Index.from_dict_(d)
コード例 #2
0
 def test_dict__to_from_dict__(self, m_q):
     """An Index.dict_ fed to Index.from_dict_ creates identical Index."""
     m_q.get.return_value = None
     idx1 = Index()
     idx1.id = 42
     idx1.position = 3
     idx1.name = 'Annual'
     idx1.slug = 'annual'
     idx1.description = 'Not built to last.'
     d = idx1.dict_
     assert Index.from_dict_(d) == idx1