Example #1
0
    def test_reads_web_if_no_file(self, get, mock_open):
        def raise_error(__):
            raise IOError()

        mock_open.side_effect = raise_error
        get.return_value.text = "hello\nworld"

        assert get_vhost_db() == ["hello", "world"]
Example #2
0
    def test_reads_web_if_no_file(self, get, mock_open):
        def raise_error(__):
            raise IOError()

        mock_open.side_effect = raise_error
        get.return_value.text = 'hello\nworld'

        assert get_vhost_db() == ['hello', 'world']
Example #3
0
 def test_reads_file_if_exists(self):
     with mock.patch("builtins.open", mock.mock_open()) as mock_open:
         lines = ["hello", "world"]
         mock_open.return_value.__iter__.return_value = lines
         assert get_vhost_db() == lines
Example #4
0
 def test_reads_file(self):
     with mock.patch('builtins.open', mock.mock_open()) as mock_open:
         text = 'hello\nworld\n'
         mock_open.return_value.read.return_value = text
         assert get_vhost_db() == text.splitlines()