Ejemplo n.º 1
0
 def setUp(self):
     self.patcher = patch(
         'subscription_manager.productid.DatabaseDirectory')
     self.mock_dir = self.patcher.start()
     self.temp_dir = tempfile.mkdtemp(
         prefix='subscription-manager-unit-tests-tmp')
     self.mock_dir.return_value = StubDirectory(path=self.temp_dir)
     self.pdb = productid.ProductDatabase()
Ejemplo n.º 2
0
 def test_create_no_dir(self, mock_write):
     # tiny tmp file race here...
     no_dir = "%s/doesnt_exist" % self.temp_dir
     os.mkdir(no_dir)
     with patch('subscription_manager.productid.DatabaseDirectory'
                ) as mock_dir:
         mock_dir.return_value = StubDirectory(path=no_dir)
         mock_dir.write = Mock()
         productid.ProductDatabase()
         self.assertTrue(mock_write.called)