Beispiel #1
0
class WorkingAreasTest(unittest.TestCase):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        load_dotenv()
        self.api_key = os.environ.get('API_KEY', 'sample_api_key')
        self.api_secret = os.environ.get('API_SECRET', 'sample_api_secret')
        self.version = __version__
        self.client = Client(self.api_key, self.api_secret)

        if bool(os.environ.get('TEST', False)):
            self.client.enable_test_mode()

    def test_working_area_attribute_type(self):
        working_area = getattr(self.client, 'working_area', None)

        assert isinstance(working_area, WorkingArea)

    def test_working_area_client(self):
        working_area = getattr(self.client, 'working_area', None)

        assert working_area.client == self.client

    def test_working_area_response_status_code(self):
        response = self.client.working_area.list()
        assert response['status'] == 200
class WorkingAreasTest(unittest.TestCase):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        load_dotenv()
        self.api_key = os.environ.get("API_KEY", "sample_api_key")
        self.api_secret = os.environ.get("API_SECRET", "sample_api_secret")
        self.version = __version__
        self.client = Client(self.api_key, self.api_secret)
        self.working_area = WorkingArea(client=self.client)

        if bool(os.environ.get("TEST", False)):
            self.client.enable_test_mode()

    def test_working_area_attribute_type(self):
        working_area = getattr(self.client, "working_area", None)

        assert isinstance(working_area, WorkingArea)

    def test_working_area_client(self):
        working_area = getattr(self.client, "working_area", None)

        assert working_area.client == self.client

    @pytest.mark.vcr()
    def test_working_area_response_status_code(self):
        response = self.working_area.list()
        assert response["status"] == 200
    def test_client_stage_updates(self):
        client = Client(self.api_key, self.api_secret, stage=Stage.PRODUCTION)

        assert client.stage == Stage.PRODUCTION
        assert client.base_url == 'https://api.glovoapp.com'

        client.enable_test_mode()

        assert client.stage == Stage.TEST
        assert client.base_url == 'https://stageapi.glovoapp.com'

        client.disable_test_mode()

        assert client.stage == Stage.PRODUCTION
        assert client.base_url == 'https://api.glovoapp.com'
class OrdersTest(unittest.TestCase):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        load_dotenv()
        self.version = __version__

        self.api_key = os.environ.get("API_KEY", "sample_api_key")
        self.api_secret = os.environ.get("API_SECRET", "sample_api_secret")
        self.order_id = os.environ.get("ORDER_ID", "sample_order_id")
        self.order_to_estimate = os.environ.get("ORDER_TO_ESTIMATE", "{}")
        self.order_to_estimate = json.loads(self.order_to_estimate)

        self.client = Client(self.api_key, self.api_secret)
        self.order = Order(client=self.client)
        if bool(os.environ.get("TEST", False)):
            self.client.enable_test_mode()

    def test_order_attribute_type(self):
        order = getattr(self.client, "order", None)

        assert isinstance(order, Order)

    def test_order_client(self):
        order = getattr(self.client, "order", None)

        assert order.client == self.client

    @pytest.mark.vcr()
    def test_order_list_status_code(self):
        response = self.order.list()

        assert response["status"] == 200

    @pytest.mark.vcr()
    def test_order_read_status_code(self):
        response = self.order.read(self.order_id)
        assert response["status"] == 200

    @pytest.mark.vcr()
    def test_order_estimate_status_code(self):
        response = self.order.estimate(self.order_to_estimate)
        assert response["status"] == 200
Beispiel #5
0
class OrdersTest(unittest.TestCase):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        load_dotenv()
        self.version = __version__

        self.api_key = os.environ.get('API_KEY', 'sample_api_key')
        self.api_secret = os.environ.get('API_SECRET', 'sample_api_secret')
        self.order_id = os.environ.get('ORDER_ID', 'sample_order_id')
        self.order_to_estimate = os.environ.get('ORDER_TO_ESTIMATE', '{}')
        self.order_to_estimate = json.loads(self.order_to_estimate)

        self.client = Client(self.api_key, self.api_secret)

        if bool(os.environ.get('TEST', False)):
            self.client.enable_test_mode()

    def test_order_attribute_type(self):
        order = getattr(self.client, 'order', None)

        assert isinstance(order, Order)

    def test_order_client(self):
        order = getattr(self.client, 'order', None)

        assert order.client == self.client

    def test_order_list_status_code(self):
        response = self.client.order.list()

        assert response['status'] == 200

    def test_order_read_status_code(self):
        response = self.client.order.read(self.order_id)
        assert response['status'] == 200

    def test_order_estimate_status_code(self):
        response = self.client.order.estimate(self.order_to_estimate)
        assert response['status'] == 200