예제 #1
0
파일: test_utils.py 프로젝트: No9/drogulus
 def test_get_whoami_default_path(self):
     """
     Ensure that a dict is returned from reading a file in the default
     location.
     """
     mock_fd = mock.MagicMock
     mock_fd.read = mock.MagicMock(return_value='{}')
     path = os.path.join(data_dir(), 'whoami.json')
     with mock.patch('builtins.open', return_value=mock_fd) as mock_open:
         result = get_whoami()
         self.assertIsInstance(result, dict)
         self.assertEqual({}, result)
         mock_open.assert_called_once_with(path, 'r')
예제 #2
0
 def test_get_whoami_default_path(self):
     """
     Ensure that a dict is returned from reading a file in the default
     location.
     """
     mock_fd = mock.MagicMock
     mock_fd.read = mock.MagicMock(return_value='{}')
     path = os.path.join(data_dir(), 'whoami.json')
     with mock.patch('builtins.open', return_value=mock_fd) as mock_open:
         result = get_whoami()
         self.assertIsInstance(result, dict)
         self.assertEqual({}, result)
         mock_open.assert_called_once_with(path, 'r')
예제 #3
0
파일: test_utils.py 프로젝트: No9/drogulus
 def test_get_whoami_with_path(self):
     """
     Ensure that a dict is returned from reading a file from a given
     location.
     """
     mock_fd = mock.MagicMock
     mock_fd.read = mock.MagicMock(return_value='{}')
     path = '/foo/bar.json'
     with mock.patch('builtins.open', return_value=mock_fd) as mock_open:
         result = get_whoami(path)
         self.assertIsInstance(result, dict)
         self.assertEqual({}, result)
         mock_open.assert_called_once_with(path, 'r')
예제 #4
0
 def test_get_whoami_with_path(self):
     """
     Ensure that a dict is returned from reading a file from a given
     location.
     """
     mock_fd = mock.MagicMock
     mock_fd.read = mock.MagicMock(return_value='{}')
     path = '/foo/bar.json'
     with mock.patch('builtins.open', return_value=mock_fd) as mock_open:
         result = get_whoami(path)
         self.assertIsInstance(result, dict)
         self.assertEqual({}, result)
         mock_open.assert_called_once_with(path, 'r')