def test_build_schema_no_update(self):
     """assert behavior for no_update"""
     metadata = schema_utils.build_metadata(
         self.dummy_schema,
         self.fake_metadata,
         schema_utils.Update.no_update,
     )
     assert metadata == self.fake_metadata
    def test_build_schema_badschema(self):
        """assert behavior for bad schema"""
        dummy_meta = {
            'schema': '',
            'version': '1.0.0',
            'update': datetime.datetime.utcnow().isoformat(),
        }

        with pytest.raises(jsonschema.exceptions.ValidationError):
            metadata = schema_utils.build_metadata(
                self.dummy_schema, dummy_meta, schema_utils.Update.first_run)
    def test_build_schema_major(self):
        """assert behavior for major update"""
        metadata = schema_utils.build_metadata(
            self.dummy_schema,
            self.fake_metadata,
            schema_utils.Update.major,
        )

        assert metadata['schema'] == self.dummy_schema
        assert metadata['update'] != self.fake_metadata['update']
        assert metadata['version'] == '1.3.0'
    def test_build_schema_first_run(self):
        """assert behavior for first_run"""
        metadata = schema_utils.build_metadata(
            self.dummy_schema,
            self.fake_metadata,
            schema_utils.Update.first_run,
        )

        assert metadata['schema'] == self.dummy_schema
        assert metadata['update'] != self.fake_metadata['update']
        assert metadata['version'] == self.fake_metadata['version']