Skip to content

Commit

Permalink
remove check and tests with erroneous package matches
Browse files Browse the repository at this point in the history
  • Loading branch information
dave-connors-3 committed Dec 4, 2024
1 parent 3529df4 commit 894b114
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 156 deletions.
17 changes: 4 additions & 13 deletions core/dbt/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import requests

import dbt_common.semver as semver
from dbt_common.ui import green, red, yellow
from dbt_common.ui import green, yellow

PYPI_VERSION_URL = "https://pypi.org/pypi/dbt-core/json"

Expand All @@ -19,7 +19,7 @@ def get_version_information() -> str:

core_msg_lines, core_info_msg = _get_core_msg_lines(installed, latest)
core_msg = _format_core_msg(core_msg_lines)
plugin_version_msg = _get_plugins_msg(installed)
plugin_version_msg = _get_plugins_msg()

msg_lines = [core_msg]

Expand Down Expand Up @@ -97,7 +97,7 @@ def _format_core_msg(lines: List[List[str]]) -> str:
return msg + "\n".join(msg_lines)


def _get_plugins_msg(installed: semver.VersionSpecifier) -> str:
def _get_plugins_msg() -> str:
msg_lines = ["Plugins:"]

plugins = []
Expand All @@ -113,7 +113,7 @@ def _get_plugins_msg(installed: semver.VersionSpecifier) -> str:

if display_update_msg:
update_msg = (
" At least one plugin is out of date or incompatible with dbt-core.\n"
" At least one plugin is out of date with dbt-core.\n"
" You can find instructions for upgrading here:\n"
" https://docs.getdbt.com/docs/installation"
)
Expand All @@ -130,15 +130,6 @@ def _get_plugin_msg_info(

needs_update = False

assert plugin.major is not None
assert plugin.minor is not None
assert core.major is not None
assert core.minor is not None
if plugin.major != core.major or plugin.minor < core.minor:
compatibility_msg = red("Not compatible!")
needs_update = True
return (compatibility_msg, needs_update)

if not latest_plugin:
compatibility_msg = yellow("Could not determine latest version")
return (compatibility_msg, needs_update)
Expand Down
183 changes: 40 additions & 143 deletions tests/unit/test_version.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import dbt.version
from dbt_common.ui import green, red, yellow
from dbt_common.ui import green, yellow


class TestGetVersionInformation:
Expand Down Expand Up @@ -239,7 +239,7 @@ def test_plugin_match_core_behind_latest(self, mocker):
"Plugins:",
f" - foobar: 1.0.0 - {yellow('Update available!')}",
"",
" At least one plugin is out of date or incompatible with dbt-core.",
" At least one plugin is out of date with dbt-core.",
" You can find instructions for upgrading here:",
" https://docs.getdbt.com/docs/installation",
"",
Expand Down Expand Up @@ -269,127 +269,7 @@ def test_plugin_match_core_ahead_latest(self, mocker):
"Plugins:",
f" - foobar: 1.0.0 - {yellow('Update available!')}",
"",
" At least one plugin is out of date or incompatible with dbt-core.",
" You can find instructions for upgrading here:",
" https://docs.getdbt.com/docs/installation",
"",
"",
]
)

assert expected == actual

def test_plugin_diff_core_major_match_latest(self, mocker):
mock_versions(
mocker,
installed="2.0.0",
latest="2.0.0",
plugins={
"foobar": ("1.0.0", "1.0.0"),
},
)

actual = dbt.version.get_version_information()
expected = "\n".join(
[
"Core:",
" - installed: 2.0.0",
f" - latest: 2.0.0 - {green('Up to date!')}",
"",
"Plugins:",
f" - foobar: 1.0.0 - {red('Not compatible!')}",
"",
" At least one plugin is out of date or incompatible with dbt-core.",
" You can find instructions for upgrading here:",
" https://docs.getdbt.com/docs/installation",
"",
"",
]
)

assert expected == actual

def test_plugin_diff_core_major_no_latest(self, mocker):
mock_versions(
mocker,
installed="2.0.0",
latest="2.0.0",
plugins={
"foobar": ("1.0.0", None),
},
)

actual = dbt.version.get_version_information()
expected = "\n".join(
[
"Core:",
" - installed: 2.0.0",
f" - latest: 2.0.0 - {green('Up to date!')}",
"",
"Plugins:",
f" - foobar: 1.0.0 - {red('Not compatible!')}",
"",
" At least one plugin is out of date or incompatible with dbt-core.",
" You can find instructions for upgrading here:",
" https://docs.getdbt.com/docs/installation",
"",
"",
]
)

assert expected == actual

def test_plugin_diff_core_major_ahead_latest(self, mocker):
mock_versions(
mocker,
installed="2.0.0",
latest="2.0.0",
plugins={
"foobar": ("1.0.0", "0.0.1"),
},
)

actual = dbt.version.get_version_information()
expected = "\n".join(
[
"Core:",
" - installed: 2.0.0",
f" - latest: 2.0.0 - {green('Up to date!')}",
"",
"Plugins:",
f" - foobar: 1.0.0 - {red('Not compatible!')}",
"",
" At least one plugin is out of date or incompatible with dbt-core.",
" You can find instructions for upgrading here:",
" https://docs.getdbt.com/docs/installation",
"",
"",
]
)

assert expected == actual

def test_plugin_diff_core_major_behind_latest(self, mocker):
mock_versions(
mocker,
installed="2.0.0",
latest="2.0.0",
plugins={
"foobar": ("1.0.0", "1.1.0"),
},
)

actual = dbt.version.get_version_information()
expected = "\n".join(
[
"Core:",
" - installed: 2.0.0",
f" - latest: 2.0.0 - {green('Up to date!')}",
"",
"Plugins:",
f" - foobar: 1.0.0 - {red('Not compatible!')}",
"",
" At least one plugin is out of date or incompatible with dbt-core.",
" At least one plugin is out of date with dbt-core.",
" You can find instructions for upgrading here:",
" https://docs.getdbt.com/docs/installation",
"",
Expand Down Expand Up @@ -417,11 +297,7 @@ def test_plugin_diff_core_minor_match_latest(self, mocker):
f" - latest: 1.1.0 - {green('Up to date!')}",
"",
"Plugins:",
f" - foobar: 1.0.0 - {red('Not compatible!')}",
"",
" At least one plugin is out of date or incompatible with dbt-core.",
" You can find instructions for upgrading here:",
" https://docs.getdbt.com/docs/installation",
f" - foobar: 1.0.0 - {green('Up to date!')}",
"",
"",
]
Expand All @@ -447,11 +323,7 @@ def test_plugin_diff_core_minor_no_latest(self, mocker):
f" - latest: 1.1.0 - {green('Up to date!')}",
"",
"Plugins:",
f" - foobar: 1.0.0 - {red('Not compatible!')}",
"",
" At least one plugin is out of date or incompatible with dbt-core.",
" You can find instructions for upgrading here:",
" https://docs.getdbt.com/docs/installation",
f" - foobar: 1.0.0 - {yellow('Could not determine latest version')}",
"",
"",
]
Expand All @@ -477,11 +349,7 @@ def test_plugin_diff_core_minor_ahead_latest(self, mocker):
f" - latest: 1.1.0 - {green('Up to date!')}",
"",
"Plugins:",
f" - foobar: 1.0.0 - {red('Not compatible!')}",
"",
" At least one plugin is out of date or incompatible with dbt-core.",
" You can find instructions for upgrading here:",
" https://docs.getdbt.com/docs/installation",
f" - foobar: 1.0.0 - {yellow('Ahead of latest version!')}",
"",
"",
]
Expand Down Expand Up @@ -582,6 +450,37 @@ def test_plugin_diff_plugin_minor_ahead_no_latest(self, mocker):

assert expected == actual

def test_plugin_diff_plugin_minor_behind_core_no_latest(self, mocker):
"""
Now that adapters are decoupled from core, a lower minor version of a plugin (1.8)
is compatible with a higher minor version of core. (1.9)
"""

mock_versions(
mocker,
installed="1.9.0",
latest="1.9.0",
plugins={
"foobar": ("1.8.0", "1.8.0"),
},
)

actual = dbt.version.get_version_information()
expected = "\n".join(
[
"Core:",
" - installed: 1.9.0",
f" - latest: 1.9.0 - {green('Up to date!')}",
"",
"Plugins:",
f" - foobar: 1.8.0 - {green('Up to date!')}",
"",
"",
]
)

assert expected == actual

def test_plugin_diff_core_minor_behind_latest(self, mocker):
mock_versions(
mocker,
Expand All @@ -600,9 +499,9 @@ def test_plugin_diff_core_minor_behind_latest(self, mocker):
f" - latest: 1.1.0 - {green('Up to date!')}",
"",
"Plugins:",
f" - foobar: 1.0.0 - {red('Not compatible!')}",
f" - foobar: 1.0.0 - {yellow('Update available!')}",
"",
" At least one plugin is out of date or incompatible with dbt-core.",
" At least one plugin is out of date with dbt-core.",
" You can find instructions for upgrading here:",
" https://docs.getdbt.com/docs/installation",
"",
Expand All @@ -621,7 +520,6 @@ def test_plugins_various(self, mocker):
"foobar": ("2.1.0", "2.1.0"),
"bazqux": ("2.1.0", None),
"quuux": ("2.1.0", "2.1.0"),
"corge": ("22.21.20", "22.21.21"),
"grault": ("2.1.0", "2.1.1"),
"garply": ("2.1.0-b1", None),
},
Expand All @@ -638,11 +536,10 @@ def test_plugins_various(self, mocker):
f" - foobar: 2.1.0 - {green('Up to date!')}",
f" - bazqux: 2.1.0 - {yellow('Could not determine latest version')}",
f" - quuux: 2.1.0 - {green('Up to date!')}",
f" - corge: 22.21.20 - {red('Not compatible!')}",
f" - grault: 2.1.0 - {yellow('Update available!')}",
f" - garply: 2.1.0-b1 - {yellow('Could not determine latest version')}",
"",
" At least one plugin is out of date or incompatible with dbt-core.",
" At least one plugin is out of date with dbt-core.",
" You can find instructions for upgrading here:",
" https://docs.getdbt.com/docs/installation",
"",
Expand Down

0 comments on commit 894b114

Please sign in to comment.