Beispiel #1
0
 def test_get_wantslist_items(self):
     mock_oauth = Mock(spec=OAuth1Session)
     mock_oauth.get = MagicMock(return_value=MockResponse(
         TestCommon.cardmarket_get_wantslist_items, 200, "testing ok"))
     wantslist_id = 2789285
     result = self.api.get_wantslist_items(wantslist_id, mock_oauth)
     self.assertEqual(result, TestCommon.get_wantslist_items)
Beispiel #2
0
    def test_delete_stock(self):
        mock_oauth = Mock(spec=OAuth1Session)
        mock_oauth.delete = MagicMock(return_value=MockResponse(
            TestCommon.get_stock_result, 200, "testing ok"))

        result = self.api.delete_stock(TestCommon.get_stock_result, mock_oauth)
        self.assertEqual(len(result), 3)
Beispiel #3
0
 def test_get_expansions(self):
     test_json = json.loads('{"test": "test"}')
     mock_oauth = Mock(spec=OAuth1Session)
     mock_oauth.get = MagicMock(
         return_value=MockResponse(test_json, 200, "testing ok"))
     game_id = 1
     self.assertEqual(self.api.get_expansions(game_id, mock_oauth),
                      test_json)
Beispiel #4
0
    def test_get_articles(self):
        mock_oauth = Mock(spec=OAuth1Session)
        mock_oauth.get = MagicMock(return_value=MockResponse(
            TestCommon.cardmarket_find_user_articles_result, 200,
            "testing ok"))
        product_id = 1

        result = self.api.get_articles(product_id, 0, mock_oauth)
        self.assertEqual(result[0]["comments"], "x")

        mock_oauth.get = MagicMock(return_value=MockResponse(
            TestCommon.cardmarket_find_user_articles_result, 206,
            "partial content"))
        product_id = 1

        result = self.api.get_articles(product_id, 0, mock_oauth)
        self.assertEqual(result[0]["comments"], "x")
Beispiel #5
0
    def test_get_articles_in_shoppingcarts(self):
        test_json = json.loads('{"test": "test"}')
        mock_oauth = Mock(spec=OAuth1Session)
        mock_oauth.get = MagicMock(
            return_value=MockResponse(test_json, 200, "testing ok"))

        self.assertEqual(self.api.get_articles_in_shoppingcarts(mock_oauth),
                         test_json)
Beispiel #6
0
    def test_no_results(self, mock):
        mock_oauth = Mock(spec=OAuth1Session)
        mock_oauth.get = MagicMock(
            return_value=MockResponse(None, 204, "testing No Result 204"))

        empty_response = self.api.get_expansions(1, mock_oauth)
        mock.assert_called_with(
            "[Cardmarket API] No results found. https://api.cardmarket.com/ws/v2.0/output.json/games/1/expansions"
        )
Beispiel #7
0
    def test_set_display_language(self):
        mock_oauth = Mock(spec=OAuth1Session)
        mock_oauth.put = MagicMock(return_value=MockResponse(
            TestCommon.fake_account_data, 200, "testing ok"))
        display_language = 1

        result = self.api.set_display_language(display_language, mock_oauth)
        self.assertEqual(result["account"]["idDisplayLanguage"],
                         str(display_language).lower())
Beispiel #8
0
 def test_find_stock_article(self):
     mock_oauth = Mock(spec=OAuth1Session)
     mock_oauth.get = MagicMock(return_value=MockResponse(
         TestCommon.cardmarket_find_user_articles_result, 200,
         "testing ok"))
     name = "test"
     game_id = 1
     result = self.api.find_stock_article(name, game_id, mock_oauth)
     self.assertEqual(result[0]["comments"], "x")
Beispiel #9
0
    def test_set_vacation_status(self):
        mock_oauth = Mock(spec=OAuth1Session)
        mock_oauth.put = MagicMock(return_value=MockResponse(
            TestCommon.fake_account_data, 200, "testing ok"))
        vacation_status = True

        result = self.api.set_vacation_status(vacation_status, mock_oauth)
        self.assertEqual(result["message"],
                         "Successfully set the account on vacation.")
        self.assertEqual(result["account"]["onVacation"], vacation_status)
Beispiel #10
0
 def test_find_product(self):
     mock_oauth = Mock(spec=OAuth1Session)
     mock_oauth.get = MagicMock(return_value=MockResponse(
         TestCommon.fake_product_response, 200, "testing ok"))
     search_string = "test"
     result = self.api.find_product(search_string, mock_oauth)
     self.assertEqual(
         result["idProduct"],
         TestCommon.fake_product_response["product"]["idProduct"],
     )
Beispiel #11
0
    def test_add_stock(self):
        mock_oauth = Mock(spec=OAuth1Session)
        mock_oauth.post = MagicMock(return_value=MockResponse(
            {
                "inserted": [{
                    "success": "true",
                    "idArticle": {
                        "product": {
                            "enName": "test"
                        }
                    },
                }]
            },
            200,
            "testing ok",
        ))

        result = self.api.add_stock(TestCommon.get_stock_result, mock_oauth)
        self.assertEqual(result["inserted"][0]["success"], "true")
Beispiel #12
0
 def test_get_orders(self):
     mock_oauth = Mock(spec=OAuth1Session)
     mock_oauth.get = MagicMock(return_value=MockResponse(
         TestCommon.cardmarket_get_order_items, 200, "testing ok"))
     orders = self.api.get_orders("buyer", "received", 0, mock_oauth)
     self.assertEqual(orders[0]["idOrder"], 22935635)
Beispiel #13
0
 def test_get_stock(self):
     mock_oauth = Mock(spec=OAuth1Session)
     mock_oauth.get = MagicMock(return_value=MockResponse(
         TestCommon.cardmarket_get_stock_result, 200, "testing ok"))
     stock = self.api.get_stock(None, mock_oauth)
     self.assertEqual(stock[0]["comments"], "x")