def test_no_units_found(self, mock_get_data, mock_units_from_json, mock_get_host_and_protocol):
        # make sure it correctly returns None if there are no units found
        mock_get_data.return_value = {
            'repo1' : {'db': mock.MagicMock(), 'protocol': 'http'},
            'repo2' : {'db': mock.MagicMock(), 'protocol': 'http'},
        }
        mock_units_from_json.return_value = []

        result = releases.find_version(['repo1', 'repo2'], 'foo/bar', '1.0.0')

        self.assertTrue(result is None)
    def test_returns_version(self, mock_get_data, mock_units_from_json, mock_get_host_and_protocol):
        mock_get_data.return_value = {
            'repo1' : {'db': mock.MagicMock(), 'protocol': 'http'},
            'repo2' : {'db': mock.MagicMock(), 'protocol': 'http'},
        }
        mock_units_from_json.return_value = [
            unit_generator(version='2.1.3'),
            unit_generator(version='1.6.2'),
            unit_generator(version='2.0.3'),
            unit_generator(version='3.1.5'),
        ]

        result = releases.find_version(['repo1', 'repo2'], 'foo/bar', '2.0.3')

        self.assertTrue(isinstance(result, Unit))
        self.assertEqual(result.version, '2.0.3')
    def test_calls_units_from_json(self, mock_get_data, mock_units_from_json, mock_get_host_and_protocol):
        mock_get_data.return_value = {
            'repo1' : {'db': mock.MagicMock(), 'protocol': 'http'},
            'repo2' : {'db': mock.MagicMock(), 'protocol': 'http'},
        }
        mock_units_from_json.return_value = []

        result = releases.find_version(['repo1', 'repo2'], 'foo/bar', '1.0.0')

        mock_units_from_json.assert_any_call(
            'foo/bar', mock_get_data.return_value['repo1']['db'],
            'repo1', MOCK_HOST_PROTOCOL['host'], 'http'
        )
        mock_units_from_json.assert_any_call(
            'foo/bar', mock_get_data.return_value['repo2']['db'],
            'repo2', MOCK_HOST_PROTOCOL['host'], 'http'
        )
Beispiel #4
0
    def test_no_units_found(self, mock_get_data, mock_units_from_json,
                            mock_get_host_and_protocol):
        # make sure it correctly returns None if there are no units found
        mock_get_data.return_value = {
            'repo1': {
                'db': mock.MagicMock(),
                'protocol': 'http'
            },
            'repo2': {
                'db': mock.MagicMock(),
                'protocol': 'http'
            },
        }
        mock_units_from_json.return_value = []

        result = releases.find_version(['repo1', 'repo2'], 'foo/bar', '1.0.0')

        self.assertTrue(result is None)
Beispiel #5
0
    def test_calls_units_from_json(self, mock_get_data, mock_units_from_json,
                                   mock_get_host_and_protocol):
        mock_get_data.return_value = {
            'repo1': {
                'db': mock.MagicMock(),
                'protocol': 'http'
            },
            'repo2': {
                'db': mock.MagicMock(),
                'protocol': 'http'
            },
        }
        mock_units_from_json.return_value = []

        result = releases.find_version(['repo1', 'repo2'], 'foo/bar', '1.0.0')

        mock_units_from_json.assert_any_call(
            'foo/bar', mock_get_data.return_value['repo1']['db'], 'repo1',
            MOCK_HOST_PROTOCOL['host'], 'http')
        mock_units_from_json.assert_any_call(
            'foo/bar', mock_get_data.return_value['repo2']['db'], 'repo2',
            MOCK_HOST_PROTOCOL['host'], 'http')
Beispiel #6
0
    def test_returns_version(self, mock_get_data, mock_units_from_json,
                             mock_get_host_and_protocol):
        mock_get_data.return_value = {
            'repo1': {
                'db': mock.MagicMock(),
                'protocol': 'http'
            },
            'repo2': {
                'db': mock.MagicMock(),
                'protocol': 'http'
            },
        }
        mock_units_from_json.return_value = [
            unit_generator(version='2.1.3'),
            unit_generator(version='1.6.2'),
            unit_generator(version='2.0.3'),
            unit_generator(version='3.1.5'),
        ]

        result = releases.find_version(['repo1', 'repo2'], 'foo/bar', '2.0.3')

        self.assertTrue(isinstance(result, Unit))
        self.assertEqual(result.version, '2.0.3')