Skip to content

Commit

Permalink
correct unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosmarxm committed Mar 2, 2022
1 parent 572fe82 commit 396e3db
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,21 @@
from airbyte_cdk.sources import AbstractSource
from airbyte_cdk.sources.streams import Stream

from .streams import Addon, AttachedItem, Coupon, CreditNote, Customer, Event, Invoice, Item, ItemPrice, Order, Plan, Subscription, Transaction
from .streams import (
Addon,
AttachedItem,
Coupon,
CreditNote,
Customer,
Event,
Invoice,
Item,
ItemPrice,
Order,
Plan,
Subscription,
Transaction,
)


class SourceChargebee(AbstractSource):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ def request_params(self, **kwargs) -> MutableMapping[str, Any]:
params["sort_by[asc]"] = "created_at"
return params


class CreditNote(IncrementalChargebeeStream):
"""
API docs: https://apidocs.chargebee.com/docs/api/credit_notes?prod_cat_ver=2#list_credit_notes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,32 @@ def test_check_error_v2(test_config_v2):
def test_source_streams_v1(test_config_v1):
source = SourceChargebee()
streams = source.streams(test_config_v1)
assert len(streams) == 9
assert len(streams) == 10
actual_stream_names = {stream.name for stream in streams}
expected_stream_names = {"coupon", "customer", "event", "invoice", "order", "subscription", "addon", "plan", "transaction"}
expected_stream_names = {
"coupon",
"credit_note",
"customer",
"event",
"invoice",
"order",
"subscription",
"addon",
"plan",
"transaction",
}
assert expected_stream_names == actual_stream_names


@responses.activate
def test_source_streams_v2(test_config_v2):
source = SourceChargebee()
streams = source.streams(test_config_v2)
assert len(streams) == 10
assert len(streams) == 11
actual_stream_names = {stream.name for stream in streams}
expected_stream_names = {
"coupon",
"credit_note",
"customer",
"event",
"invoice",
Expand Down

1 comment on commit 396e3db

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SonarQube Report

SonarQube report for Airbyte Connectors Source Chargebee(#10811)

Measures

Name Value Name Value Name Value
Lines to Cover 200 Duplicated Blocks 0 Bugs 0
Duplicated Lines (%) 0.0 Lines of Code 259 Vulnerabilities 0
Security Rating A Coverage 84.5 Code Smells 17
Reliability Rating A Quality Gate Status OK Blocker Issues 0
Critical Issues 1 Major Issues 0 Minor Issues 16

Detected Issues

Rule File Description Message
python:S1192 (CRITICAL) source_chargebee/streams.py:168 String literals should not be duplicated Define a constant instead of duplicating this literal "sort_by[asc]" 3 times.
python:mypy_override (MINOR) source_chargebee/streams.py:304 Check that method override is compatible with base class Signature of "request_params" incompatible with supertype "IncrementalChargebeeStream" . Code line: def request_params(self, **kwargs) -> MutableMapping[str, Any]:
python:mypy_override (MINOR) source_chargebee/streams.py:304 Check that method override is compatible with base class Signature of "request_params" incompatible with supertype "ChargebeeStream" . Code line: def request_params(self, **kwargs) -> MutableMapping[str, Any]:
python:mypy_override (MINOR) source_chargebee/streams.py:319 Check that method override is compatible with base class Signature of "request_params" incompatible with supertype "IncrementalChargebeeStream" . Code line: def request_params(self, **kwargs) -> MutableMapping[str, Any]:
python:mypy_override (MINOR) source_chargebee/streams.py:319 Check that method override is compatible with base class Signature of "request_params" incompatible with supertype "ChargebeeStream" . Code line: def request_params(self, **kwargs) -> MutableMapping[str, Any]:
python:mypy_no_any_return (MINOR) source_chargebee/streams.py:126 Reject returning value with "Any" type if return type is not "Any" Returning Any from function declared to return "int" . Code line: return start_point
python:mypy_override (MINOR) source_chargebee/streams.py:128 Check that method override is compatible with base class Signature of "parse_response" incompatible with supertype "ChargebeeStream" . Code line: def parse_response(
python:mypy_arg_type (MINOR) source_chargebee/streams.py:131 Check argument types in calls Argument "stream_state" to "get_starting_point" of "SemiIncrementalChargebeeStream" has incompatible type "Optional[Mapping[str, Any]]"; expected "Mapping[str, Any]" . Code line: ...ing_point = self.get_starting_point(stream_state=stream_state, item_id...
python:mypy_index (MINOR) source_chargebee/streams.py:131 Check indexing operations Value of type "Optional[Mapping[str, Any]]" is not indexable . Code line: ...tarting_point(stream_state=stream_state, item_id=stream_slice["item_id...
python:mypy_attr_defined (MINOR) source_chargebee/streams.py:144 Check that attribute exists "MutableMapping[str, Any]" has no attribute "copy" . Code line: current_stream_state = current_stream_state.copy()
python:mypy_type_var (MINOR) source_chargebee/streams.py:150 Check that type variable values are valid Value of type variable "SupportsRichComparisonT" of "max" cannot be "Optional[Any]" . Code line: max_value = max(current_state_value, latest_cursor_value)
python:mypy_override (MINOR) source_chargebee/streams.py:179 Check that method override is compatible with base class Signature of "parse_response" incompatible with supertype "SemiIncrementalChargebeeStream" . Code line: def parse_response(self, list_result: ListResult, **kwargs) -> Ite...
python:mypy_index (MINOR) source_chargebee/streams.py:282 Check indexing operations Value of type "Optional[Mapping[str, Any]]" is not indexable . Code line: return self.api.list(id=stream_slice["item_id"], params=params...
python:mypy_import (MINOR) source_chargebee/rate_limiting.py:11 Require that imported module can be found or has stubs Library stubs not installed for "requests" (or incompatible with Python 3.7) . Code line: from requests import codes
python:mypy_call_overload (MINOR) source_chargebee/source.py:35 Check that an overload variant matches arguments No overload variant of "next" matches argument type "Iterable[Mapping[str, Any]]" . Code line: next(subscription_stream.read_records(sync_mode=SyncMode.f...
python:mypy_return (MINOR) source_chargebee/streams.py:40 Check that function always returns a value Missing return statement . Code line: def next_page_token(self, list_result: ListResult) -> Optional[Map...
python:mypy_valid_type (MINOR) source_chargebee/source.py:30 Check that type (annotation) is valid Function "builtins.any" is not valid as a type . Code line: ...nnection(self, logger, config: Mapping[str, Any]) -> Tuple[bool, any]:

Coverage (84.5%)

File Coverage File Coverage
source_chargebee/init.py 100.0 source_chargebee/rate_limiting.py 63.2
source_chargebee/source.py 100.0 source_chargebee/streams.py 84.4

Please sign in to comment.