Beispiel #1
0
    def test_get_version_info_missing(self, list_versions):
        """
        Tests that we handle when the version can't be found
        """

        list_versions.return_value = {
            'latest':   {},
            'versions': [],
        }

        Server.get_version_info('nope')
Beispiel #2
0
    def test_get_version_info_network(self, list_versions, requests_get):
        """
        Tests that we handle when there's a networking problem
        """

        list_versions.return_value = copy.deepcopy(SAMPLE_VERSIONS)

        mock_response = unittest.mock.Mock(spec = requests.Response)
        mock_response.ok = False

        requests_get.return_value = mock_response

        Server.get_version_info('my_release')
Beispiel #3
0
    def test_get_version_info_latest(self, list_versions, requests_get):
        """
        Tests that we can get the infor for the latest server version by default
        """

        list_versions.return_value = SAMPLE_VERSIONS

        version_info = SAMPLE_VERSION

        mock_response = unittest.mock.Mock(spec = requests.Response)
        mock_response.ok = True
        mock_response.json.return_value = version_info

        requests_get.return_value = mock_response

        version = Server.get_version_info()

        requests_get.assert_called_with('http://example.com/mc/my_release.json')

        self.assertDictEqual(
            version_info,
            version,
            'Version metadata did not match expected',
        )
Beispiel #4
0
    def test_get_version_info(self, list_versions, requests_get):
        """
        Tests that we can get the information about a specific server version
        """

        list_versions.return_value = copy.deepcopy(SAMPLE_VERSIONS)

        version_info = SAMPLE_VERSION

        mock_response = unittest.mock.Mock(spec = requests.Response)
        mock_response.ok = True
        mock_response.json.return_value = version_info

        requests_get.return_value = mock_response

        version = Server.get_version_info('my_release')

        requests_get.assert_called_with('http://example.com/mc/my_release.json')

        self.assertDictEqual(
            version_info,
            version,
            'The version metadata did not match the expected',
        )