<gh_stars>0
# -*- coding: utf-8 -*-

"""
Test module for the Scraper against Finn.no housing search

"""

__author__ = '<NAME>'
__email__ = '<EMAIL>'

from uuid import UUID

import pytest as pt

from source.app import Finn
from source.util import TrackingError


class TestFinn:
    """
    Test cases for the Finn scraper

    """

    @classmethod
    def setup(cls):
        """
        Executed before all tests

        """
        cls.finn = Finn("144857770")

    def test_finn_is_instance_of_scraper(self):
        """
        Test that Finn object is instance and subclass of Scraper

        """
        assert isinstance(self.finn, Finn)
        assert isinstance(self.finn, Finn)
        assert issubclass(self.finn.__class__, Finn)

    @staticmethod
    @pt.mark.parametrize("invalid_finn_code_types", [144857770, 144857770.0, True, [], (), {}])
    def test_invalid_finn_code_raises_type_error(invalid_finn_code_types):
        """
        Test that Finn raises TypeError for invalid finn_code types

        """
        with pt.raises(TypeError):
            Finn(invalid_finn_code_types)

    @pt.mark.parametrize("invalid_finn_code", ["1448577", "2448577701", "24485777a"])
    def test_validate_finn_code_method(self, invalid_finn_code):
        """
        Test that invalid finn_code raises TrackingError

        """
        with pt.raises(TrackingError):
            Finn(invalid_finn_code)

    def test_finn_has_uuid4_compatible_id(self):
        """
        Test Finn scraper has uuid4 compatible ids

        """
        assert UUID(str(self.finn.id_))

# -*- coding: utf-8 -*-

"""
Test module for the Scraper against Finn.no housing search

"""

__author__ = '<NAME>'
__email__ = '<EMAIL>'

from uuid import UUID

import pytest as pt

from source.app import Finn
from source.util import TrackingError


class TestFinn:
    """
    Test cases for the Finn scraper

    """

    @classmethod
    def setup(cls):
        """
        Executed before all tests

        """
        cls.finn = Finn("144857770")

    def test_finn_is_instance_of_scraper(self):
        """
        Test that Finn object is instance and subclass of Scraper

        """
        assert isinstance(self.finn, Finn)
        assert isinstance(self.finn, Finn)
        assert issubclass(self.finn.__class__, Finn)

    @staticmethod
    @pt.mark.parametrize("invalid_finn_code_types", [144857770, 144857770.0, True, [], (), {}])
    def test_invalid_finn_code_raises_type_error(invalid_finn_code_types):
        """
        Test that Finn raises TypeError for invalid finn_code types

        """
        with pt.raises(TypeError):
            Finn(invalid_finn_code_types)

    @pt.mark.parametrize("invalid_finn_code", ["1448577", "2448577701", "24485777a"])
    def test_validate_finn_code_method(self, invalid_finn_code):
        """
        Test that invalid finn_code raises TrackingError

        """
        with pt.raises(TrackingError):
            Finn(invalid_finn_code)

    def test_finn_has_uuid4_compatible_id(self):
        """
        Test Finn scraper has uuid4 compatible ids

        """
        assert UUID(str(self.finn.id_))
# -*- coding: utf-8 -*- Test module for the Scraper against Finn.no housing search Test cases for the Finn scraper Executed before all tests Test that Finn object is instance and subclass of Scraper Test that Finn raises TypeError for invalid finn_code types Test that invalid finn_code raises TrackingError Test Finn scraper has uuid4 compatible ids