Пример #1
0
 def test_timestamp(self):
     dataset = get_sample_dataset(day=date(2017, 4, 3))
     self.assertEqual(
         dataset.timestamp,
         timezone.make_aware(datetime(2017, 4, 3, 0, 0, 0),
                             timezone.get_current_timezone()),
     )
Пример #2
0
    def test_datafile(self):
        dataset = get_sample_dataset(day=date(2017, 4, 3),
                                     datasets={
                                         '20170403_something.txt': 'testing',
                                     })

        f = dataset.datafile('something')
        self.assertEqual(f.read(), 'testing')
Пример #3
0
    def test_datafile(self):
        dataset = get_sample_dataset(
            day=date(2017, 4, 3),
            datasets={"20170403_something.txt": "testing"},
        )

        f = dataset.datafile("something")
        self.assertEqual(f.read(), b"testing")
Пример #4
0
    def test_validate_file_single_scenario(self):
        scenario_file = ContentFile(json.dumps(self.scenario))
        dataset = get_sample_dataset()

        with patch(
            'ratechecker.validation.get_rates',
            return_value={'data': {'3.25': '1.75'}}
        ):
            self.validator.validate_file(scenario_file, dataset, scenario_id=0)
Пример #5
0
 def test_timestamp(self):
     dataset = get_sample_dataset(day=date(2017, 4, 3))
     self.assertEqual(
         dataset.timestamp,
         timezone.make_aware(
             datetime(2017, 4, 3, 0, 0, 0),
             timezone.get_current_timezone()
         )
     )
Пример #6
0
    def test_load_fails_if_dataset_missing(self):
        dataset = get_sample_dataset(day=date(2017, 4, 3),
                                     datasets={"20170403_key.txt": "testing"})

        loader = Mock()
        loader.return_value = loader
        dataset.loaders = {"other_key": loader}

        with self.assertRaises(KeyError):
            dataset.load()
Пример #7
0
    def test_load_calls_loaders(self):
        dataset = get_sample_dataset(day=date(2017, 4, 3),
                                     datasets={"20170403_key.txt": "testing"})

        loader = Mock()
        loader.return_value = loader
        dataset.loaders = {"key": loader}
        dataset.load()

        loader.load.assert_called_once()
Пример #8
0
    def test_validate_file_scenario_fails(self):
        scenario_file = ContentFile(json.dumps(self.scenario))
        dataset = get_sample_dataset()

        with patch(
            'ratechecker.validation.get_rates',
            return_value={'data': {'3.25': '0.00'}}
        ):
            with self.assertRaises(ValidationError):
                self.validator.validate_file(scenario_file, dataset)
Пример #9
0
    def test_datafile(self):
        dataset = get_sample_dataset(
            day=date(2017, 4, 3),
            datasets={
                '20170403_something.txt': 'testing',
            }
        )

        f = dataset.datafile('something')
        self.assertEqual(f.read(), 'testing')
    def test_validate_file_single_scenario(self):
        scenario_file = ContentFile(json.dumps(self.scenario))
        dataset = get_sample_dataset()

        with patch(
                "ratechecker.validation.get_rates",
                return_value={"data": {
                    "3.25": "1.75"
                }},
        ):
            self.validator.validate_file(scenario_file, dataset, scenario_id=0)
    def test_validate_file_scenario_fails(self):
        scenario_file = ContentFile(json.dumps(self.scenario))
        dataset = get_sample_dataset()

        with patch(
                "ratechecker.validation.get_rates",
                return_value={"data": {
                    "3.25": "0.00"
                }},
        ):
            with self.assertRaises(ValidationError):
                self.validator.validate_file(scenario_file, dataset)
Пример #12
0
    def test_load_calls_loaders(self):
        dataset = get_sample_dataset(
            day=date(2017, 4, 3),
            datasets={
                '20170403_key.txt': 'testing',
            }
        )

        loader = Mock()
        loader.return_value = loader
        dataset.loaders = {'key': loader}
        dataset.load()

        loader.load.assert_called_once()
Пример #13
0
 def test_cover_sheet(self):
     dataset = get_sample_dataset()
     self.assertIsInstance(dataset.cover_sheet, CoverSheet)
Пример #14
0
 def test_cover_sheet(self):
     dataset = get_sample_dataset()
     self.assertIsInstance(dataset.cover_sheet, CoverSheet)