Skip to content

Commit

Permalink
Merge branch 'develop' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
upsilon committed Jul 18, 2023
2 parents 57fa9fa + 6e862da commit 1421552
Show file tree
Hide file tree
Showing 56 changed files with 2,854 additions and 608 deletions.
10 changes: 10 additions & 0 deletions OpenTween/Resources/ChangeLog.txt → CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
更新履歴

==== Ver 3.7.0(2023/07/19)
* NEW: Cookie使用時のツイート投稿・削除に対応
* NEW: Cookie使用時のリツイートおよびリツイートの取消に対応
* NEW: Cookie使用時の個別ツイートの取得に対応
* NEW: graphqlエンドポイントを使用しているタブでの「前データを取得」に対応
* NEW: graphqlエンドポイントが返すエラーメッセージの表示に対応
* CHG: Google画像検索のURLの変更に対応
* FIX: 発言一覧でDMを選択中に発言詳細部の日時ラベルをクリックするとエラーが発生する不具合を修正
* FIX: Cookie使用時に「Listの発言取得に公式RTを含める」の設定が適用されない不具合を修正

==== Ver 3.6.2(2023/07/07)
* FIX: リプライ制限されたツイートのRTがリストのタイムラインに含まれているとエラーになる不具合を修正

Expand Down
63 changes: 63 additions & 0 deletions OpenTween.Tests/Api/GraphQL/CreateRetweetRequestTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// OpenTween - Client of Twitter
// Copyright (c) 2023 kim_upsilon (@kim_upsilon) <https://upsilo.net/~upsilon/>
// All rights reserved.
//
// This file is part of OpenTween.
//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 3 of the License, or (at your option)
// any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program. If not, see <http://www.gnu.org/licenses/>, or write to
// the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
// Boston, MA 02110-1301, USA.

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Moq;
using OpenTween.Connection;
using Xunit;

namespace OpenTween.Api.GraphQL
{
public class CreateRetweetRequestTest
{
[Fact]
public async Task Send_Test()
{
var responseText = File.ReadAllText("Resources/Responses/CreateRetweet.json");

var mock = new Mock<IApiConnection>();
mock.Setup(x =>
x.PostJsonAsync(It.IsAny<Uri>(), It.IsAny<string>())
)
.Callback<Uri, string>((url, json) =>
{
Assert.Equal(new("https://twitter.com/i/api/graphql/ojPdsZsimiJrUGLR1sjUtA/CreateRetweet"), url);
Assert.Contains(@"""tweet_id"":""12345""", json);
})
.ReturnsAsync(responseText);

var request = new CreateRetweetRequest
{
TweetId = new("12345"),
};

var tweetId = await request.Send(mock.Object).ConfigureAwait(false);
Assert.Equal("1617128268548964354", tweetId.Id);

mock.VerifyAll();
}
}
}
114 changes: 114 additions & 0 deletions OpenTween.Tests/Api/GraphQL/CreateTweetRequestTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
// OpenTween - Client of Twitter
// Copyright (c) 2023 kim_upsilon (@kim_upsilon) <https://upsilo.net/~upsilon/>
// All rights reserved.
//
// This file is part of OpenTween.
//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 3 of the License, or (at your option)
// any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program. If not, see <http://www.gnu.org/licenses/>, or write to
// the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
// Boston, MA 02110-1301, USA.

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Moq;
using OpenTween.Connection;
using Xunit;

namespace OpenTween.Api.GraphQL
{
public class CreateTweetRequestTest
{
[Fact]
public async Task Send_Test()
{
var responseText = File.ReadAllText("Resources/Responses/CreateTweet_CircleTweet.json");

var mock = new Mock<IApiConnection>();
mock.Setup(x =>
x.PostJsonAsync(It.IsAny<Uri>(), It.IsAny<string>())
)
.Callback<Uri, string>((url, json) =>
{
Assert.Equal(new("https://twitter.com/i/api/graphql/tTsjMKyhajZvK4q76mpIBg/CreateTweet"), url);
Assert.Contains(@"""tweet_text"":""tetete""", json);
Assert.DoesNotContain(@"""reply"":", json);
Assert.DoesNotContain(@"""media"":", json);
})
.ReturnsAsync(responseText);

var request = new CreateTweetRequest
{
TweetText = "tetete",
};

var status = await request.Send(mock.Object).ConfigureAwait(false);
Assert.Equal("1680534146492317696", status.IdStr);

mock.VerifyAll();
}

[Fact]
public async Task Send_ReplyTest()
{
var responseText = File.ReadAllText("Resources/Responses/CreateTweet_CircleTweet.json");

var mock = new Mock<IApiConnection>();
mock.Setup(x =>
x.PostJsonAsync(It.IsAny<Uri>(), It.IsAny<string>())
)
.Callback<Uri, string>((url, json) =>
{
Assert.Contains(@"""reply"":{""exclude_reply_user_ids"":[""11111"",""22222""],""in_reply_to_tweet_id"":""12345""}", json);
})
.ReturnsAsync(responseText);

var request = new CreateTweetRequest
{
TweetText = "tetete",
InReplyToTweetId = new("12345"),
ExcludeReplyUserIds = new[] { "11111", "22222" },
};
await request.Send(mock.Object).ConfigureAwait(false);
mock.VerifyAll();
}

[Fact]
public async Task Send_MediaTest()
{
var responseText = File.ReadAllText("Resources/Responses/CreateTweet_CircleTweet.json");

var mock = new Mock<IApiConnection>();
mock.Setup(x =>
x.PostJsonAsync(It.IsAny<Uri>(), It.IsAny<string>())
)
.Callback<Uri, string>((url, json) =>
{
Assert.Contains(@"""media"":{""media_entities"":[{""media_id"":""11111"",""tagged_users"":[]},{""media_id"":""22222"",""tagged_users"":[]}],""possibly_sensitive"":false}", json);
})
.ReturnsAsync(responseText);

var request = new CreateTweetRequest
{
TweetText = "tetete",
MediaIds = new[] { "11111", "22222" },
};
await request.Send(mock.Object).ConfigureAwait(false);
mock.VerifyAll();
}
}
}
59 changes: 59 additions & 0 deletions OpenTween.Tests/Api/GraphQL/DeleteRetweetRequestTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// OpenTween - Client of Twitter
// Copyright (c) 2023 kim_upsilon (@kim_upsilon) <https://upsilo.net/~upsilon/>
// All rights reserved.
//
// This file is part of OpenTween.
//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 3 of the License, or (at your option)
// any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program. If not, see <http://www.gnu.org/licenses/>, or write to
// the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
// Boston, MA 02110-1301, USA.

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Moq;
using OpenTween.Connection;
using Xunit;

namespace OpenTween.Api.GraphQL
{
public class DeleteRetweetRequestTest
{
[Fact]
public async Task Send_Test()
{
var mock = new Mock<IApiConnection>();
mock.Setup(x =>
x.PostJsonAsync(It.IsAny<Uri>(), It.IsAny<string>())
)
.Callback<Uri, string>((url, json) =>
{
Assert.Equal(new("https://twitter.com/i/api/graphql/iQtK4dl5hBmXewYZuEOKVw/DeleteRetweet"), url);
Assert.Contains(@"""source_tweet_id"":""12345""", json);
});

var request = new DeleteRetweetRequest
{
SourceTweetId = new("12345"),
};

await request.Send(mock.Object).ConfigureAwait(false);

mock.VerifyAll();
}
}
}
59 changes: 59 additions & 0 deletions OpenTween.Tests/Api/GraphQL/DeleteTweetRequestTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// OpenTween - Client of Twitter
// Copyright (c) 2023 kim_upsilon (@kim_upsilon) <https://upsilo.net/~upsilon/>
// All rights reserved.
//
// This file is part of OpenTween.
//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 3 of the License, or (at your option)
// any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program. If not, see <http://www.gnu.org/licenses/>, or write to
// the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
// Boston, MA 02110-1301, USA.

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Moq;
using OpenTween.Connection;
using Xunit;

namespace OpenTween.Api.GraphQL
{
public class DeleteTweetRequestTest
{
[Fact]
public async Task Send_Test()
{
var mock = new Mock<IApiConnection>();
mock.Setup(x =>
x.PostJsonAsync(It.IsAny<Uri>(), It.IsAny<string>())
)
.Callback<Uri, string>((url, json) =>
{
Assert.Equal(new("https://twitter.com/i/api/graphql/VaenaVgh5q5ih7kvyVjgtg/DeleteTweet"), url);
Assert.Contains(@"""tweet_id"":""12345""", json);
});

var request = new DeleteTweetRequest
{
TweetId = new("12345"),
};

await request.Send(mock.Object).ConfigureAwait(false);

mock.VerifyAll();
}
}
}
50 changes: 50 additions & 0 deletions OpenTween.Tests/Api/GraphQL/ErrorResponseTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// OpenTween - Client of Twitter
// Copyright (c) 2023 kim_upsilon (@kim_upsilon) <https://upsilo.net/~upsilon/>
// All rights reserved.
//
// This file is part of OpenTween.
//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 3 of the License, or (at your option)
// any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program. If not, see <http://www.gnu.org/licenses/>, or write to
// the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
// Boston, MA 02110-1301, USA.

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xunit;

namespace OpenTween.Api.GraphQL
{
public class ErrorResponseTest
{
[Fact]
public void ThrowIfError_ErrorResponseTest()
{
var responseText = File.ReadAllText("Resources/Responses/Error_NotFound.json");
var exception = Assert.Throws<WebApiException>(() => ErrorResponse.ThrowIfError(responseText));
Assert.Equal("_Missing: No status found with that ID.", exception.Message);
}

[Fact]
public void ThrowIfError_SuccessResponseTest()
{
var responseText = File.ReadAllText("Resources/Responses/TweetDetail.json");
ErrorResponse.ThrowIfError(responseText);
// 通常のレスポンスに対しては WebApiException を発生させない
}
}
}
Loading

0 comments on commit 1421552

Please sign in to comment.