Beispiel #1
0
def test_gen_date_9():
    """Create a date with non-Date arguments."""
    with pytest.raises(ValueError):
        gen_date(
            min_date='abc',
            max_date='def'
        )
Beispiel #2
0
def test_gen_date_10():
    """Create a date with non-Date arguments."""
    with pytest.raises(ValueError):
        gen_date(
            min_date=1,
            max_date=1
        )
Beispiel #3
0
def test_gen_date_14():
    """max-date must be a Date type."""
    with pytest.raises(ValueError):
        gen_date(
            min_date=datetime.date.today(),
            max_date='foo'
        )
Beispiel #4
0
def test_gen_date_11():
    """Create a date with non-Date arguments."""
    with pytest.raises(ValueError):
        gen_date(
            min_date=(1,),
            max_date=(2, 3, 4)
        )
Beispiel #5
0
def test_gen_date_12():
    """Create a date with non-Date arguments."""
    with pytest.raises(ValueError):
        gen_date(
            min_date=['a', 'b'],
            max_date=['c', 'd', 'e']
        )
Beispiel #6
0
    def test_gen_date_12(self):
        """
        @Test: Create a date with non-Date arguments
        @Feature: Date Generator
        @Assert: Date should not be created due to value error
        """

        with self.assertRaises(ValueError):
            gen_date(min_date=['a', 'b'], max_date=['c', 'd', 'e'])
Beispiel #7
0
    def test_gen_date_11(self):
        """
        @Test: Create a date with non-Date arguments
        @Feature: Date Generator
        @Assert: Date should not be created due to value error
        """

        with self.assertRaises(ValueError):
            gen_date(min_date=(1, ), max_date=(2, 3, 4))
Beispiel #8
0
    def test_gen_date_14(self):
        """
        @Test: max-date must be a Datetime type
        @Feature: DateTime Generator
        @Assert: Datetime should not be created due to value error
        """

        with self.assertRaises(ValueError):
            gen_date(min_date=datetime.datetime.now(), max_date='foo')
    def test_gen_date_12(self):
        """
        @Test: Create a date with non-Date arguments
        @Feature: Date Generator
        @Assert: Date should not be created due to value error
        """

        with self.assertRaises(ValueError):
            gen_date(
                min_date=['a', 'b'],
                max_date=['c', 'd', 'e']
            )
Beispiel #10
0
    def test_gen_date_11(self):
        """
        @Test: Create a date with non-Date arguments
        @Feature: Date Generator
        @Assert: Date should not be created due to value error
        """

        with self.assertRaises(ValueError):
            gen_date(
                min_date=(1,),
                max_date=(2, 3, 4)
            )
Beispiel #11
0
def test_gen_date_13():
    """Create a date with min_date > max_date."""
    # Today is...
    today = datetime.date.today()
    # Five days into the future
    min_date = today + datetime.timedelta(5)

    with pytest.raises(AssertionError):
        gen_date(
            min_date=min_date,
            max_date=today
        )
Beispiel #12
0
    def test_gen_date_14(self):
        """
        @Test: max-date must be a Date type
        @Feature: Date Generator
        @Assert: Date should not be created due to value error
        """

        with self.assertRaises(ValueError):
            gen_date(
                min_date=datetime.date.today(),
                max_date='foo'
            )
Beispiel #13
0
    def test_gen_date_13(self):
        """
        @Test: Create a date with min_date > max_date
        @Feature: Date Generator
        @Assert: Date should not be created due to assertion error
        """

        # Today is...
        today = datetime.date.today()
        # Five days into the future
        min_date = today + datetime.timedelta(5)

        with self.assertRaises(AssertionError):
            gen_date(min_date=min_date, max_date=today)
Beispiel #14
0
def test_gen_date_2(item):
    """Create a date with only min_date."""
    # Today is...
    today = datetime.date.today()
    # Five days ago
    min_date = today - datetime.timedelta(5)

    assert gen_date(min_date=min_date) >= min_date
Beispiel #15
0
    def test_gen_date_13(self):
        """
        @Test: Create a date with min_date > max_date
        @Feature: Date Generator
        @Assert: Date should not be created due to assertion error
        """

        # Today is...
        today = datetime.date.today()
        # Five days into the future
        min_date = today + datetime.timedelta(5)

        with self.assertRaises(AssertionError):
            gen_date(
                min_date=min_date,
                max_date=today
            )
Beispiel #16
0
def test_gen_date_3(item):
    """Create a date with only max_date."""
    # Today is...
    today = datetime.date.today()
    # Five days into the future
    max_date = today + datetime.timedelta(5)

    assert gen_date(max_date=max_date) <= max_date
Beispiel #17
0
 def test_gen_date_1(self):
     """
     @Test: Create a date with no arguments
     @Feature: Date Generator
     @Assert: Date is created with random values.
     """
     result = gen_date()
     self.assertTrue(isinstance(result, datetime.date),
                     "Data is not instance of datetime.date.")
Beispiel #18
0
 def test_gen_date_1(self):
     """
     @Test: Create a date with no arguments
     @Feature: Date Generator
     @Assert: Date is created with random values.
     """
     result = gen_date()
     self.assertTrue(
         isinstance(result, datetime.date),
         "Data is not instance of datetime.date.")
Beispiel #19
0
def test_gen_date_6(item):
    """Create a date with max_date == 'None'."""
    # max_date for the platform
    max_date = (datetime.date.today() +
                datetime.timedelta(365 * MAX_YEARS))
    # min_date  = max_date - 1 year
    min_date = max_date - datetime.timedelta(365 * 1)

    result = gen_date(
        min_date=min_date,
        max_date=None
    )
    assert result.year <= max_date.year
    assert result.year >= min_date.year
def _bios_date():
    """Generate a random date for system's BIOS between
    today and 10 years ago.

    :return: A random `datetime.date` that falls within the last 10 years
        from today.
    :rtype: object

    """
    # Today is...
    today = datetime.date.today()
    # and 10 years ago (~365 days * 10 years) is
    ten_years_ago = today - datetime.timedelta(3650)
    return gen_date(ten_years_ago, today)
Beispiel #21
0
def _bios_date():
    """Generate a random date for system's BIOS between
    today and 10 years ago.

    :return: A random `datetime.date` that falls within the last 10 years
        from today.
    :rtype: object

    """
    # Today is...
    today = datetime.date.today()
    # and 10 years ago (~365 days * 10 years) is
    ten_years_ago = today - datetime.timedelta(3650)
    return gen_date(ten_years_ago, today)
Beispiel #22
0
    def test_gen_date_2(self):
        """
        @Test: Create a date with only min_date
        @Feature: Date Generator
        @Assert: Date should be created and not be before minimum date
        """

        # Today is...
        today = datetime.date.today()
        # Five days ago
        min_date = today - datetime.timedelta(5)

        for turn in range(10):
            result = gen_date(min_date=min_date)
            self.assertTrue(result >= min_date)
Beispiel #23
0
    def test_gen_date_3(self):
        """
        @Test: Create a date with only max_date
        @Feature: Date Generator
        @Assert: Date should be created and not be after maximum date
        """

        # Today is...
        today = datetime.date.today()
        # Five days into the future
        max_date = today + datetime.timedelta(5)

        for turn in range(10):
            result = gen_date(max_date=max_date)
            self.assertTrue(result <= max_date)
Beispiel #24
0
    def test_gen_date_2(self):
        """
        @Test: Create a date with only min_date
        @Feature: Date Generator
        @Assert: Date should be created and not be before minimum date
        """

        # Today is...
        today = datetime.date.today()
        # Five days ago
        min_date = today - datetime.timedelta(5)

        for turn in range(10):
            result = gen_date(min_date=min_date)
            self.assertTrue(result >= min_date)
Beispiel #25
0
def test_gen_date_7(item):
    """Create a date with specific date ranges."""
    # min_date for the platform
    min_date = (datetime.date.today() -
                datetime.timedelta(365 * MIN_YEARS))
    # max_date for the platform
    max_date = (datetime.date.today() +
                datetime.timedelta(365 * MAX_YEARS))

    result = gen_date(
        min_date=min_date,
        max_date=max_date
    )
    assert result.year <= max_date.year
    assert result.year >= min_date.year
Beispiel #26
0
def test_gen_date_4(item):
    """Create a date with both arguments."""
    # Today is...
    today = datetime.date.today()
    # Five days ago
    min_date = today - datetime.timedelta(5)
    # Five days into the future
    max_date = today + datetime.timedelta(5)

    result = gen_date(
        min_date=min_date,
        max_date=max_date
    )
    assert result >= min_date
    assert result <= max_date
Beispiel #27
0
    def test_gen_date_3(self):
        """
        @Test: Create a date with only max_date
        @Feature: Date Generator
        @Assert: Date should be created and not be after maximum date
        """

        # Today is...
        today = datetime.date.today()
        # Five days into the future
        max_date = today + datetime.timedelta(5)

        for turn in range(10):
            result = gen_date(max_date=max_date)
            self.assertTrue(result <= max_date)
Beispiel #28
0
    def test_gen_date_5(self):
        """
        @Test: Create a date with min_date == 'None'
        @Feature: Date Generator
        @Assert: Date should be created and fall before maximum date
        """

        # min_date for the platform
        min_date = (datetime.date.today() -
                    datetime.timedelta(365 * MIN_YEARS))
        # max_date = min_date + 1 year
        max_date = min_date + datetime.timedelta(365 * 1)

        for turn in range(20):
            result = gen_date(min_date=None, max_date=max_date)
            self.assertTrue(result.year <= max_date.year)
            self.assertTrue(result.year >= min_date.year)
Beispiel #29
0
    def test_gen_date_6(self):
        """
        @Test: Create a date with max_date == 'None'
        @Feature: Date Generator
        @Assert: Date should be created and fall after minimum date
        """

        # max_date for the platform
        max_date = (datetime.date.today() +
                    datetime.timedelta(365 * MAX_YEARS))
        # min_date  = max_date - 1 year
        min_date = max_date - datetime.timedelta(365 * 1)

        for turn in range(20):
            result = gen_date(min_date=min_date, max_date=None)
            self.assertTrue(result.year <= max_date.year, result)
            self.assertTrue(result.year >= min_date.year, result)
Beispiel #30
0
    def test_gen_date_4(self):
        """
        @Test: Create a date with both arguments
        @Feature: Date Generator
        @Assert: Date should be created and fall within specified range
        """

        # Today is...
        today = datetime.date.today()
        # Five days ago
        min_date = today - datetime.timedelta(5)
        # Five days into the future
        max_date = today + datetime.timedelta(5)

        for turn in range(10):
            result = gen_date(min_date=min_date, max_date=max_date)
            self.assertTrue(result >= min_date)
            self.assertTrue(result <= max_date)
Beispiel #31
0
    def test_gen_date_7(self):
        """
        @Test: Create a date with specific date ranges
        @Feature: Date Generator
        @Assert: Date should be created and fall inside the date range
        """

        # min_date for the platform
        min_date = (datetime.date.today() -
                    datetime.timedelta(365 * MIN_YEARS))
        # max_date for the platform
        max_date = (datetime.date.today() +
                    datetime.timedelta(365 * MAX_YEARS))

        for turn in range(20):
            result = gen_date(min_date=min_date, max_date=max_date)
            self.assertTrue(result.year <= max_date.year, result)
            self.assertTrue(result.year >= min_date.year, result)
Beispiel #32
0
    def test_gen_date_5(self):
        """
        @Test: Create a date with min_date == 'None'
        @Feature: Date Generator
        @Assert: Date should be created and fall before maximum date
        """

        # min_date for the platform
        min_date = (datetime.date.today() -
                    datetime.timedelta(365 * MIN_YEARS))
        # max_date = min_date + 1 year
        max_date = min_date + datetime.timedelta(365 * 1)

        for turn in range(20):
            result = gen_date(
                min_date=None,
                max_date=max_date
            )
            self.assertTrue(result.year <= max_date.year)
            self.assertTrue(result.year >= min_date.year)
Beispiel #33
0
    def test_gen_date_6(self):
        """
        @Test: Create a date with max_date == 'None'
        @Feature: Date Generator
        @Assert: Date should be created and fall after minimum date
        """

        # max_date for the platform
        max_date = (datetime.date.today() +
                    datetime.timedelta(365 * MAX_YEARS))
        # min_date  = max_date - 1 year
        min_date = max_date - datetime.timedelta(365 * 1)

        for turn in range(20):
            result = gen_date(
                min_date=min_date,
                max_date=None
            )
            self.assertTrue(result.year <= max_date.year, result)
            self.assertTrue(result.year >= min_date.year, result)
Beispiel #34
0
    def test_gen_date_4(self):
        """
        @Test: Create a date with both arguments
        @Feature: Date Generator
        @Assert: Date should be created and fall within specified range
        """

        # Today is...
        today = datetime.date.today()
        # Five days ago
        min_date = today - datetime.timedelta(5)
        # Five days into the future
        max_date = today + datetime.timedelta(5)

        for turn in range(10):
            result = gen_date(
                min_date=min_date,
                max_date=max_date
            )
            self.assertTrue(result >= min_date)
            self.assertTrue(result <= max_date)
Beispiel #35
0
    def test_gen_date_7(self):
        """
        @Test: Create a date with specific date ranges
        @Feature: Date Generator
        @Assert: Date should be created and fall inside the date range
        """

        # min_date for the platform
        min_date = (datetime.date.today() -
                    datetime.timedelta(365 * MIN_YEARS))
        # max_date for the platform
        max_date = (datetime.date.today() +
                    datetime.timedelta(365 * MAX_YEARS))

        for turn in range(20):
            result = gen_date(
                min_date=min_date,
                max_date=max_date
            )
            self.assertTrue(result.year <= max_date.year, result)
            self.assertTrue(result.year >= min_date.year, result)
Beispiel #36
0
def test_gen_date_1():
    """Create a date with no arguments."""
    result = gen_date()
    assert isinstance(result, datetime.date)
Beispiel #37
0
def daterange(request):
    """Return a randomized daterange tuple."""
    offset = datetime.timedelta(days=7)
    start = fauxfactory.gen_date()
    return (start, start + offset)
Beispiel #38
0
def daterange_parametrized(request, daterange_offset_parametrized):
    """Return daterange parametrized with various lengths."""
    start = fauxfactory.gen_date()
    return (start, start + daterange_offset_parametrized)
Beispiel #39
0
 def gen_value(self):
     """Return a value suitable for a :class:`DateField`."""
     return gen_date(self.min_date, self.max_date)
Beispiel #40
0
symbol_tests = [
    fauxfactory.gen_alpha(),
    "_{0}".format(fauxfactory.gen_alpha()),
    "{0}.{1}".format(fauxfactory.gen_alpha(), fauxfactory.gen_alpha()),
    "_{0}.{1}".format(fauxfactory.gen_alpha(), fauxfactory.gen_alpha()),
    ("'{0}'".format(fauxfactory.gen_alpha()), ParseException),
    ('"{0}"'.format(fauxfactory.gen_alpha()), ParseException),
    (fauxfactory.gen_numeric_string(), ParseException),
]

value_tests = [
    "'{0}'".format(fauxfactory.gen_alpha()),
    '"{0}"'.format(fauxfactory.gen_alpha()),
    fauxfactory.gen_numeric_string(),
    fauxfactory.gen_date().isoformat(),
    fauxfactory.gen_time().isoformat(),
    fauxfactory.gen_datetime().isoformat(),
    (fauxfactory.gen_alpha(), ParseException),
    ("_{0}".format(fauxfactory.gen_alpha()), ParseException),
    ("{0}.{1}".format(fauxfactory.gen_alpha(), fauxfactory.gen_alpha()), ParseException),
    ("_{0}.{1}".format(fauxfactory.gen_alpha(), fauxfactory.gen_alpha()), ParseException),
]

regex_tests = [
    "/regex/",
    "/regex/i",
    "/regex/im",
    ("/not[a-valid/", ParseException),
    ("/not(a-valid/", ParseException),
    ("/not-a-valid)", ParseException),
Beispiel #41
0
 def gen_value(self):
     """Return a value suitable for a :class:`DateField`."""
     return gen_date(self.min_date, self.max_date)
Beispiel #42
0
def daterange(request):
    """Return a randomized daterange tuple."""
    offset = datetime.timedelta(days=7)
    start = fauxfactory.gen_date()
    return (start, start + offset)
Beispiel #43
0
def daterange_parametrized(request, daterange_offset_parametrized):
    """Return daterange parametrized with various lengths."""
    start = fauxfactory.gen_date()
    return (start, start + daterange_offset_parametrized)