Exemple #1
0
 def test_push_item_positive(
     self,
     is_readme_present_mock,
     path_exists_mock,
     request_api_mock,
     load_yaml_mock,
     compress_mock,
     getcwd_mock,
     rm_tarfiles_mock,
     check_is_author_logged_in_mock,
     open_mock,
 ):
     """Test for push_item positive result."""
     public_id = PublicIdMock(
         name="some-name",
         author="some-author",
         version="{}".format(PublicIdMock.DEFAULT_VERSION),
     )
     push_item(ContextMock(), "some-type", public_id)
     request_api_mock.assert_called_once_with(
         "POST",
         "/some-types/create",
         data={
             "name": "some-name",
             "description": "some-description",
             "version": "some-version",
             "protocols": ["protocol_id"],
         },
         is_auth=True,
         files={"file": "opened_file", "readme": "opened_file"},
     )
Exemple #2
0
    def test_push_item_item_not_found(
        self,
        path_exists_mock,
        request_api_mock,
        load_yaml_mock,
        compress_mock,
        getcwd_mock,
        rm_tarfiles_mock,
        check_is_author_logged_in_mock,
    ):
        """Test for push_item - item not found."""
        with self.assertRaises(ClickException):
            push_item(ContextMock(), "some-type", PublicIdMock())

        request_api_mock.assert_not_called()
Exemple #3
0
 def test_push_item_positive_without_readme(self, is_readme_present_mock,
                                            path_exists_mock,
                                            request_api_mock, *mocks):
     """Test for push_item without readme positive result."""
     public_id = PublicIdMock(
         name="some-name",
         author="some-author",
         version="{}".format(PublicIdMock.DEFAULT_VERSION),
     )
     push_item(ContextMock(), "some-type", public_id)
     request_api_mock.assert_called_once_with(
         "POST",
         "/some-types/create",
         data={
             "name": "some-name",
             "description": "some-description",
             "version": PublicIdMock.DEFAULT_VERSION,
             "protocols": ["protocol_id"],
         },
         is_auth=True,
         files={"file": open("opened_file", "r")},
     )
Exemple #4
0
def skill(ctx: Context, skill_id):
    """Push a skill to the registry or save it in local registry."""
    if ctx.config.get("local"):
        _save_item_locally(ctx, SKILL, skill_id)
    else:
        push_item(ctx, SKILL, skill_id)
Exemple #5
0
def protocol(ctx: Context, protocol_id):
    """Push a protocol to the registry or save it in local registry."""
    if ctx.config.get("local"):
        _save_item_locally(ctx, PROTOCOL, protocol_id)
    else:
        push_item(ctx, PROTOCOL, protocol_id)
Exemple #6
0
def contract(ctx: Context, contract_id):
    """Push a contract to the registry or save it in local registry."""
    if ctx.config.get("local"):
        _save_item_locally(ctx, CONTRACT, contract_id)
    else:
        push_item(ctx, CONTRACT, contract_id)
Exemple #7
0
def connection(ctx: Context, connection_id):
    """Push a connection to the registry or save it in local registry."""
    if ctx.config.get("local"):
        _save_item_locally(ctx, CONNECTION, connection_id)
    else:
        push_item(ctx, CONNECTION, connection_id)
Exemple #8
0
def skill(ctx: Context, skill_id):
    """Push skill to Registry or save it in local packages."""
    if ctx.config.get("local"):
        _save_item_locally(ctx, "skill", skill_id)
    else:
        push_item(ctx, "skill", skill_id)
Exemple #9
0
def protocol(ctx: Context, protocol_id):
    """Push protocol to Registry or save it in local packages."""
    if ctx.config.get("local"):
        _save_item_locally(ctx, "protocol", protocol_id)
    else:
        push_item(ctx, "protocol", protocol_id)
Exemple #10
0
def contract(ctx: Context, contract_id):
    """Push connection to Registry or save it in local packages."""
    if ctx.config.get("local"):
        _save_item_locally(ctx, "contract", contract_id)
    else:
        push_item(ctx, "contract", contract_id)
Exemple #11
0
def connection(ctx: Context, connection_id):
    """Push connection to Registry or save it in local packages."""
    if not ctx.config.get("registry"):
        _save_item_locally(ctx, "connection", connection_id)
    else:
        push_item(ctx, "connection", connection_id)