-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for python 3.8 deprecation warning and unsupported error (#…
- Loading branch information
Showing
2 changed files
with
155 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
# typed: false | ||
# frozen_string_literal: true | ||
|
||
require "dependabot/python/language" | ||
require "dependabot/ecosystem" | ||
require_relative "../../spec_helper" | ||
|
||
RSpec.describe Dependabot::Python::Language do | ||
subject(:language) { described_class.new(version) } | ||
|
||
describe "#deprecated?" do | ||
let(:version) { "3.8" } | ||
|
||
before do | ||
allow(::Dependabot::Experiments).to receive(:enabled?) | ||
.with(:python_3_8_deprecation_warning) | ||
.and_return(deprecation_enabled) | ||
allow(::Dependabot::Experiments).to receive(:enabled?) | ||
.with(:python_3_8_unsupported_error) | ||
.and_return(unsupported_enabled) | ||
end | ||
|
||
context "when python_3_8_deprecation_warning is enabled and version is deprecated" do | ||
let(:deprecation_enabled) { true } | ||
let(:unsupported_enabled) { false } | ||
|
||
it "returns true" do | ||
expect(language.deprecated?).to be true | ||
end | ||
end | ||
|
||
context "when python_3_8_deprecation_warning is enabled but version is not deprecated" do | ||
let(:version) { "3.13" } | ||
let(:deprecation_enabled) { true } | ||
let(:unsupported_enabled) { false } | ||
|
||
it "returns false" do | ||
expect(language.deprecated?).to be false | ||
end | ||
end | ||
|
||
context "when python_3_8_deprecation_warning is disabled" do | ||
let(:deprecation_enabled) { false } | ||
let(:unsupported_enabled) { false } | ||
|
||
it "returns false" do | ||
expect(language.deprecated?).to be false | ||
end | ||
end | ||
|
||
context "when version is unsupported" do | ||
let(:deprecation_enabled) { true } | ||
let(:unsupported_enabled) { true } | ||
|
||
it "returns false, as unsupported takes precedence" do | ||
expect(language.deprecated?).to be false | ||
end | ||
end | ||
end | ||
|
||
describe "#unsupported?" do | ||
let(:version) { "3.8" } | ||
|
||
before do | ||
allow(::Dependabot::Experiments).to receive(:enabled?) | ||
.with(:python_3_8_unsupported_error) | ||
.and_return(unsupported_enabled) | ||
end | ||
|
||
context "when python_3_8_unsupported_error is enabled and version is unsupported" do | ||
let(:unsupported_enabled) { true } | ||
|
||
it "returns true" do | ||
expect(language.unsupported?).to be true | ||
end | ||
end | ||
|
||
context "when python_3_8_unsupported_error is enabled but version is supported" do | ||
let(:version) { "3.13" } | ||
let(:unsupported_enabled) { true } | ||
|
||
it "returns false" do | ||
expect(language.unsupported?).to be false | ||
end | ||
end | ||
|
||
context "when python_3_8_unsupported_error is disabled" do | ||
let(:unsupported_enabled) { false } | ||
|
||
it "returns false" do | ||
expect(language.unsupported?).to be false | ||
end | ||
end | ||
end | ||
|
||
describe "#raise_if_unsupported!" do | ||
let(:version) { "3.8" } | ||
|
||
before do | ||
allow(Dependabot::Experiments).to receive(:enabled?) | ||
.with(:python_3_8_unsupported_error) | ||
.and_return(unsupported_enabled) | ||
end | ||
|
||
context "when python_3_8_unsupported_error is enabled and version is unsupported" do | ||
let(:unsupported_enabled) { true } | ||
|
||
it "raises a ToolVersionNotSupported error" do | ||
expect { language.raise_if_unsupported! }.to raise_error(Dependabot::ToolVersionNotSupported) | ||
end | ||
end | ||
|
||
context "when python_3_8_unsupported_error is disabled" do | ||
let(:unsupported_enabled) { false } | ||
|
||
it "does not raise an error" do | ||
expect { language.raise_if_unsupported! }.not_to raise_error | ||
end | ||
end | ||
end | ||
end |