Ejemplo n.º 1
0
 def test__eq__(self):
     """Return True if all columns are the same value."""
     idx1 = Index()
     idx2 = Index()
     idx1.id = 42
     assert idx1 != idx2
     idx2.id = 42
     assert idx1 == idx2
     idx1.position = 3
     idx1.name = 'Annual'
     idx1.slug = 'annual'
     idx1.description = 'Not built to last.'
     assert idx1 != idx2
     idx2.position = 3
     idx2.name = 'Annual'
     idx2.slug = 'annual'
     idx2.description = 'Not built to last.'
     assert idx1 == idx2
Ejemplo n.º 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
Ejemplo n.º 3
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)